Anti Earth
Anti Earth

Reputation: 4809

PyQt4 - detect global mouse click

A part of a small project I am working on involves 'calibrating' the coordinates of the screen of which to take a screen capture of.
By the 'screen', I refer to the entire desktop, not my GUI window.

The coordinates are calibrated when a QDialog window appears (which I've subclassed).
The user is prompted to click several locations on the screen.
I need the program to record the locations of all mouse clicks occuring anywhere on the screen - ones that don't natively trigger a QDialog mouseEvent, since they are outside this window.

Obviously overwriting the mouseEvent method does not work, since the QDialog doesn't recieve the clicks.

How can I capture global mouse clicks, so that an event is triggered and sent to the QDialog when any part of the screen is clicked?

(I'd prefer a Qt based solution, but am open to other libraries if need be).

Thanks!

Upvotes: 0

Views: 2279

Answers (2)

synthesizerpatel
synthesizerpatel

Reputation: 28056

There are some cross-platform examples of how to do this with http://pypi.python.org/pypi/autopy/0.51

Upvotes: 3

Anti Earth
Anti Earth

Reputation: 4809

I've assumed this isn't possible and am instead using pyHook, letting Qt pump the messages.

Upvotes: 0

Related Questions