How send Lwin shortcut key in vb.net

前端 未结 3 1755
北荒
北荒 2020-12-07 06:15

Can someone tell mew how to send Shortcut keys in vb.net? The shortcut keys are {LEFTWIN} + {ADD} amd {LEFTWIN} + {SUBTRACT}. Tried SendKeys.Send it does not work.

3条回答
  •  忘掉有多难
    2020-12-07 07:01

    Sending LWin is not possible through SendKeys.Send(). In order to do so you have to P/Invoke the WinAPI's SendInput() function.

    Here's a wrapper class I've created for that purpose:

    EDIT (2019-09-20)

    InputHelper has since long been moved to its own library. The answer has been updated to reflect this change.

    Download InputHelper from GitHub:
    https://github.com/Visual-Vincent/InputHelper/releases

    Here's how you'd use it:

    InputHelper.Keyboard.SetKeyState(Keys.LWin, True) 'Hold LWin.
    InputHelper.Keyboard.PressKey(Keys.Add) 'Press the ADD key.
    InputHelper.Keyboard.SetKeyState(Keys.LWin, False) 'Release LWin.
    

提交回复
热议问题