none
Hotkeys On Other Windows RRS feed

  • Question

  • Hello,

    I could not really find a good thread name, but I think by describing my issue, I can make up for that.

    The problem with hotkeys is that if I press for example the button "G", while I am on my program, the button performs the action, which is good. If I am one another window, let us say Microsoft Edge, and I am pressing the button "G", the action is not performed on my windows form.

    Basically, I am looking for a code that when I press the button G (or F, or RSHIFT, it does not matter; just one unequivocal key), in any form (not in Form1.vb) it does something in Form1.vb.

    Thank you very much, and I hope this is clear enough to understand.

    Jakob

    Saturday, July 21, 2018 11:20 PM

All replies

  • Hi

    Have you considered the effect when the 'other window already uses Hotkeys for its own purposes?


    Regards Les, Livingston, Scotland

    Saturday, July 21, 2018 11:36 PM
  • Hello,

    Well, then so it should be. What I want to do is that when the actual form is not open, the hotkey still triggers an event. If another application already uses the key "G" for example, then it just toggles my event, and then the one from the application itself.

    To be honest, your answer is more of a side-effect answer rather than what seek.

    Anyways, thank you for your answer.

    Saturday, July 21, 2018 11:54 PM
  • RegisterHotKey works even if your window has not the focus

    (you can also use a WH_KEYBOARD_LL hook)

    Sunday, July 22, 2018 8:21 AM
  • Hi

    I think we can override the ProcessCmdKey(ref Message msg, Keys keyData) method of the Form base class.

    Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean
            If keyData = Keys.D Then
                MessageBox.Show("123")
            End If
            Return True
        End Function

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, July 23, 2018 6:33 AM