使用Qt模拟/伪造鼠标单击和鼠标滚轮 [英] Mimicking/faking a Mouse Click and Mouse Wheel using 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 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屋!