【发布时间】:2017-10-04 08:24:51
【问题描述】:
我遇到以下问题,我想模拟从 c# 到应用程序的按键,我尝试使用 sendkeys、inputsimulator 和拦截。我的问题是如何处理这个问题?我知道 sendkeys 是一个非常小的类,但我希望它能在这种情况下发挥作用,
Process p = Process.GetProcessesByName("condor").FirstOrDefault();
if (p != null)
{
IntPtr h = p.MainWindowHandle;
SetForegroundWindow(h);
SendKeys.Send("k");
}
这给了我错误:
SendKeys cannot run inside this application because the application is not handling Windows messages. Either change the application to handle messages, or use the SendKeys.SendWait method
我的问题是如何模拟无形应用的按键操作?
【问题讨论】:
-
"或使用 SendKeys.SendWait 方法"
-
不能解决问题,幸好我没那么傻。。
-
这是 Windows 应用程序还是控制台应用程序?无形?
-
它是一个 windows 窗体应用程序,试图使用 sendkeys 到另一个应用程序
-
您似乎正在尝试从一台电脑访问另一台电脑?