如何在 vb.net 中发送 Lwin 快捷键 [英] How send Lwin shortcut key in vb.net
问题描述
谁能告诉我如何在 vb.net 中发送快捷键?快捷键是 {LEFTWIN} + {ADD} 和 {LEFTWIN} + {SUBTRACT}.试过 SendKeys.发送它不起作用.
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.
推荐答案
无法通过 SendKeys.Send()
发送 LWin
.为此,您必须 P/Invoke WinAPI 的 SendInput()
函数.
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:
编辑 (2019-09-20)
InputHelper
早已被移到它自己的库中.答案已更新以反映此更改.
InputHelper
has since long been moved to its own library. The answer has been updated to reflect this change.
从 GitHub 下载 InputHelper:
https://github.com/Visual-Vincent/InputHelper/releases
您将如何使用它:
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.
这篇关于如何在 vb.net 中发送 Lwin 快捷键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!