2

I have a project that runs in the background in a different process, I want it to be able to react to keyboard everywhere, for example I run the project, and afterwards I do other stuff in the computer such as browsing, facebook, watching movies etc.., and every time I press F9 I want my project to show up. Same as how you press a combination of keys to invoke Babylon... I want to implement it in C#, I have no idea how to begin.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
Giora Ron Genender
  • 797
  • 1
  • 11
  • 21

2 Answers2

9

You can register a hotkey with the RegisterHotKey API function. You can see an example of its usage from C# here.

Matteo Italia
  • 123,740
  • 17
  • 206
  • 299
  • 1
    This is precisely what the Hotkey APIs were intended for. Though taking over F9 might be a bad idea if someone other than yourself is going to use this app. – Andrew Lambert Dec 13 '11 at 23:52
0

I think you need to write a system-wide keyboard hook, check here for details:

https://stackoverflow.com/a/1764434/559144

How do I grab events for all applications? An example system-wide hook.

Community
  • 1
  • 1
Davide Piras
  • 43,984
  • 10
  • 98
  • 147