Python pynput.mouse.Controller() Examples
The following are 11
code examples of pynput.mouse.Controller().
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
pynput.mouse
, or try the search function
.
Example #1
Source File: test_dateentry.py From tkcalendar with GNU General Public License v3.0 | 6 votes |
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())
Example #2
Source File: workers.py From TensorMouse with MIT License | 6 votes |
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))
Example #3
Source File: proxy.py From airtest-selenium with Apache License 2.0 | 5 votes |
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}
Example #4
Source File: proxy.py From airtest-selenium with Apache License 2.0 | 5 votes |
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
Example #5
Source File: proxy.py From airtest-selenium with Apache License 2.0 | 5 votes |
def __init__(self, command_executor='http://127.0.0.1:4444/wd/hub', desired_capabilities=None, browser_profile=None, proxy=None, keep_alive=False, file_detector=None, options=None): super(WebRemote,self).__init__(command_executor=command_executor, desired_capabilities=desired_capabilities, browser_profile=browser_profile, proxy=proxy, keep_alive=keep_alive, file_detector=file_detector, options=options) self.father_number = {0: 0} self.action_chains = ActionChains(self) self.number = 0 self.mouse=Controller() self.operation_to_func={"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}
Example #6
Source File: proxy.py From airtest-selenium with Apache License 2.0 | 5 votes |
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
Example #7
Source File: proxy.py From airtest-selenium with Apache License 2.0 | 5 votes |
def __init__(self, firefox_profile=None, firefox_binary=None, timeout=30, capabilities=None, proxy=None, executable_path="geckodriver", options=None, firefox_options=None, service_args=None, desired_capabilities=None, log_path=None): print("Please make sure your geckodriver is in your path before proceeding using this driver") super(WebFirefox, self).__init__(firefox_profile=firefox_profile, firefox_binary=firefox_binary, timeout=timeout, capabilities=capabilities, proxy=proxy, executable_path=executable_path, options=options, firefox_options=firefox_options, service_args=service_args, desired_capabilities=desired_capabilities, log_path=log_path) self.father_number = {0: 0} self.action_chains = ActionChains(self) self.number = 0 self.mouse = Controller() self.operation_to_func = {"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}
Example #8
Source File: mouse_controller.py From iris with Mozilla Public License 2.0 | 5 votes |
def __init__(self): self.mouse = MouseController()
Example #9
Source File: test_itemscanvas.py From ttkwidgets with GNU General Public License v3.0 | 5 votes |
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()
Example #10
Source File: test_itemscanvas.py From ttkwidgets with GNU General Public License v3.0 | 5 votes |
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()
Example #11
Source File: test_itemscanvas.py From ttkwidgets with GNU General Public License v3.0 | 5 votes |
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()