I’m writing a linux application using C++ and wxWidgets.
From my application, I need to send keyboard events to the window that currently has the focus (not belonging to my application!).
My questions are:
- How can I find out what window has the focus?
- How can I send a keyboard event to a window not belonging to my application?
Thanks
Daniele
XGetInputFocus(3).Windowis the Xlib data type). Use whatever method of sending events works. There are two methods I know of:XSendEvent(3)andXTestFakeKeyEvent(3). The former method does not work with some programs that chose to ignore events coming fromXSendEvent. The latter one requires theXTestextension, which is present in most, but not all, modern servers.InputFocusis a valid window designator forXSendEvent, andXTestFakeKeyEventis delivered to the window that has the focus anyway, so you probably don’t need to callXGetInputFocusat all.