简体   繁体   中英

X11 and fake keyboard / mouse events

I want to know as to how do you detect if a key press event or a mouse pointer event has been generated by an (automation like) application like xdotool. Basically, I am writing an application to check if there is no real mouse or keyboard activity. In my application I want to flag idle activity only if we don't have real mouse movement or real key press/release on the keyboard. Any reference regarding this would be great. I want to do this using pure xlib API. Don't want to use XCB. Any extensions such XRecord(which I am currently using to capture events) are fine.

Thanks in advance.

Yes there is a possibility.

All X11-events which are relevant for mouse movements and clicks have a member called "send_event". It is set to "True" if the event was sent by an application. It is "False" if it was generated by the X-Server, ie by a user action.

If xdotool uses SendEvent for mousclick simulation than you'll be able to detect that using the "send_event" member.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM