Background Process and Keypress

  • Thread starter Thread starter Joshua Campbell
  • Start date Start date
J

Joshua Campbell

I am wanting to write a program that will run in the background, but will
intercept a keypress (<CTRL> + <ALT> + L) and do a certain action.
Unfortunately, the only way that I've been able to accomplish this is if the
program is the active window. Is there a way to have this running as a
background process, yet still able to intercept keypresses?

Thanks.
Joshua
 
This is only possible with a global hook (SetWindowsHookEx), and is not
possible in either VB.Net or in C#.

But note that you would not want it to work, as the notion of injecting a
managed app into every process is a frightening one, to say the least.
 
True. Oh well. Thanks.



Michael (michka) Kaplan said:
This is only possible with a global hook (SetWindowsHookEx), and is not
possible in either VB.Net or in C#.

But note that you would not want it to work, as the notion of injecting a
managed app into every process is a frightening one, to say the least.


--
MichKa [MS]

This posting is provided "AS IS" with
no warranties, and confers no rights.


Joshua Campbell said:
I am wanting to write a program that will run in the background, but will
intercept a keypress (<CTRL> + <ALT> + L) and do a certain action.
Unfortunately, the only way that I've been able to accomplish this is if the
program is the active window. Is there a way to have this running as a
background process, yet still able to intercept keypresses?

Thanks.
Joshua
 
Hi Joshua,

Getting global access to the keyboard is easy when you follow the
footsteps of a Master.

The Master in question is Paul Kimmel, author of Visual Basic .NET
Unleashed, and he has written a three-part article explaining the whats and
hows of trapping the keyboard using SetWindowsHookEx:

http://www.developer.com/net/net/article.php/11087_2193301_1

Have fun. :-)

Regards,
Fergus
 
Back
Top