I'm trying to create a program which will work in the background and can be brought back to the topmost upon a keyboard shortcut. I got stuck when creating the multiple keypress statement, and not sure how to make the shortcut work when the form is not in focus.
Here's the shortcut I'm trying to make, but it won't work.

 Private Sub TakeDown_KeyDown(sender As Object, e As KeyEventArgs) Handles TakeDown.KeyDown
        If e.KeyCode = Keys.LWin And e.KeyCode = Keys.Z = True Then
            Me.BackColor = Color.Blue
        End If
    End Sub

The if I use only one key it will work, but not when using the code for pressing two keys at the same time.

Edited by Start4me: sense

3 Years
Discussion Span
Last Post by Reverend Jim

So it won't be possible to use Win key with Z?
When the program is not in focus (not TopMost), how will I make the shortcut above bring the program to front?


Yes you can - To have these keys raise the KeyDown event, you must override the IsInputKey method in each control on your form. Read the link.
Since your code calls it from the TextBox1_KeyDown event you need to call it from the form that has focus.


TakeDown_KeyDown is actually a button. I've looked at the code, but wasn't able to figure out how to

override the IsInputKey method in each control on your form


Instead of trying to build this into your program you might consider a program like Qliner Hotkeys. I've been using it for years. You can assign the program to a hotkey (like WINDOWS-F12) and when that hotkey is pressed, the program

  1. starts and comes to the front if it is not already running
  2. is brought to the front if it is already running
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.