Unsolved Catching mouse/key events outside the application
-
Hi,
I need to catch system events outside an app like hooking keyboard presses and mouse events. I thought I could use the classes QMouseEvent and QKeyEvent as they are delivering events from the Windows system but It did not work.. Also tried to use the library named "LibQxt" but as the library does not have support for 5.5.1 MSVC 2013, I cannot use it for my app.
Another thing is, I want to have this application cross platform :) What do you suggest me to do?
Regards
-
You could try this QPoint QCursor::pos().
-
http://doc.qt.io/qt-5/qwidget.html#grabKeyboard
http://doc.qt.io/qt-5/qwidget.html#grabMouseBut be careful with those, you might end up making your system pretty unusable if you fail to release the mouse and keyboard input.
-
Hi,
What is your goal catching keyboard and mouse outside from your application ?
-
Hi. I'll add this capability to a widget object to be used in another Qt based software.
Thank you for your replies.
-
Sounds like you should rather provide some sort of IPC mechanism between these two applications, no ?
-
Sadly no, not exactly. I'm in need of developing this as a widget object for a SCADA software. The widget object needs to get mouse and keyboard events from the system during the runtime of SCADA so the end user can reach the out of scope values/events like cursor position or key pressed etc... Some kind of IPC mechanism is also possible to be implemented for the situation maybe but I'm trying to develop the widget for the end user. So only the "event handling" part of widget better be accessed over GUI by the end user.
When I use grabMouse(), do I need to install another eventFilter to the mouse object so it can work like a call back when cursor position is changed in out of scope?
-
@kshegunov said in Catching mouse/key events outside the application:
http://doc.qt.io/qt-5/qwidget.html#grabKeyboard
http://doc.qt.io/qt-5/qwidget.html#grabMouseBut be careful with those, you might end up making your system pretty unusable if you fail to release the mouse and keyboard input.
How can I get the mouse events after grabbing? Do I need to install another filter for it? After grabbing it still does not grab mouse move events outside the widget window.
-
AFAIK, the grabbing will only occur as long as you're on your application widget which as the grab mouse/keyboard activated otherwise it would mean that your application is spying on the mouse/keyboard while not being the active one.