from Xlib import X, XK, display from Xlib.ext import record, xtest from Xlib.protocol import rq, event dpy = display.Display() time = 1 def send_i(): global time target = dpy.get_input_focus().focus key_event = event.KeyPress( detail = 42, time = time, root = dpy.screen().root, window = target, child = X.NONE, root_x = 1, root_y = 1, event_x = 1, event_y = 1, state = 1, same_screen = 1) target.send_event(key_event) time = time + 1 key_event = event.KeyRelease( detail = 42, time = time, root = dpy.screen().root, window = target, child = X.NONE, root_x = 1, root_y = 1, event_x = 1, event_y = 1, state = 1, same_screen = 1) target.send_event(key_event) time = time + 1 dpy.sync() def use_fake_input(): xtest.fake_input(dpy, X.KeyPress, 36) xtest.fake_input(dpy, X.KeyRelease, 36) dpy.sync() send_i() use_fake_input() send_i()