How to send key event to application using XCB?

后端 未结 1 2058
一整个雨季
一整个雨季 2021-02-13 19:47

How can I send a key press or key release event to a window (the currently active window) from another program using XCB?

I found some tutorials using

1条回答
  •  执念已碎
    2021-02-13 20:47

    You should be able to use the XTEST extension to fake input to the active window, using the xcb_test_fake_input() function.

    #include 
    ...
    xcb_test_fake_input(c, XCB_KEY_PRESS, keycode, XCB_CURRENT_TIME, XCB_NONE, 0, 0, 0);
    xcb_test_fake_input(c, XCB_KEY_RELEASE, keycode, XCB_CURRENT_TIME, XCB_NONE, 0, 0, 0);
    

    See the xte program in xcb/demos for a working example.

    0 讨论(0)
提交回复
热议问题