当前位置: 首页>>代码示例>>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;未经允许,请勿转载。