0

If there's any way to simulate a real mouse click (press + release) at the absolute position of current desktop with PyQt, without other extenal library like PyUserInput?

I search around and just found this and this. But If I don't misunderstand, they seem to send their click event to Qt application it self, instead of the desktop?

Community
  • 1
  • 1
kuanyui
  • 782
  • 13
  • 23
  • 1
    Yes, It's generate event in Qt by self not desktop. In Qt (C++) have all event your can see in 'QWidget' reference class. But you want to create UI unit-test, It will OK to "dummy" this event. – Bandhit Suksiri Aug 17 '14 at 10:46

1 Answers1

0

Use PyQt's QTest, together with unittest or such. See also for example http://www.voom.net/pyqt-qtest-example.

If this is not for unit testing, look at sendEvent and postEvent (See http://doc.qt.digia.com/qq/qq11-events.html#syntheticevents). There are some limitations to Qt's mechanism for generating "artificial" events but based on what you describe, it is likely to work. If you have tried those and it doesn't work, please post the code you tried.

Oliver
  • 27,510
  • 9
  • 72
  • 103
  • I'm not doing unit test. and the most important is that it also seems to click on a QWidget instead of desktop. – kuanyui Aug 20 '14 at 07:13