user2969663
user2969663

Reputation: 11

Simulate Mouse Events linux

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?

Upvotes: 1

Views: 1479

Answers (1)

Simon Richter
Simon Richter

Reputation: 29618

There are two methods:

  1. 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 IsSynthetic field in the event. Xterm for example ignores synthetic events for security reasons.

  2. You can use the XTEST extension.

    This allows sending events with IsSynthetic set to False, and hence full simulation, but the extension is normally disabled or restricted.

Upvotes: 3

Related Questions