Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mimicking/faking a Mouse Click and Mouse Wheel using 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!

like image 247
Viet Avatar asked Jan 05 '10 04:01

Viet


1 Answers

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

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, 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:

Simulating a mouse button click in Windows

...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.

like image 50
HostileFork says dont trust SE Avatar answered Nov 06 '22 00:11

HostileFork says dont trust SE