sendkeys安装包_发送使用的SendKeys Windows键

在C#中实现快捷键时,使用SendKeys.SendWait发送Ctrl、Alt和Shift键已经成功,但无法发送Windows键。解决方案是使用InputSimulator库,它提供了SendInput方法来直接发送Windows键,例如InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_E)。" 125855407,12780510,静电防护:AMAZINGIC晶焱科技的TVS解决方案,"['半导体技术', '电子工程', '静电放电', '保护元件', '电路设计']

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I am working on shortcuts in C#. I succeed implementing Ctrl, Alt and Shift with SendKeys.

Like this;

Ctrl + C:

System.Windows.Forms.SendKeys.SendWait("^c");

or Alt + F4:

System.Windows.Forms.SendKeys.SendWait("%{F4}");

But I can't send "Windows Key" with SendKeys. I tried ex: Win + E : .SendWait("#e") but it's not working. What should I use instead of "#"?

Thanks.

解决方案

OK turns out what you really want is this: http://inputsimulator.codeplex.com/

Which has done all the hard work of exposing the Win32 SendInput methods to C#. This allows you to directly send the windows key. This is tested and works:

InputSimulator.SimulateModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_E);

Note however that in some cases you want to specifically send the key to the application (such as ALT+F4), in which case use the Form library method. In others, you want to send it to the OS in general, use the above.

Old

Keeping this here for reference, it will not work in all operating systems, and will not always behave how you want. Note that you're trying to send these key strokes to the app, and the OS usually intercepts them early. In the case of Windows 7 and Vista, too early (before the E is sent).

SendWait("^({ESC}E)") or Send("^({ESC}E)")

To specify that any combination of SHIFT, CTRL, and ALT should be held

down while several other keys are pressed, enclose the code for those

keys in parentheses. For example, to specify to hold down SHIFT while

E and C are pressed, use "+(EC)". To specify to hold down SHIFT while

E is pressed, followed by C without SHIFT, use "+EC".

Note that since you want ESC and (say) E pressed at the same time, you need to enclose them in brackets.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值