h_a86
h_a86

Reputation: 772

C# keydown event

I am using this code for opening an application from C# keydown event

private void Form1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.F && e.Alt)
    {
        Process.Start(@"c:\ade.exe");
    }
}

It's working perfectly, but when my windows form application is in working mode, I want to work it also when my app is minimized.

Upvotes: 1

Views: 5485

Answers (3)

Ashkan Mobayen Khiabani
Ashkan Mobayen Khiabani

Reputation: 34180

Well the keydown (keyup, keypress , mousedown, ...) will work when your application is active and the control that you have written the code has the focus. if you want to get key strike any way. you can search in google and codeproject.com for examples of keyboard hook. here are some examples:

example 1

example 2

Upvotes: 0

Shai
Shai

Reputation: 25595

You'll have to use hooking for this,

I googled abit for you and came across this website. it's a small class that allows you to bind a Hotkey to your application, when once pressed - you can fire an event in your application.

Upvotes: 0

John Woo
John Woo

Reputation: 263903

You should create global hotkey.

Check this one

http://www.liensberger.it/web/blog/?p=207

Upvotes: 1

Related Questions