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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With