使用Qt模拟/伪造鼠标单击和鼠标滚轮 [英] Mimicking/faking a Mouse Click and Mouse Wheel using Qt

查看:1059
本文介绍了使用Qt模拟/伪造鼠标单击和鼠标滚轮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Qt模拟/伪造鼠标单击和鼠标滚轮?更具体地说,我想在Qt应用程序的内部和外部单击.预先感谢!

How to mimic/fake a Mouse Click and Mouse Wheel using Qt? To be more specific, I want to click inside and outside the Qt application. Thanks in advance!

推荐答案

如果要模拟对应用程序内部的单击,请签出

If you want to simulate clicks on widgets inside your application, check out QTestEventList:

可以用GUI事件填充QTestEventList,这些GUI事件可以存储为测试数据以供以后使用,也可以在任何QWidget上重播.

A QTestEventList can be populated with GUI events that can be stored as test data for later usage, or be replayed on any QWidget.

它使您可以执行按键和各种鼠标事件,但无需滚轮.无论如何,源代码应提供有关此类操作的最佳实践的线索:

It lets you perform keypresses and various mouse events, but no wheel. Regardless, the source code should give cues on best practices for this sort of operation:

http://qt.gitorious.org /qt/qt/blobs/master/src/testlib/qtestmouse.h

http://qt.gitorious.org /qt/qt/blobs/master/src/testlib/qtestevent.h

OTOH,如果您是想模拟应用程序外部的点击(例如桌面上的图标等),则可能超出了Qt API的范围.要在Windows上完全控制鼠标",有一个相关问题:

OTOH, if you mean you want to simulate clicks outside your application (like icons on the desktop etc.) that's probably beyond the scope of the Qt API. To "take complete control over the mouse" on Windows there's this related question:

模拟Windows中的鼠标按钮

...,而可以考虑使用专门为此任务设计的自动化工具.某些选项包括Windows Auto It!,Mac的 iMacros .您甚至可以从Qt调用 QProcess 这样的工具.

...and might instead consider using an automation tool specifically designed for this task. Some options are the Windows Auto It!, the Mac's Automator, and the Web-based iMacros. You could even invoke such a tool from Qt as a QProcess.

这篇关于使用Qt模拟/伪造鼠标单击和鼠标滚轮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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