def pressKey(keyCode): XTEST_EVENTS = { 'KeyPress': 2, 'KeyRelease': 3, 'ButtonPress': 4, 'ButtonRelease': 5, 'MotionNotify': 6 } # send keycode to X server xtest.FakeInput(XTEST_EVENTS['KeyPress'], keyCode, xcffib.CurrentTime, inputWindow, 0, 0, 0, is_checked=True) xtest.FakeInput(XTEST_EVENTS['KeyRelease'], keyCode, xcffib.CurrentTime, inputWindow, 0, 0, 0, is_checked=True) connection.flush()
def fake_click(self, x, y): """Click at the specified coordinates""" conn = Connection(self.env["DISPLAY"]) root = conn.default_screen.root.wid xtest = conn.conn(xcffib.xtest.key) xtest.FakeInput(6, 0, xcffib.xproto.Time.CurrentTime, root, x, y, 0) xtest.FakeInput(4, 1, xcffib.xproto.Time.CurrentTime, root, 0, 0, 0) xtest.FakeInput(5, 1, xcffib.xproto.Time.CurrentTime, root, 0, 0, 0) conn.conn.flush() self.manager.c.sync() conn.finalize()
def test(x, y): # motion xtest.FakeInput(6, 0, xcffib.xproto.Time.CurrentTime, screen.root, x, y, 0) # press xtest.FakeInput(4, 1, xcffib.xproto.Time.CurrentTime, screen.root, 0, 0, 0) # release xtest.FakeInput(5, 1, xcffib.xproto.Time.CurrentTime, screen.root, 2, 2, 0) self.conn.flush()
def fake_click(conn, xtest, x, y): root = conn.default_screen.root.wid xtest.FakeInput(6, 0, xcffib.xproto.Time.CurrentTime, root, x, y, 0) xtest.FakeInput(4, 1, xcffib.xproto.Time.CurrentTime, root, 0, 0, 0) xtest.FakeInput(5, 1, xcffib.xproto.Time.CurrentTime, root, 0, 0, 0) conn.conn.flush()