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


Python mouse.Controller方法代碼示例

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


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

示例1: test_dateentry_drop_down

# 需要導入模塊: from pynput import mouse [as 別名]
# 或者: from pynput.mouse import Controller [as 別名]
def test_dateentry_drop_down(self):
        """Check whether drop down opens on click."""
        widget = DateEntry(self.window)
        widget.pack()
        self.window.update()
        w = widget.winfo_width()
        h = widget.winfo_height()
        widget.event_generate('<1>', x=w - 10, y=h // 2)
        self.window.update()
        self.assertTrue(widget._top_cal.winfo_ismapped())
        mouse = Controller()
        x = widget._top_cal.winfo_rootx() + widget._top_cal.winfo_width() + 10
        y = widget._top_cal.winfo_rooty() + widget._top_cal.winfo_height() + 10
        mouse.position = x, y
        widget._calendar.event_generate('<FocusOut>')
        widget._on_focus_out_cal(TestEvent(widget=widget._calendar,
                                           x='', y=''))
        self.window.update()
        self.assertFalse(widget._top_cal.winfo_ismapped()) 
開發者ID:j4321,項目名稱:tkcalendar,代碼行數:21,代碼來源:test_dateentry.py

示例2: mouse_move_worker

# 需要導入模塊: from pynput import mouse [as 別名]
# 或者: from pynput.mouse import Controller [as 別名]
def mouse_move_worker(objectX, objectY, mouse_state):
    """ Separate process worker to move mouse and perform clicks"""

    import tkinter
    from pynput.mouse import Button, Controller
    import time

    mouse = Controller()
    x,y = tkinter.Tk().winfo_screenwidth(), tkinter.Tk().winfo_screenheight()

    while True:
        if mouse_state.value == MOUSE_CLICK:
            time.sleep(0.2)
            mouse.press(Button.left)
            mouse_state.value = MOUSE_RELEASE
        if mouse_state.value == MOUSE_DRAG:
            time.sleep(0.2)
            mouse.press(Button.left)
            mouse_state.value = MOUSE_DRAGGING
        if (mouse_state.value == MOUSE_RELEASE):
            mouse.release(Button.left)
            mouse_state.value = MOUSE_NULL

        if (objectX.value > 0 and objectY.value > 0):
            mouse.position = (int((1-objectX.value)*x), int(objectY.value*y)) 
開發者ID:tadejmagajna,項目名稱:TensorMouse,代碼行數:27,代碼來源:workers.py

示例3: __init__

# 需要導入模塊: from pynput import mouse [as 別名]
# 或者: from pynput.mouse import Controller [as 別名]
def __init__(self, executable_path="chromedriver", port=0,
                 options=None, service_args=None,
                 desired_capabilities=None, service_log_path=None,
                 chrome_options=None):
        if "darwin" in sys.platform:
            os.environ['PATH'] += ":/Applications/AirtestIDE.app/Contents/Resources/selenium_plugin"
        super(WebChrome, self).__init__(chrome_options=chrome_options, executable_path=executable_path,
                                        port=port, options=options, service_args=service_args,
                                        service_log_path=service_log_path, desired_capabilities=desired_capabilities)
        self.father_number = {0: 0}
        self.action_chains = ActionChains(self)
        self.number = 0
        self.mouse = Controller()
        self.operation_to_func = {"elementsD": self.find_any_element, "xpath": self.find_element_by_xpath, "id": self.find_element_by_id,
                                  "name": self.find_element_by_name, "css": self.find_element_by_css_selector} 
開發者ID:AirtestProject,項目名稱:airtest-selenium,代碼行數:17,代碼來源:proxy.py

示例4: _get_left_up_offset

# 需要導入模塊: from pynput import mouse [as 別名]
# 或者: from pynput.mouse import Controller [as 別名]
def _get_left_up_offset(self):
        window_pos = self.get_window_position()
        window_size = self.get_window_size()
        mouse = Controller()
        screen = self.screenshot()
        screen_size = get_resolution(screen)
        offset = window_size["width"] - \
            screen_size[0], window_size["height"] - screen_size[1]
        pos = (int(offset[0] / 2 + window_pos['x']),
               int(offset[1] + window_pos['y'] - offset[0] / 2))
        return pos 
開發者ID:AirtestProject,項目名稱:airtest-selenium,代碼行數:13,代碼來源:proxy.py

示例5: __init__

# 需要導入模塊: from pynput import mouse [as 別名]
# 或者: from pynput.mouse import Controller [as 別名]
def __init__(self):
        self.mouse = MouseController() 
開發者ID:mozilla,項目名稱:iris,代碼行數:4,代碼來源:mouse_controller.py

示例6: test_itemscanvas_drag

# 需要導入模塊: from pynput import mouse [as 別名]
# 或者: from pynput.mouse import Controller [as 別名]
def test_itemscanvas_drag(self):
        canvas = ItemsCanvas(self.window)
        canvas.pack()
        canvas.add_item("item", font=("default", 16))
        self.window.wm_geometry("+0+0")
        self.window.update()
        mouse_controller = Controller()
        mouse_controller.position = (30, 40)
        self.window.update()
        mouse_controller.press(Button.left)
        self.window.update()
        mouse_controller.move(100, 100)
        self.window.update()
        mouse_controller.release(Button.left)
        self.window.update() 
開發者ID:TkinterEP,項目名稱:ttkwidgets,代碼行數:17,代碼來源:test_itemscanvas.py

示例7: test_itemscanvas_select

# 需要導入模塊: from pynput import mouse [as 別名]
# 或者: from pynput.mouse import Controller [as 別名]
def test_itemscanvas_select(self):
        canvas = ItemsCanvas()
        canvas.pack()
        canvas.add_item("item", font=("default", 16))
        self.window.wm_geometry("+0+0")
        self.window.update()
        mouse_controller = Controller()
        mouse_controller.position = (30, 40)
        self.window.update()
        mouse_controller.press(Button.left)
        self.window.update()
        mouse_controller.release(Button.left)
        self.window.update() 
開發者ID:TkinterEP,項目名稱:ttkwidgets,代碼行數:15,代碼來源:test_itemscanvas.py

示例8: test_itemscanvas_menu

# 需要導入模塊: from pynput import mouse [as 別名]
# 或者: from pynput.mouse import Controller [as 別名]
def test_itemscanvas_menu(self):
        canvas = ItemsCanvas()
        canvas.pack()
        self.window.wm_geometry("+0+0")
        self.window.update()
        mouse_controller = Controller()
        mouse_controller.position = (0, 0)
        mouse_controller.move(30, 40)
        self.window.update()
        mouse_controller.press(Button.right)
        self.window.update()
        mouse_controller.release(Button.right)
        self.window.update() 
開發者ID:TkinterEP,項目名稱:ttkwidgets,代碼行數:15,代碼來源:test_itemscanvas.py


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