0

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!

Anti Earth
  • 4,671
  • 13
  • 52
  • 83
  • The usual trick is opening a full screen frameless transparent always-on-top window and capturing mouse events with that. But it doesn't work on all Linux platforms. So it's not completely cross-platform. – Avaris Oct 31 '12 at 08:15
  • Yes, I remember doing something similar in another program. I called it the 'tarp'. However, I need to allow the mouseclicks to be registered in another application as well, so I can't block the input. (I could switch off the tarp momentarily and replicate the click but that seems a convoluted and unnecessary method) Thanks for the suggestion though! – Anti Earth Nov 01 '12 at 00:45

2 Answers2

3

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

synthesizerpatel
  • 27,321
  • 5
  • 74
  • 91
0

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

Anti Earth
  • 4,671
  • 13
  • 52
  • 83
  • Could you please elaborate on how you are "letting Qt pump the messages"? I am trying to implement something nearly identical but I am unsure about how to pump messages for pyHook using PyQt. – TerryTate Jan 18 '13 at 16:23
  • 1
    Sorry,I no longer have the code for this (and don't even remember what I was talking about) – Anti Earth Jan 18 '13 at 21:11