1

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.

Fischermaen
  • 12,238
  • 2
  • 39
  • 56
h_a86
  • 772
  • 6
  • 14
  • 24
  • 1
    As the event handler is for [Winforms KeyDown](http://msdn.microsoft.com/en-us/library/system.windows.forms.control.keydown.aspx) event, it is applicable only when the form is active. For keylogger application, refer [app in background read keys pressed by user](http://stackoverflow.com/questions/2292232/app-in-background-read-keys-pressed-by-user) – Devendra D. Chavan Jan 05 '12 at 07:57
  • You can also take a look at: http://stackoverflow.com/questions/1983148/setwindowshookex-global-keyboard-hook-not-catching-all-keypresses – Qorbani Jan 05 '12 at 08:01

3 Answers3

1

You should create global hotkey.

Check this one

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

John Woo
  • 258,903
  • 69
  • 498
  • 492
0

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.

Shai
  • 25,159
  • 9
  • 44
  • 67
0

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

Ashkan Mobayen Khiabani
  • 33,575
  • 33
  • 102
  • 171