将按键发送到另一个应用程序/窗口 [英] Sending keypresses to another app/window

查看:85
本文介绍了将按键发送到另一个应用程序/窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序使用以下代码将按键发送到另一个应用程序窗口:

I have an application which sends keypresses to another application window using this code:

ADR_Library.DataAccess.Win32Imports.SetForegroundWindow(handle);
System.Windows.Forms.SendKeys.SendWait(item.Key);
System.Windows.Forms.SendKeys.Flush();
System.Threading.Thread.Sleep(1000);





这个工作正常,但在上周它已停止工作。该程序的旧版本也已停止工作。我知道代码找到了另一个窗口的正确句柄,但数据没有出现在目标窗口中。为什么?这适用于其他一些PC,但不再是我的。



这听起来像某种Windows权限问题,好像Windows Update可能改变了一些东西。



我尝试过:



在管理员帐户下运行我的应用程序无法解决问题。



This was working fine but in the last week it has stopped working. An older release of the programme has stopped working too. I know that the code finds the correct 'handle' for the other window, but the data does not appear in the destination window. Why? This works on some other PCs, but not mine anymore.

This sounds to me like some sort of Windows permissions issue, as if a Windows Update has perhaps changed something.

What I have tried:

Running my application under the Admin account does not solve the problem.

推荐答案

好的,问题似乎是由测试字符串中的第一个字符引起窗口失去焦点引起的......
Okay, the problem seems to have been caused by the first characters in the test string causing the window to lose focus ...


这篇关于将按键发送到另一个应用程序/窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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