SendKeys.SendWait不发送" {ENTER}"在Windows 7 [英] SendKeys.SendWait does not send "{ENTER}" in Windows 7

查看:668
本文介绍了SendKeys.SendWait不发送" {ENTER}"在Windows 7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经试过这在Visual Studio 2008与XP和Windows 7:

I have tried this in Visual Studio 2008 with XP and Windows 7:

SendKeys.SendWait(sometext {ENTER} {} ENTER)

这是在打开文件对话框中打开一个文件。它适用于XP与VS2008,但是当我尝试在Windows 7上,似乎{ENTER}键没有经历。

This is for opening a file in an open file dialog box. It works on XP with VS2008, but when I try on Windows 7, it seems that the {ENTER} keys are not going through.

有一个已知的问题与此,还是我做错了什么?

Is there a known issue with this, or am I doing something wrong?

推荐答案

这应该工作,你可以尝试使用\ N作为得好:

this should work, you can try using \n as well:

System.Windows.Forms.SendKeys.SendWait("Hello World{ENTER}Testing\n");

这并不在我的Windows 7机器的工作。你遇到的问题是最有可能与你正在试图发送密钥的应用程序是在一个不同的特权帐户下运行(如:以管理员身份)。这将prevent用户级应用程序发送键,除非你运行你的应用程序作为管理员,以及。尝试运行Visual Studio作为管理员,并再次测试你的code。

This does work on my windows 7 machine. The problem you're having is most likely with the application you're attempting to send the keys to is running under a different privileged account (eg: as Administrator). This will prevent a user level application from sending the keys, unless you run your application as an Administrator as well. Try running Visual Studio as Administrator and testing your code again.

Right click Visual Studio -> Run As Administrator

这篇关于SendKeys.SendWait不发送" {ENTER}"在Windows 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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