Search code examples
c#winformsgoogle-chromesetforegroundwindow

Launch application process in the background


I have created a Windows Forms app that listens to keyboard input. When the correct input command is entered it should launch an instance of google chrome which will then run a chrome extension that I have developed.

I want the chrome process to run quietly in the background whilst other foreground processes run if possible. Or if this is not possible then I want to be able to swap back to the process that was active in the foreground before the command was successfully input.

Is this at all possible?


Solution

  • Try This:

        private void MainForm_KeyUp(object sender, KeyEventArgs e)
        {
            Log("MainForm_KeyUp");
            if (e.Control && e.KeyCode == Keys.P)
            {
                Process.Start("chrome.exe", "http://www.your_website_url.com");
             } 
    
        }
    

    Make sure you will set keypreview property of the form to true

    Vaibhav Tapare