Can .NET app preview keys without focus?

  • Thread starter Thread starter Dave Leach
  • Start date Start date
D

Dave Leach

I want my application to see a particular key press event
whether it has focus or not. I want to display a dialog
form when a "hot key" like Shift-Ctrl-5 is entered from
the keyboard.

Is there a way to do this?

Thanks,
Dave
 
Hi Dave,
Thanks for your post!
As I know, .NET Framework didn't provide this feature, however, you may try
using the "global hot key" by PInvoking some APIs. The API you need is
RegisterHotKey/UnregisterHotKey, you also need handle the WM_HOTKEY message
by overriding the WndProc. The PInvoke declarations are:
<code>
[DllImport("user32.dll")]
public static extern int RegisterHotKey(int hwnd,int id,int
fsModifiers,int vk);

[DllImport("user32.dll")]
public static extern int UnregisterHotKey(int hwnd,int id);

</code>

Also, here is an article on how to use global hot key in an unmanaged
application, I hope it is helpful to you.

http://www.codeproject.com/system/nishhotkeys01.asp?print=true

Does it answer your question?
If you have any problem on this issue, please be free to reply to the group.
Thanks!


Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!
 
Hi Dave,
You haven't updated this issue for days, Does this work around solve you
problem?
If you still have problem on this problem , please be free to let me know.

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!
 
Back
Top