handling key events

  • Thread starter Thread starter Roman Ma¹ek
  • Start date Start date
R

Roman Ma¹ek

hi,

does anybody know, how to handle keyboard events on system level (i need to
be able to do some action, when keyboard shortcut is pressed, even if my
application isn't active),

thanks for replies (sorry for my english, i'm working on it)
 
Roman said:
does anybody know, how to handle keyboard events on system level (i

system-level = device-driver !?
need to be able to do some action, when keyboard shortcut is pressed,
even if my application isn't active),

Use "SetWindowsHookEx"

For more info see:
HOW TO: Set a Windows Hook in Visual C# .NET
http://support.microsoft.com/?kbid=318804

--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp


Do you need daily reports from your server ?
http://sourceforge.net/projects/srvreport/
 
Jochen said:
Use "SetWindowsHookEx"

For more info see:
HOW TO: Set a Windows Hook in Visual C# .NET
http://support.microsoft.com/?kbid=318804

I forgot to mention:
System-Wide hooks are not supported in C#. You have to use C/C++

See:
http://www.pinvoke.net/default.aspx/user32.SetWindowsHookEx


--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp


Do you need daily reports from your server ?
http://sourceforge.net/projects/srvreport/
 
Hi Jochen,
I forgot to mention:
System-Wide hooks are not supported in C#. You have to use C/C++

This is true and is not true at the same time.
Maybe all programmers tried to implement windows hooks end up reading this
Global Hook Is Not Supported in .NET Framework
in the MS KB. Yes this is true. Global hooks are not supported beacuse of
the way they work. However there 2 exceptions of that and MS should've
mentioned them
The exceptions are: WH_MOUSE_LL and WH_KEYBOARD_LL. They are different from
the other global hooks because of the following statement:
MSDN:
"However, the WH_KEYBOARD_LL / WH_MOUSE_LL hook is not injected into another
process"

As far as I understand Roman needs WH_KEYBOARD_LL and this is possible to be
written in C#. Ofcourse PInvoke has to be used for calling SetWindowsHookEx
API.

How to do it I don't have an example nor link about it right now. But such
examples are all over the net. Just poll google and there are tons of
examples, I believe.
 
Back
Top