private void ForegroundWatcher_ForegroundChanged(object sender, ForegroundArgs e) { if (e.Process.ProcessName != "ra3_1.12.game") { return; } Log("RA3 Window found"); latestRa3 = e.Process; if (settings.RemoveBorder) { if (!WindowInvocation.DropBorder(e.Process)) { Log("Remove Window Border failed."); } if (!WindowInvocation.ResizeWindow(e.Process)) { Log("Resize Window failed."); } } if (settings.LockCursor) { WindowInvocation.ClipCursor(e.Process); } if (settings.InvokeAltUp) { Task.Delay(100).ContinueWith(_ => { Messaging.SimulateAltKeyPress(e.Process.MainWindowHandle); // Messaging.InvokeSysKeyPress(e.Process.MainWindowHandle, (uint) Keys.Menu); // Messaging.InvokeSysKeyPress(e.Process.MainWindowHandle, (int)Keys.Menu); // ALT key }); } if (settings.RefreshPathToRa3) { try { // Dirty? string manualPath = Path.Combine( Path.GetDirectoryName(Path.GetDirectoryName(e.Process.MainModule.FileName)) , "RA3.exe" ); txtRa3Path.Text = manualPath; }catch (Exception err) { err = err; } } }
private void SystemWatcherSystemChanged(object sender, ProcessArgs e) { if (e.Process.ProcessName != Constants.Ra3ProcessName) { return; } if (LatestRa3 == null || LatestRa3.HasExited) { LatestRa3 = e.Process; } if (settings.LaunchRa3Windowed) { _mouseWatcher.WatchCursor(settings.SleepTime); } if (settings.RemoveBorder) { WindowInvocation.DropBorder(e.Process); WindowInvocation.ResizeWindow(e.Process); Logger.Info("OK.. drop border and resize"); } if (settings.LockCursor) { bool success = WindowInvocation.LockToProcess(e.Process); Logger.Info($"OK.. lock cursor to ra3 window. success: {success}"); } if (settings.InvokeAltUp) { Task.Delay(100).ContinueWith(_ => { Inputs.SimulateAltKeyPress(e.Process.MainWindowHandle); // Messaging.InvokeSysKeyPress(e.Process.MainWindowHandle, (uint) Keys.Menu); // Messaging.InvokeSysKeyPress(e.Process.MainWindowHandle, (int)Keys.Menu); // ALT key Logger.Info("OK.. invoke alt keypress after ra3 has gained focus"); }); } }