如何preSS Windows按钮编程方式使用C#的SendKeys [英] How to press the Windows button programmatically using C# SendKeys

查看:216
本文介绍了如何preSS Windows按钮编程方式使用C#的SendKeys的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上我想在$ C $模拟C对Windows按钮用户点击。我知道有一个的SendKeys,让我送钥匙presses到Windows,如果我得到一个处理他们,但我想不出是我需要得到以发送的Windows按钮命令的处理。例如。 windows键+ L。看了这个有点看来,CTRL-ESC应弹出开始菜单也但不知道如何告诉它的按键发送到Windows(如果这甚至有可能)。任何帮助将是非常美联社preciated。

Basically I want to simulate in code a user clicking on the windows button. I know there is SendKeys which allows me to send key presses to windows if I get a handle to them, but what I can't figure out is what I need to get a handle on in order to send Windows button commands. E.g. Windows Button + L. Having read into this a bit it appears that CTRL-ESC should pop up the Start Menu also but not sure how to tell it to send the keys to Windows (if this is even possible). Any help would be much appreciated.

干杯!

推荐答案

我不认为你可以做到这一点使用的SendKeys,您将需要的P / Invoke给API函数来代替,大概的 keybd_event 来发送CTRL + ESC或Windows键。

I don't think you can do this using SendKeys, you will need to p/invoke to an API function instead, probably keybd_event to send either CTRL+ESC or the Windows key.

这里是打开开始菜单中的一个例子在VB方式这里是keybd_event上的PInvoke它的C#签名。净。

Here is an example of opening the start menu this way in VB and here is keybd_event with its C# signature on pinvoke.net.

这篇关于如何preSS Windows按钮编程方式使用C#的SendKeys的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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