I have tried hard to find a C/C++ library to simulate mouse events in Linux, but cannot find one. Can someone suggest an easy library for the same?
-
It depends if you are thinking of some X11 based desktop application or not.Basile Starynkevitch– Basile Starynkevitch2013年11月08日 16:51:05 +00:00Commented Nov 8, 2013 at 16:51
1 Answer 1
There are two methods:
You can generate "synthetic" events
The mouse buttons are handled very similar to keys on the keyboard, so it should be simple to adapt this code. Note that applications can find out about this by looking at the
IsSyntheticfield in the event. Xterm for example ignores synthetic events for security reasons.You can use the XTEST extension.
This allows sending events with
IsSyntheticset toFalse, and hence full simulation, but the extension is normally disabled or restricted.