public LinkResult Compile(ProjectInfo projectInfo, ScriptInfo scriptInfo, bool runAfterCompiling) { var sfdProcess = Process.GetProcessesByName("Superfighters Deluxe").FirstOrDefault(); if (sfdProcess == null) { return(new LinkResult(AutomationError.SfdNotOpen)); } var result = CopyToClipboard(projectInfo, scriptInfo); var sourceCode = result.Content; //var sourceCode = await Task.Run(() => _linker.Link(ProjectInfo, ScriptInfo)); // Switch to the Script Editor window WinUtil.BringWindowToFront("Script Editor"); // Wait until the window is switching back while (WinUtil.GetActiveWindowTitle() == null) { } if (WinUtil.GetActiveWindowTitle() == "Script Editor") { // Tab to focus in the editor's text area if not already WinUtil.SimulateKey("{TAB}"); // CTRL-A Select all text in editor WinUtil.SimulateKey("^(a)"); // CTRL-V Paste clipboard content WinUtil.SimulateKey("^(v)"); // Compile newly pasted code WinUtil.SimulateKey("{F5}"); if (runAfterCompiling) { RunMapEditorTestIfSuccess(); } return(result); } else { return(new LinkResult(AutomationError.ScriptEditorNotOpen)); } }
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; } }