发送使用的SendKeys Windows键 [英] Sending Windows key using SendKeys

查看:1888
本文介绍了发送使用的SendKeys Windows键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作在C#中的快捷方式。我成功实施按Ctrl,Alt键和Shift键的SendKeys

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

筛选;

<大骨节病>控制 + <大骨节病> C

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

或<大骨节病>替代 + <大骨节病> F4

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

但我不能用的SendKeys发送Windows键。我试过例如:<大骨节病>赢 + <大骨节病>电子 .SendWait(#E),但它不工作。我应该使用,而不是#是什么?

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 "#"?

感谢。

推荐答案

OK原来你真正想要的是这样的: HTTP:/ /inputsimulator.$c$cplex.com/

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

这方面做揭 Win32的SendInput 方法,以C#中所有的辛勤工作。这使您可以直接发送Windows键。这是测试和工程:

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(VirtualKey code.LWIN,VirtualKey code.VK_E);

注意然而,在某些情况下,你要专门派的关键应用程序(如 ALT + F4 ),在这种情况下,使用表格库的方法。在其他情况下,你要发送到一般的操作系统,使用以上。

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.

牢记这这里的参考,它不会在所有的操作系​​统上运行,并不会总是表现你怎么想。请注意,你要这些击键发送到应用程序,操作系统通常早期拦截他们。在Windows 7和Vista的情况下,过早(即电子之前发送)。

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))发送(^({ESC} E))

从这里注意:<一href=\"http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx\">http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx

要指定SHIFT,CTRL和ALT的任意组合,应举行
  倒边等几个键是pressed,附上code对于那些
  键在括号中。例如,要指定按住SHIFT的同时
  E和C是pressed,用+(EC)。要指定按住SHIFT的同时
  E是pssed $ P $,接着为C无移位,可用+ EC。

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".

请注意,既然你想 ESC 键,(说)电子 pressed在同一时间,你需要它们放在括号中。

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

这篇关于发送使用的SendKeys Windows键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆