Key-key and keyboard shortcuts with Qt 4.6

Say I have a windowless application that has only a taskbar icon (Windows, Mac OS X and Linux). I want him to fix some key combinations and keys, for example, Right Control + Right Shift. After entering the correct combination, he will do something, say, a screenshot. I can make a windowless application, a taskbar icon and screen capture, but I don’t know how to control the keyboard globally for keyboard shortcuts. I ask you to advise. Any help or hint is greatly appreciated! Thanks in advance!

+3
source share
1 answer

System-wide system capture is a complex issue, but system-wide key capture is even more complex. Each OS / GUI has its own solution, at least for capture. Qt4 does not disclose such a function, but the Qt eXTension library solves the problem with its QxtGlobalShortcut . This is a good wrapper for:

This way you can capture an explicit key combination, i.e. a specific key and modifiers (XGrabKey () allows a little more) that no other application will receive. Key sequences, that is, sequential key combinations, are not supported here.


Keyboard capture is much more efficient because it allows you to look at input events (or even filter them). It is not only used by keyboard recorders, but is also a typical association.

If you are on Windows, you can read:

In X11, this is much more complicated. There are at least two pages that you can read:

There was an X event interception extension , but it was not supported and was ultimately removed.

Hope this can be done without the help of the X11 infrastructure. The Linux 2.6 kernel has an “Event Interface” known as evdev , which can be used here. Details can be found in the source code of the logkeys Linux keylogger . This can also be done with something similar to evdev. See My PoC project: kaos - Key Activity Screen.

And I don't have a Mac, so no further links .;)

+8
source

Source: https://habr.com/ru/post/1390040/


All Articles