public static void Main(string[] args) { if (args.Length != 0) { if (args[0] == "-set") { //Open settings window Application.EnableVisualStyles(); Application.Run(new Settings()); } } else { if (settings.Multiplayer) { //Disable player2 record device SetDeviceState(settings.GUID2); //Register hotkey and press event InitHotKey(); } //Reading Offsets ReadOffsetValues(); //Reading PID&VID values for Player1 ReadDeviceValues(false); //Launching Rocksmith 2014 StartGame(); //Getting process id and setting exit event HookProcess(); //Checking offsets to write if (CheckOffsets() == false) { if (settings.manualOffsets) { ExitWithError("Offsets values are wrong! Set proper values manually in settings or uncheck \"Manual Offsets\" to find it automatically."); } else { //Find offsets automatically FindOffsets(); } } //Patching game Patch(); if (settings.Multiplayer) { //Waiting for hotkey while (!stopWait) { Thread.Sleep(100); } //If game still running if (gameRunning) { //Reading PID&VID values for Player2 ReadDeviceValues(true); //Patching game for multiplayer Patch(); } //Enable player2 record device SetDeviceState(settings.GUID2, true); //Free hotkey HotKeyManager.UnregisterHotKey(hotkeyID); } //Closing game handle CloseHandle(procInfo.Handle); } }
private static void InitHotKey() { hotkeyID = HotKeyManager.RegisterHotKey(Keys.M, KeyModifiers.Control); HotKeyManager.HotKeyPressed += HotKeyManager_HotKeyPressed; }
private static void InitHotKey() { hotkeyID = HotKeyManager.RegisterHotKey(Keys.M, KeyModifiers.Control); HotKeyManager.HotKeyPressed += new EventHandler <HotKeyEventArgs>(HotKeyManager_HotKeyPressed); }
public static void Main(string[] args) { if (args.Length != 0) { if (args[0] == "-set") { //Open settings window Application.EnableVisualStyles(); Application.Run(new Settings()); } else if (args[0] == "-fof") { //Find offcets and write it to settings var offsets = SearchOffcets(); if (offsets != null) { if (MessageBox.Show("Offcets found!" + Environment.NewLine + "VID Offcet: " + offsets.Item1 + Environment.NewLine + "PID Offcet: " + offsets.Item2 + Environment.NewLine + "Save It to settings?", Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { settings.offcetVID = offsets.Item1; settings.offcetPID = offsets.Item2; settings.Save(); } } else { MessageBox.Show("Offcets NOT found!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } else { if (settings.Multiplayer) { //Disable player2 record device SetDeviceState(settings.GUID2, false); //Register hotkey and press event InitHotKey(); } //Getting Offcets GetOffcetValues(); //Getting PID&VID values for Player1 GetDeviceValues(false); //Launching Rocksmith 2014 StartGame(); //Getting process id and setting exit event HookProcess(); //Checking offcets to write if (CheckOffcets() == false) { ExitWithError("Offcets values are wrong! Set It in settings."); } //Patching game Patch(); if (settings.Multiplayer) { //Waiting for hotkey while (!stopWait) { Thread.Sleep(100); } //If game still running if (gameRunning) { //Getting PID&VID values for Player2 GetDeviceValues(true); //Patching game for multiplayer Patch(); } //Enable player2 record device SetDeviceState(settings.GUID2, true); //Free hotkey HotKeyManager.UnregisterHotKey(hotkeyID); } } }
public static void Main(string[] args) { if (System.Diagnostics.Process.GetProcessesByName(System.IO.Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly().Location)).Count() > 1) { MessageBox.Show("NoCableLauncher is already running."); Application.Exit(); } bool isOpenSettings = false; if (args.Length != 0) { if (args[0] == "-set") { isOpenSettings = true; } } // First of all, check if the bat file exists, if not, create it if (!File.Exists(SettingsFileBat)) { File.WriteAllText(SettingsFileBat, "start " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + ".exe -set"); // And since there was no Bat file we assume this is the first we are running the program, so let's open the settings directly isOpenSettings = true; } bool isOpenGame = true; if (isOpenSettings) { // Open settings window Application.EnableVisualStyles(); Settings settings = new Settings(); Application.Run(settings); isOpenGame = settings.OpenGameOnClose; } if (isOpenGame) { // Hotfix to allow us to use all Recording devices when not in Multiplayer mode if (!Common.settings.Multiplayer) { FixRecordingDevices(); } else if (IsDeviceUsbAndConnected(Common.settings.PID, Common.settings.VID)) { // Disable player2 record device if (!Common.SetDeviceState(Common.settings.GUID2)) { ExitWithError("Player2 Input device is not set!"); } // Register hotkey and press event InitHotKey(); } // Reading Offsets ReadOffsetValues(); // Reading PID&VID values for Player1 ReadDeviceValues(false); // Launching Rocksmith 2014 StartGame(); // Getting process id and setting exit event HookProcess(); // Checking offsets to write if (CheckOffsets() == false) { if (Common.settings.manualOffsets) { ExitWithError("Offsets values are wrong! Set proper values manually in settings or uncheck \"Manual Offsets\" to find it automatically."); } else { // Find offsets automatically FindOffsets(); } } // Patching game Patch(); // If game still running if (Common.settings.Multiplayer) { // Waiting for hotkey while (!stopWait) { Thread.Sleep(100); } if (gameRunning) { // Reading PID&VID values for Player2 ReadDeviceValues(true); // Patching game for multiplayer Patch(); // Enable player2 record device if (!Common.SetDeviceState(Common.settings.GUID2, true)) { ExitWithError("Player2 Input device is not set!"); } } // Free hotkey HotKeyManager.UnregisterHotKey(hotkeyID); } else // !Common.settings.Multiplayer { if (Common.settings.SingleplayerMode == 0) { bool okPressed = false; // Process watch var context = TaskScheduler.FromCurrentSynchronizationContext(); Task T = Task.Factory.StartNew(() => { while (true) { Process[] processes = Process.GetProcessesByName(exeName); if (processes.Length <= 0) { // Ouch CloseHandle(procInfo.Handle); Application.Exit(); } if (okPressed) { break; } Thread.Sleep(50); } }); // Wait for the ok prompt MessageBox.Show("After the game is opened and in the main menu, press ALT-TAB to change back to this window and press 'OK'.", "Info"); okPressed = true; ReadDeviceValues(true); Patch(); Thread.Sleep(500); } } // Closing game handle CloseHandle(procInfo.Handle); if (!Common.settings.Multiplayer) { if (Common.settings.SingleplayerMode == 1) { // Wait for the game to close so we can re-enable the disabled devices while (true) { Process[] processes = Process.GetProcessesByName(exeName); if (processes.Length <= 0) { break; } Thread.Sleep(1000); } } if (RequiresCaptureDeviceReenable) { Common.ReEnableCaptureDevices(); } } } }