Python Xlib.X.ButtonPress() Examples
The following are 30
code examples of Xlib.X.ButtonPress().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
Xlib.X
, or try the search function
.
Example #1
Source File: event.py From deepin-remote-assistance with GNU General Public License v3.0 | 6 votes |
def handle_event(self, event): # KeyPress event if event.type == X.KeyPress: keyname = xrobot.get_keyname(event) self.keyPressed.emit(keyname) # KeyRelease event elif event.type == X.KeyRelease: keyname = xrobot.get_keyname(event) self.keyReleased.emit(keyname) # ButtonPress event elif event.type == X.ButtonPress: self.buttonPressed.emit(event.root_x, event.root_y, event.time) # ButtonRelease event elif event.type == X.ButtonRelease: self.buttonReleased.emit(event.root_x, event.root_y, event.time) # MotionNotify event elif event.type == X.MotionNotify: self.cursorPositionChanged.emit(event.root_x, event.root_y)
Example #2
Source File: pyxhook.py From Tickeys-linux with MIT License | 6 votes |
def makemousehookevent(self, event): storewm = self.xwindowinfo() if event.detail == 1: MessageName = "mouse left " elif event.detail == 3: MessageName = "mouse right " elif event.detail == 2: MessageName = "mouse middle " elif event.detail == 5: MessageName = "mouse wheel down " elif event.detail == 4: MessageName = "mouse wheel up " else: MessageName = "mouse " + str(event.detail) + " " if event.type == X.ButtonPress: MessageName = MessageName + "down" elif event.type == X.ButtonRelease: MessageName = MessageName + "up" else: MessageName = "mouse moved" return pyxhookmouseevent(storewm["handle"], storewm["name"], storewm["class"], (self.mouse_position_x, self.mouse_position_y), MessageName)
Example #3
Source File: pyxhook.py From Python-Programs with GNU General Public License v3.0 | 6 votes |
def makemousehookevent(self, event): storewm = self.xwindowinfo() if event.detail == 1: MessageName = "mouse left " elif event.detail == 3: MessageName = "mouse right " elif event.detail == 2: MessageName = "mouse middle " elif event.detail == 5: MessageName = "mouse wheel down " elif event.detail == 4: MessageName = "mouse wheel up " else: MessageName = "mouse " + str(event.detail) + " " if event.type == X.ButtonPress: MessageName = MessageName + "down" elif event.type == X.ButtonRelease: MessageName = MessageName + "up" return pyxhookmouseevent(storewm["handle"], storewm["name"], storewm["class"], (self.mouse_position_x, self.mouse_position_y), MessageName)
Example #4
Source File: pyxhook.py From PythonP2PBotnet with MIT License | 6 votes |
def makemousehookevent(self, event): storewm = self.xwindowinfo() if event.detail == 1: MessageName = "mouse left " elif event.detail == 3: MessageName = "mouse right " elif event.detail == 2: MessageName = "mouse middle " elif event.detail == 5: MessageName = "mouse wheel down " elif event.detail == 4: MessageName = "mouse wheel up " else: MessageName = "mouse " + str(event.detail) + " " if event.type == X.ButtonPress: MessageName = MessageName + "down" elif event.type == X.ButtonRelease: MessageName = MessageName + "up" return pyxhookmouseevent(storewm["handle"], storewm["name"], storewm["class"], (self.mouse_position_x, self.mouse_position_y), MessageName)
Example #5
Source File: pyxhook.py From py-keylogger with MIT License | 6 votes |
def makemousehookevent(self, event): storewm = self.xwindowinfo() if event.detail == 1: MessageName = "mouse left " elif event.detail == 3: MessageName = "mouse right " elif event.detail == 2: MessageName = "mouse middle " elif event.detail == 5: MessageName = "mouse wheel down " elif event.detail == 4: MessageName = "mouse wheel up " else: MessageName = "mouse " + str(event.detail) + " " if event.type == X.ButtonPress: MessageName = MessageName + "down" elif event.type == X.ButtonRelease: MessageName = MessageName + "up" return pyxhookmouseevent(storewm["handle"], storewm["name"], storewm["class"], (self.mouse_position_x, self.mouse_position_y), MessageName)
Example #6
Source File: interface.py From autokey with GNU General Public License v3.0 | 6 votes |
def __sendMouseClick(self, xCoord, yCoord, button, relative): # Get current pointer position so we can return it there pos = self.rootWindow.query_pointer() if relative: focus = self.localDisplay.get_input_focus().focus focus.warp_pointer(xCoord, yCoord) xtest.fake_input(focus, X.ButtonPress, button, x=xCoord, y=yCoord) xtest.fake_input(focus, X.ButtonRelease, button, x=xCoord, y=yCoord) else: self.rootWindow.warp_pointer(xCoord, yCoord) xtest.fake_input(self.rootWindow, X.ButtonPress, button, x=xCoord, y=yCoord) xtest.fake_input(self.rootWindow, X.ButtonRelease, button, x=xCoord, y=yCoord) self.rootWindow.warp_pointer(pos.root_x, pos.root_y) self.__flush()
Example #7
Source File: interface.py From autokey with GNU General Public License v3.0 | 6 votes |
def __processEvent(self, reply): if reply.category != record.FromServer: return if reply.client_swapped: return if not len(reply.data) or str_or_bytes_to_bytes(reply.data)[0] < 2: # not an event return data = reply.data while len(data): event, data = rq.EventField(None).parse_binary_value(data, self.recordDisplay.display, None, None) if event.type == X.KeyPress: self.handle_keypress(event.detail) elif event.type == X.KeyRelease: self.handle_keyrelease(event.detail) elif event.type == X.ButtonPress: self.handle_mouseclick(event.detail, event.root_x, event.root_y)
Example #8
Source File: interface.py From autokey with GNU General Public License v3.0 | 6 votes |
def run(self): # Create a recording context; we only want key and mouse events self.ctx = self.recordDisplay.record_create_context( 0, [record.AllClients], [{ 'core_requests': (0, 0), 'core_replies': (0, 0), 'ext_requests': (0, 0, 0, 0), 'ext_replies': (0, 0, 0, 0), 'delivered_events': (0, 0), 'device_events': (X.KeyPress, X.ButtonPress), #X.KeyRelease, 'errors': (0, 0), 'client_started': False, 'client_died': False, }]) # Enable the context; this only returns after a call to record_disable_context, # while calling the callback function in the meantime logger.info("XRecord interface thread starting") self.recordDisplay.record_enable_context(self.ctx, self.__processEvent) # Finally free the context self.recordDisplay.record_free_context(self.ctx) self.recordDisplay.close()
Example #9
Source File: pyxhook.py From botnet-lab with MIT License | 6 votes |
def makemousehookevent(self, event): storewm = self.xwindowinfo() if event.detail == 1: MessageName = "mouse left " elif event.detail == 3: MessageName = "mouse right " elif event.detail == 2: MessageName = "mouse middle " elif event.detail == 5: MessageName = "mouse wheel down " elif event.detail == 4: MessageName = "mouse wheel up " else: MessageName = "mouse " + str(event.detail) + " " if event.type == X.ButtonPress: MessageName = MessageName + "down" elif event.type == X.ButtonRelease: MessageName = MessageName + "up" return pyxhookmouseevent(storewm["handle"], storewm["name"], storewm["class"], (self.mouse_position_x, self.mouse_position_y), MessageName)
Example #10
Source File: pyxhook.py From Tickeys-linux with MIT License | 5 votes |
def processevents(self, reply): if reply.category != record.FromServer: return if reply.client_swapped: print("* received swapped protocol data, cowardly ignored") return if not len(reply.data) or ord(reply.data[0]) < 2: # not an event return data = reply.data while len(data): event, data = rq.EventField(None).parse_binary_value(data, self.record_dpy.display, None, None) if event.type == X.KeyPress: hookevent = self.keypressevent(event) self.KeyDown(hookevent) elif event.type == X.KeyRelease: hookevent = self.keyreleaseevent(event) self.KeyUp(hookevent) elif event.type == X.ButtonPress: hookevent = self.buttonpressevent(event) self.MouseAllButtonsDown(hookevent) elif event.type == X.ButtonRelease: hookevent = self.buttonreleaseevent(event) self.MouseAllButtonsUp(hookevent) elif event.type == X.MotionNotify: # use mouse moves to record mouse position, since press and release events # do not give mouse position info (event.root_x and event.root_y have # bogus info). hookevent = self.mousemoveevent(event) self.MouseMovement(hookevent) #print "processing events...", event.type
Example #11
Source File: pyxhook.py From Tickeys-linux with MIT License | 5 votes |
def run(self): # Check if the extension is present if not self.record_dpy.has_extension("RECORD"): print("RECORD extension not found") sys.exit(1) r = self.record_dpy.record_get_version(0, 0) print("RECORD extension version %d.%d" % (r.major_version, r.minor_version)) # Create a recording context; we only want key and mouse events self.ctx = self.record_dpy.record_create_context( 0, [record.AllClients], [{ 'core_requests': (0, 0), 'core_replies': (0, 0), 'ext_requests': (0, 0, 0, 0), 'ext_replies': (0, 0, 0, 0), 'delivered_events': (0, 0), 'device_events': tuple(self.contextEventMask), #(X.KeyPress, X.ButtonPress), 'errors': (0, 0), 'client_started': False, 'client_died': False, }]) # Enable the context; this only returns after a call to record_disable_context, # while calling the callback function in the meantime self.record_dpy.record_enable_context(self.ctx, self.processevents) # Finally free the context self.record_dpy.record_free_context(self.ctx)
Example #12
Source File: draw-proto.py From python-xlib with GNU Lesser General Public License v2.1 | 5 votes |
def loop(self): current = None while 1: e = self.d.next_event() # Window has been destroyed, quit if e.type == X.DestroyNotify: sys.exit(0) # Some part of the window has been exposed, # redraw all the objects. if e.type == X.Expose: for o in self.objects: o.expose(e) # Left button pressed, start to draw if e.type == X.ButtonPress and e.detail == 1: current = Movement(self, e) self.objects.append(current) # Left button released, finish drawing if e.type == X.ButtonRelease and e.detail == 1 and current: current.finish(e) current = None # Mouse movement with button pressed, draw if e.type == X.MotionNotify and current: current.motion(e) # A drawed objects, consisting of either a single # rhomboid, or two rhomboids connected by a winding line
Example #13
Source File: draw.py From python-xlib with GNU Lesser General Public License v2.1 | 5 votes |
def loop(self): current = None while 1: e = self.d.next_event() # Window has been destroyed, quit if e.type == X.DestroyNotify: sys.exit(0) # Some part of the window has been exposed, # redraw all the objects. if e.type == X.Expose: for o in self.objects: o.expose(e) # Left button pressed, start to draw if e.type == X.ButtonPress and e.detail == 1: current = Movement(self, e) self.objects.append(current) # Left button released, finish drawing if e.type == X.ButtonRelease and e.detail == 1 and current: current.finish(e) current = None # Mouse movement with button pressed, draw if e.type == X.MotionNotify and current: current.motion(e) if e.type == X.ClientMessage: if e.client_type == self.WM_PROTOCOLS: fmt, data = e.data if fmt == 32 and data[0] == self.WM_DELETE_WINDOW: sys.exit(0) # A drawed objects, consisting of either a single # rhomboid, or two rhomboids connected by a winding line
Example #14
Source File: record_demo.py From python-xlib with GNU Lesser General Public License v2.1 | 5 votes |
def record_callback(reply): if reply.category != record.FromServer: return if reply.client_swapped: print("* received swapped protocol data, cowardly ignored") return if not len(reply.data) or reply.data[0] < 2: # not an event return data = reply.data while len(data): event, data = rq.EventField(None).parse_binary_value(data, record_dpy.display, None, None) if event.type in [X.KeyPress, X.KeyRelease]: pr = event.type == X.KeyPress and "Press" or "Release" keysym = local_dpy.keycode_to_keysym(event.detail, 0) if not keysym: print("KeyCode%s" % pr, event.detail) else: print("KeyStr%s" % pr, lookup_keysym(keysym)) if event.type == X.KeyPress and keysym == XK.XK_Escape: local_dpy.record_disable_context(ctx) local_dpy.flush() return elif event.type == X.ButtonPress: print("ButtonPress", event.detail) elif event.type == X.ButtonRelease: print("ButtonRelease", event.detail) elif event.type == X.MotionNotify: print("MotionNotify", event.root_x, event.root_y) # Check if the extension is present
Example #15
Source File: interface.py From autokey with GNU General Public License v3.0 | 5 votes |
def _paste_using_mouse_button_2(self): """Paste using the mouse: Press the second mouse button, then release it again.""" focus = self.localDisplay.get_input_focus().focus xtest.fake_input(focus, X.ButtonPress, X.Button2) xtest.fake_input(focus, X.ButtonRelease, X.Button2) logger.debug("Mouse Button2 event sent.")
Example #16
Source File: interface.py From autokey with GNU General Public License v3.0 | 5 votes |
def __sendMouseClickRelative(self, xoff, yoff, button): # Get current pointer position pos = self.rootWindow.query_pointer() xCoord = pos.root_x + xoff yCoord = pos.root_y + yoff self.rootWindow.warp_pointer(xCoord, yCoord) xtest.fake_input(self.rootWindow, X.ButtonPress, button, x=xCoord, y=yCoord) xtest.fake_input(self.rootWindow, X.ButtonRelease, button, x=xCoord, y=yCoord) self.rootWindow.warp_pointer(pos.root_x, pos.root_y) self.__flush()
Example #17
Source File: pyxhook.py From MouseTracks with GNU General Public License v3.0 | 5 votes |
def run(self): # Check if the extension is present if not self.record_dpy.has_extension("RECORD"): print("RECORD extension not found", file=sys.stderr) sys.exit(1) # r = self.record_dpy.record_get_version(0, 0) # print("RECORD extension version {major}.{minor}".format( # major=r.major_version, # minor=r.minor_version # )) # Create a recording context; we only want key and mouse events self.ctx = self.record_dpy.record_create_context( 0, [record.AllClients], [{ 'core_requests': (0, 0), 'core_replies': (0, 0), 'ext_requests': (0, 0, 0, 0), 'ext_replies': (0, 0, 0, 0), 'delivered_events': (0, 0), # (X.KeyPress, X.ButtonPress), 'device_events': tuple(self.contextEventMask), 'errors': (0, 0), 'client_started': False, 'client_died': False, }]) # Enable the context; this only returns after a call to # record_disable_context, while calling the callback function in the # meantime self.record_dpy.record_enable_context(self.ctx, self.processevents) # Finally free the context self.record_dpy.record_free_context(self.ctx)
Example #18
Source File: pyxhook.py From MouseTracks with GNU General Public License v3.0 | 5 votes |
def HookMouse(self): # We don't need to do anything here anymore, since the default mask # is now set to contain X.MotionNotify # need mouse motion to track pointer position, since ButtonPress # events don't carry that info. # self.contextEventMask[1] = X.MotionNotify pass
Example #19
Source File: pyxhook.py From MouseTracks with GNU General Public License v3.0 | 5 votes |
def makemousehookevent(self, event): storewm = self.xwindowinfo() if event.detail == 1: MessageName = "mouse left " elif event.detail == 3: MessageName = "mouse right " elif event.detail == 2: MessageName = "mouse middle " elif event.detail == 5: MessageName = "mouse wheel down " elif event.detail == 4: MessageName = "mouse wheel up " else: MessageName = "mouse {} ".format(event.detail) if event.type == X.ButtonPress: MessageName = "{} down".format(MessageName) elif event.type == X.ButtonRelease: MessageName = "{} up".format(MessageName) else: MessageName = "mouse moved" return pyxhookmouseevent( storewm["handle"], storewm["name"], storewm["class"], (self.mouse_position_x, self.mouse_position_y), MessageName )
Example #20
Source File: pyxhook.py From PythonP2PBotnet with MIT License | 5 votes |
def run(self): # Check if the extension is present if not self.record_dpy.has_extension("RECORD"): print "RECORD extension not found" sys.exit(1) r = self.record_dpy.record_get_version(0, 0) #print "RECORD extension version %d.%d" % (r.major_version, r.minor_version) # Create a recording context; we only want key and mouse events self.ctx = self.record_dpy.record_create_context( 0, [record.AllClients], [{ 'core_requests': (0, 0), 'core_replies': (0, 0), 'ext_requests': (0, 0, 0, 0), 'ext_replies': (0, 0, 0, 0), 'delivered_events': (0, 0), 'device_events': tuple(self.contextEventMask), #(X.KeyPress, X.ButtonPress), 'errors': (0, 0), 'client_started': False, 'client_died': False, }]) # Enable the context; this only returns after a call to record_disable_context, # while calling the callback function in the meantime self.record_dpy.record_enable_context(self.ctx, self.processevents) # Finally free the context self.record_dpy.record_free_context(self.ctx)
Example #21
Source File: pyxhook.py From PythonP2PBotnet with MIT License | 5 votes |
def HookMouse(self): pass # We don't need to do anything here anymore, since the default mask # is now set to contain X.MotionNotify # need mouse motion to track pointer position, since ButtonPress events # don't carry that info. #self.contextEventMask[1] = X.MotionNotify
Example #22
Source File: pyxhook.py From PythonP2PBotnet with MIT License | 5 votes |
def processevents(self, reply): if reply.category != record.FromServer: return if reply.client_swapped: print "* received swapped protocol data, cowardly ignored" return if not len(reply.data) or ord(reply.data[0]) < 2: # not an event return data = reply.data while len(data): event, data = rq.EventField(None).parse_binary_value(data, self.record_dpy.display, None, None) if event.type == X.KeyPress: hookevent = self.keypressevent(event) self.KeyDown(hookevent) elif event.type == X.KeyRelease: hookevent = self.keyreleaseevent(event) self.KeyUp(hookevent) elif event.type == X.ButtonPress: hookevent = self.buttonpressevent(event) self.MouseAllButtonsDown(hookevent) elif event.type == X.ButtonRelease: hookevent = self.buttonreleaseevent(event) self.MouseAllButtonsUp(hookevent) elif event.type == X.MotionNotify: # use mouse moves to record mouse position, since press and release events # do not give mouse position info (event.root_x and event.root_y have # bogus info). self.mousemoveevent(event) #print "processing events...", event.type
Example #23
Source File: _pyautogui_x11.py From xbmc with GNU General Public License v3.0 | 5 votes |
def _mouseDown(x, y, button): _moveTo(x, y) assert button in BUTTON_NAME_MAPPING.keys(), "button argument not in ('left', 'middle', 'right', 4, 5, 6, 7)" button = BUTTON_NAME_MAPPING[button] fake_input(_display, X.ButtonPress, button) _display.sync()
Example #24
Source File: mouse.py From deepin-remote-assistance with GNU General Public License v3.0 | 5 votes |
def handle_mouse_event(event): '''Listening mouse event and send it to browser''' try: if not client_dbus or not client_dbus.remoting_connected: return if not client_dbus.main_window.root.getCaptureCursor(): return offsetX = client_dbus.main_window.root.getCursorX() offsetY = client_dbus.main_window.root.getCursorY() width = int(client_dbus.main_window.root.getVideoWidth()) height = int(client_dbus.main_window.root.getVideoHeight()) except AttributeError as e: print(e) return msg = { 'type': event.type, 'x': offsetX, 'y': offsetY, 'w': width, 'h': height, } if event.type == X.ButtonPress or event.type == X.ButtonRelease: msg['button'] = button_ids[event.detail] elif event.type != X.MotionNotify: # Ignore KeyPress/KeyRelease event return send_message(json.dumps(msg))
Example #25
Source File: recipe-578082.py From code with MIT License | 5 votes |
def mouse_click_down(button): Xlib.ext.xtest.fake_input(d,X.ButtonPress, button) d.sync()
Example #26
Source File: pyxhook.py From Python-Programs with GNU General Public License v3.0 | 5 votes |
def run(self): # Check if the extension is present if not self.record_dpy.has_extension("RECORD"): print ("RECORD extension not found") sys.exit(1) r = self.record_dpy.record_get_version(0, 0) print ("RECORD extension version %d.%d" % (r.major_version, r.minor_version)) # Create a recording context; we only want key and mouse events self.ctx = self.record_dpy.record_create_context( 0, [record.AllClients], [{ 'core_requests': (0, 0), 'core_replies': (0, 0), 'ext_requests': (0, 0, 0, 0), 'ext_replies': (0, 0, 0, 0), 'delivered_events': (0, 0), 'device_events': tuple(self.contextEventMask), #(X.KeyPress, X.ButtonPress), 'errors': (0, 0), 'client_started': False, 'client_died': False, }]) # Enable the context; this only returns after a call to record_disable_context, # while calling the callback function in the meantime self.record_dpy.record_enable_context(self.ctx, self.processevents) # Finally free the context self.record_dpy.record_free_context(self.ctx)
Example #27
Source File: pyxhook.py From Python-Programs with GNU General Public License v3.0 | 5 votes |
def HookMouse(self): pass # We don't need to do anything here anymore, since the default mask # is now set to contain X.MotionNotify # need mouse motion to track pointer position, since ButtonPress events # don't carry that info. #self.contextEventMask[1] = X.MotionNotify
Example #28
Source File: pyxhook.py From Python-Programs with GNU General Public License v3.0 | 5 votes |
def processevents(self, reply): if reply.category != record.FromServer: return if reply.client_swapped: print ("* received swapped protocol data, cowardly ignored") return if not len(reply.data) or reply.data[0] < 2: # not an event return data = reply.data while len(data): event, data = rq.EventField(None).parse_binary_value(data, self.record_dpy.display, None, None) if event.type == X.KeyPress: hookevent = self.keypressevent(event) self.KeyDown(hookevent) elif event.type == X.KeyRelease: hookevent = self.keyreleaseevent(event) self.KeyUp(hookevent) elif event.type == X.ButtonPress: hookevent = self.buttonpressevent(event) self.MouseAllButtonsDown(hookevent) elif event.type == X.ButtonRelease: hookevent = self.buttonreleaseevent(event) self.MouseAllButtonsUp(hookevent) elif event.type == X.MotionNotify: # use mouse moves to record mouse position, since press and release events # do not give mouse position info (event.root_x and event.root_y have # bogus info). self.mousemoveevent(event) #print "processing events...", event.type
Example #29
Source File: _pyautogui_x11.py From pyautogui with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _mouseDown(x, y, button): _moveTo(x, y) assert button in BUTTON_NAME_MAPPING.keys(), "button argument not in ('left', 'middle', 'right', 4, 5, 6, 7)" button = BUTTON_NAME_MAPPING[button] fake_input(_display, X.ButtonPress, button) _display.sync()
Example #30
Source File: pyxhook.py From clix with MIT License | 5 votes |
def run(self): # Check if the extension is present if not self.record_dpy.has_extension("RECORD"): print("RECORD extension not found", file=sys.stderr) sys.exit(1) # r = self.record_dpy.record_get_version(0, 0) # print("RECORD extension version {major}.{minor}".format( # major=r.major_version, # minor=r.minor_version # )) # Create a recording context; we only want key and mouse events self.ctx = self.record_dpy.record_create_context( 0, [record.AllClients], [{ 'core_requests': (0, 0), 'core_replies': (0, 0), 'ext_requests': (0, 0, 0, 0), 'ext_replies': (0, 0, 0, 0), 'delivered_events': (0, 0), # (X.KeyPress, X.ButtonPress), 'device_events': tuple(self.contextEventMask), 'errors': (0, 0), 'client_started': False, 'client_died': False, }]) # Enable the context; this only returns after a call to # record_disable_context, while calling the callback function in the # meantime self.record_dpy.record_enable_context(self.ctx, self.processevents) # Finally free the context self.record_dpy.record_free_context(self.ctx)