當前位置: 首頁>>代碼示例>>Python>>正文


Python X.ButtonPress方法代碼示例

本文整理匯總了Python中Xlib.X.ButtonPress方法的典型用法代碼示例。如果您正苦於以下問題:Python X.ButtonPress方法的具體用法?Python X.ButtonPress怎麽用?Python X.ButtonPress使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Xlib.X的用法示例。


在下文中一共展示了X.ButtonPress方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: makemousehookevent

# 需要導入模塊: from Xlib import X [as 別名]
# 或者: from Xlib.X import ButtonPress [as 別名]
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) 
開發者ID:OmkarPathak,項目名稱:Python-Programs,代碼行數:22,代碼來源:pyxhook.py

示例2: makemousehookevent

# 需要導入模塊: from Xlib import X [as 別名]
# 或者: from Xlib.X import ButtonPress [as 別名]
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) 
開發者ID:jpdias,項目名稱:botnet-lab,代碼行數:23,代碼來源:pyxhook.py

示例3: makemousehookevent

# 需要導入模塊: from Xlib import X [as 別名]
# 或者: from Xlib.X import ButtonPress [as 別名]
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) 
開發者ID:BillBillBillBill,項目名稱:Tickeys-linux,代碼行數:24,代碼來源:pyxhook.py

示例4: __sendMouseClick

# 需要導入模塊: from Xlib import X [as 別名]
# 或者: from Xlib.X import ButtonPress [as 別名]
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() 
開發者ID:autokey,項目名稱:autokey,代碼行數:19,代碼來源:interface.py

示例5: run

# 需要導入模塊: from Xlib import X [as 別名]
# 或者: from Xlib.X import ButtonPress [as 別名]
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() 
開發者ID:autokey,項目名稱:autokey,代碼行數:26,代碼來源:interface.py

示例6: __processEvent

# 需要導入模塊: from Xlib import X [as 別名]
# 或者: from Xlib.X import ButtonPress [as 別名]
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) 
開發者ID:autokey,項目名稱:autokey,代碼行數:20,代碼來源:interface.py

示例7: handle_event

# 需要導入模塊: from Xlib import X [as 別名]
# 或者: from Xlib.X import ButtonPress [as 別名]
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) 
開發者ID:linuxdeepin,項目名稱:deepin-remote-assistance,代碼行數:25,代碼來源:event.py

示例8: _mouseDown

# 需要導入模塊: from Xlib import X [as 別名]
# 或者: from Xlib.X import ButtonPress [as 別名]
def _mouseDown(self, location: Location, button: str):
        """
        Mouse button press

        :param location :x,y coordinates where to click
        :param button 'left','middle','right'

        """
        self.moveTo(location)
        assert (
            button in self.MOUSE_BUTTONS.keys()
        ), "button argument not in ('left', 'middle', 'right', 4, 5, 6, 7)"
        button = self.MOUSE_BUTTONS[button]
        fake_input(self.display, X.ButtonPress, button)
        self.display.sync() 
開發者ID:mozilla,項目名稱:iris,代碼行數:17,代碼來源:xmouse.py

示例9: run

# 需要導入模塊: from Xlib import X [as 別名]
# 或者: from Xlib.X import ButtonPress [as 別名]
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) 
開發者ID:OmkarPathak,項目名稱:Python-Programs,代碼行數:31,代碼來源:pyxhook.py

示例10: HookMouse

# 需要導入模塊: from Xlib import X [as 別名]
# 或者: from Xlib.X import ButtonPress [as 別名]
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 
開發者ID:OmkarPathak,項目名稱:Python-Programs,代碼行數:10,代碼來源:pyxhook.py

示例11: processevents

# 需要導入模塊: from Xlib import X [as 別名]
# 或者: from Xlib.X import ButtonPress [as 別名]
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 
開發者ID:OmkarPathak,項目名稱:Python-Programs,代碼行數:33,代碼來源:pyxhook.py

示例12: _mouseDown

# 需要導入模塊: from Xlib import X [as 別名]
# 或者: from Xlib.X import ButtonPress [as 別名]
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() 
開發者ID:asweigart,項目名稱:pyautogui,代碼行數:8,代碼來源:_pyautogui_x11.py

示例13: run

# 需要導入模塊: from Xlib import X [as 別名]
# 或者: from Xlib.X import ButtonPress [as 別名]
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) 
開發者ID:nikhilkumarsingh,項目名稱:clix,代碼行數:36,代碼來源:pyxhook.py

示例14: HookMouse

# 需要導入模塊: from Xlib import X [as 別名]
# 或者: from Xlib.X import ButtonPress [as 別名]
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 
開發者ID:nikhilkumarsingh,項目名稱:clix,代碼行數:10,代碼來源:pyxhook.py

示例15: makemousehookevent

# 需要導入模塊: from Xlib import X [as 別名]
# 或者: from Xlib.X import ButtonPress [as 別名]
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
        ) 
開發者ID:nikhilkumarsingh,項目名稱:clix,代碼行數:30,代碼來源:pyxhook.py


注:本文中的Xlib.X.ButtonPress方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。