/// <summary> /// Show button for translate /// </summary> private void ShowTranslationButton() { this.SetDesktopLocation(Cursor.Position.X - 15, Cursor.Position.Y + 15); this.Visible = true; this.Focus(); WindowApi.SetForegroundWindow(this.Handle); }
public static Process StartDetached(string filename, string arguments, string startFolder, bool hidden = true) { var process = new Process(); process.StartInfo = new ProcessStartInfo(filename) { Arguments = arguments, UseShellExecute = true, WorkingDirectory = startFolder, }; if (hidden) { process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; process.Start(); } else { process.StartInfo.WindowStyle = ProcessWindowStyle.Normal; process.Start(); for (int i = 0; process.MainWindowHandle == IntPtr.Zero && i < 30; i++) { System.Threading.Thread.Sleep(10); } // set user the focus to the window, if there is one. if (process.MainWindowHandle != IntPtr.Zero) { _ = WindowApi.SetForegroundWindow(process.MainWindowHandle); } } return(process); }