C ++ (Qt) cross-platform library for simulating keyboard input, sendkeys, sending kestrokes, etc.

Does anyone know a true cross-platform C ++ library for simulating keyboard input?

I would do a goover plus stackoverflow study, but find neither a Qt-based nor a common C ++ library for Windows, Linux / X11, and Mac OS X.

Only some code fragments are available, for example:

Window:

  • There are several examples of how to do this using the keybd_event function.

Linux:

Mac OS X

So the question is, did I miss something? Is there a cross-platform C ++ library in this world to simulate keyboard input?

PS: When I wrote this question, the site offers in the section "Similar questions" a cool idea - to explore in free game engines. Indeed, there are many open-source cross-platform engines that have keyboard input modules. Thus, even they do not have keyboard emulation, they have a good starting point for developing such a library.

UPDATE 1: it's not quiet fun that FreePascal / Lazarus already has such a library. Nice to see that the library architecture: http://wiki.lazarus.freepascal.org/MouseAndKeyInput

+4
source share
1 answer

You could achieve this with Qt, but not in a real platform independently. With Qt, you have two ways:

  • Use the Qt methods keyClick (), keyPress (), ... to simulate the corresponding events. But note that this only works for your own program, and not for other processes.
  • Use the winEvent (), x11Event (), and macEvent () events and fire platform-specific messages. These messages are not reflected in Qt and must be surrounded by #ifdef ... #endif to make the source compiler on all platforms.
+2
source

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


All Articles