I am working on Hand Gesture Recognition System and I want to generate keystrokes for any application using gestures as input. But i am not getting any idea that how can i make this work on both Linux and Windows platform, as keybd_event is there for Windows but it doesn't work on Linux.
Please help me out !! :-/ :?:

Recommended Answers

All 9 Replies

Since Linux and Windows are two different systems, they do things differently. You're going to have to learn the Linux version of all the Windows functions you're using.

Please tell me the function like keybd_event which can be used in Linux
or is there any function in QT which can work on both Linux and Windows ??

Please tell me the function like keybd_event which can be used in Linux
or is there any function in QT which can work on both Linux and Windows ??

How did you find keybd_event? Someone told you about it, I assume. Otherwise you'd know how to do your own research.

I got it. XTestFakeKeyEvent() is the function in Linux.
Thanks for the reply :)

fyi, if you know some Java you can use the Robot class, which can simulate Keyboard events and even Mouse events in a cross-platform way.

Cheers, xfbs

Thanks xfbs, i know Java but i am looking it for C++.
Is there any way in C++ ??

I'm not aware of any cross-platform way to do it in C++, which is why I recommended that Java class (Robot). When I tried to simulate keyboard input on OSX I had to resort to AppleScript :/.
Anyway, I found this link, it's some sample code that generates one key press event and one key release event and sends them to the window that currently has the focus. It doesn't work OSX's X11 server, but it should work on Linux.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.