Launch application process in the background

827 Views Asked by At

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?

2

There are 2 best solutions below

1
On BEST ANSWER

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

1
On

have you tried something like:

    static void Main(string[] args)
    {

        var Process = new Process
        {
            StartInfo =
            {
                FileName = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\Chrome.exe",
                WindowStyle = ProcessWindowStyle.Normal
            }
        };


        Process.Start();

        Console.ReadKey();

    }