Imitation / pretense of a mouse and mouse wheel using Qt

How to simulate / fake a mouse and mouse using Qt? To be more specific, I want to click inside and outside of a Qt application. Thanks in advance!

+6
qt mouse mouseevent
source share
1 answer

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

A QTestEventList can be populated with GUI events that can be saved as test data for later use or played back on any QWidget.

It allows you to perform keystrokes and various mouse events, but not the wheel. Regardless, the source code should provide recommendations on best practices for this kind 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 want you to simulate clicks outside your application (e.g. desktop icons, etc.) that are likely beyond the scope of the Qt API. To β€œtake full control of the mouse” on Windows, this related question:

Windows mouse click simulation

... and instead, you can use an automation tool specifically designed for this task. Some options: Windows Auto It! , Mac Automator, and the iMacros website. You can even call a tool from Qt like QProcess .

+7
source share

All Articles