var prs = new ProcessStartInfo("chrome.exe"); prs.Arguments = "http://translate.google.com"; Process p= Process.Start(prs); Program.setFocusToProcess(p);
public static void setFocusToThisProcessName(string name) { Process[] Processes = Process.GetProcessesByName(name); //if (Processes.Length == 0) //{ // MessageBox.Show("The program: '" + name + "' isn't running and can't be focused on.", "TranslateProgram"); // return; //} foreach (Process process in Processes) { setFocusToProcess(process); } } static void setFocusToProcess(Process process) { if (process.MainWindowHandle == (IntPtr)0x00000000) { return; } const int SW_RESTORE = 9; //if(IsIconic(process.MainWindowHandle) != 0) //{ ShowWindow(process.MainWindowHandle, SW_RESTORE); //} SetForegroundWindow(process.MainWindowHandle); BringWindowToTop(process.MainWindowHandle); SetFocus(new HandleRef(null, process.MainWindowHandle)); }
Process process = new Process(); process.StartInfo.FileName = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"; process.StartInfo.Arguments = "google.com" + " --new-window"; process.Start();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)