views:

169

answers:

2

I'm making a little application for taking notes. So when I type 'note' anywhere on my computer, my window will pop up and show me a textbox for me to type something in and save it to XML.

I'm stumped on how to get the program to 'listen' to my keypresses. I'll have the app running on the system tray if that's any help. :)

A: 

I'm not sure about being able to hook a series of key strokes (and tying it down to typing "note" may trigger the functionality when it's not wanted), but I have implemented similar functionality for a WinForms application using "hot keys". Hot keys are a windows (Win32) concept and can allow certain key combinations to be routed to a window e.g. WinKey+A. You can use the Win32 functions RegisterHotKey and UnregisterHotKey with some P/Invoke to get the desired results. The following has an example of using RegisterHotKey from C#:

http://www.pinvoke.net/default.aspx/user32/registerhotkey.html

chibacity