private void OnCompileResultDialogOpened(object sender, WinEventArgs args) { var windowTitle = WinUtil.GetWindowTitle(args.HWnd); if (windowTitle == "Success" || windowTitle == "Error") { // Enter to close the result dialog after compiling WinUtil.SimulateKey("{ENTER}"); if (windowTitle == "Success") { WinUtil.BringWindowToFront("Superfighters Deluxe Map Editor"); WinUtil.SimulateKey("{F5}"); // Run map editor test } _winService.ForegroundChanged -= OnCompileResultDialogOpened; } }