Grabbing Special Key Combos


Jun 8, 2004
Programming Experience
okay, I'm writing a program that I want to sit over the desktop area of windows. Kind of a replacment. What I'm trying to work out is, is it possible to grab special windows key combos like Start+D to goto desktop??

I know you can grab normal keys and Ctrl+D type keys, but how can you grab Start+D type keys, if at all??

Regards, Raven
I wrote a browser that hides when it looses focus and becomes visible when a special key combination is pressed (Winkey+G for examaple. The Start key is often called the Windows Key or WinKey). It uses API calls to hook into the keyBoard so it can capture keys without having to have a form with focus.

Attached is the class I use. It needs a little work.

Let me know if you need help using it, if this is what you want.


    1.6 KB · Views: 153
To use it, first add it to your project (of course :)). Here's some sample code for the Winkey+D (Start+D):

Public WithEvents kh As New KeyboardHook()

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) _
  Handles MyBase.Load
    'this causes kh to send only keyups (or downs) for the D key
End Sub

Private Sub kh_KeyUp(ByVal P As PopUpBrowser.KeyboardHook.KBDLLHOOKSTRUCT) _
  Handles kh.KeyUp
    If kh.WinKey Then
        'show the replacement desktop
    End If
End Sub

Private Sub Form1_Closing(ByVal sender As Object, _
 ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
End Sub
The combo WinKey+D (in Windows XP at least) also shows the desktop and minimizes all windows. Doing the above won't stop that, but will only add to it. I'm not sure how to overcome that.
Ummm.. Sory if I'm just being blind or something, but SetFocus doesn't seem to appear anywhere in VB.NET... There's form.focus(), but I think that's only for multiple form apps, not when the whole thing's not in focus.