我正在开发 VS 2010 Ultimate。我创建了一个大约 25-30 行的简单控制台应用程序。所以我想在 Main() 函数中简单地模拟在 while 循环中按“ALT+TAB”。哦,我可以这样做吗 - 我不能使用 SendKeys 类,因为它“提供了将击键发送到应用程序的方法”。我希望在启动控制台应用程序时模拟按“ALT+TAB”1000 次,而不将其附加到任何应用程序。像这样的事情:
using System; using System.Windows.Forms; namespace nagradite { class Program { static void Main() { int i = 1000; while( i > 0 ) { // PRESS "ALT+TAB" i--; } } } }
我应该输入什么而不是//按“ALT+TAB”
最佳答案
使用“%{TAB}”
表示Alt+TAB
SendKeys.Send("%{TAB}");
SendKeys.Send("%{TAB} 1000"); //if you want to do same by 1000 times as you stated
引用http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send.aspx
关于c# - 模拟按键 C# .Net,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4479042/