X11 key press translator -


i make key press translator "convert" 1 key press another, eg. ctrl+t translated ctrl+x. make "gobal"; make work in application.

as proof of concept i'm experimenting code below doesn't work. problem when capture key press send out key press again captured code... i'm getting infinite loop (the counter there break out of infinite loop). how should send out key press event key press event handler?

#include <stdio.h> #include <x11/xlib.h> #include <xdo.h> #include <x11/extensions/xtest.h>  int main(void) {     display *dpy = xopendisplay(0x0);     xevent ev;     int counter;     xdo_t *xdo = xdo_new(null);        xgrabkeyboard(dpy, defaultrootwindow(dpy), false,          grabmodeasync, grabmodeasync,currenttime);      for(counter = 0; counter < 10; counter++)     {         xnextevent(dpy, &ev);          if(ev.type == keypress) {             xungrabkeyboard(dpy, currenttime);             printf("%d %d\n", ev.xkey.keycode, ev.xany.send_event);             xdo_keysequence(xdo, currentwindow, "a", 0);         }     }      return 0; } 


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -