User32 keybd事件-确保成功 [英] User32 keybd event - Ensuring Success

查看:144
本文介绍了User32 keybd事件-确保成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一劳永逸,

我编写了一个小应用程序,可以指定一个应用程序,然后将其发送键击或定向的鼠标单击.

我在user32.dll中使用keybd_eventmouse_event.现在我已经成功地使它起作用了,但是我知道在做这种事情并试图实现一致性时存在很多不确定性和陷阱.

我应该或可以采取任何措施来确保已发送消息的成功吗?我的意思是一个按键未注册可能会对应用程序的整体输出产生很大的影响.

欢迎任何提示或想法.

谢谢,

Jib.

Good day one and all,

I have written a small application that allows me to specify an application, and send it keystrokes or directed mouse-clicks.

I''m using keybd_event and mouse_event in the user32.dll. Now I''ve been successful in getting it working, however I understand that there are many uncertainties and pitfalls when doing this sort of thing and trying to achieve consistency.

Are there any measures I should or can take to ensure the success of the sent messages? I mean one key stroke not registering could make a big difference to the whole output of the app.

Any tips or ideas are welcome.

Thanks,

Jib.

推荐答案

您真正要做的就是检查以确保目标应用程序a)仍在运行,b)仍在响应".任务管理器检查应用程序是否正在运行的方式是,它使用SendMessageTimeoutWM_GETICON消息发送到应用程序窗口并等待返回值.如果5秒钟内未收到一则,则认为该应用程序无响应".

All you can really do is check to make sure the target app is a) still running, and b) is still "responding". The way Task Manager checks to see if an app is running is that it uses SendMessageTimeout to send a WM_GETICON message to the app window and waits for a return value. If it doesn''t get one within 5 seconds, it assumes the app is "Not Responding".


这篇关于User32 keybd事件-确保成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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