def delayed_click(m, button=0, times=1): old = eye_mouse.config.control_mouse eye_mouse.config.control_mouse = False x, y = click_pos(m) ctrl.mouse(x, y) ctrl.mouse_click(x, y, button=button, times=times, wait=16000) time.sleep(0.032) eye_mouse.config.control_mouse = old
def on_pop(self, noise): if len(mouse.eye_hist) < 2: return if noise != 'hiss_start': return now = time.time() if self.state == STATE_IDLE: if now - self.last_click < config.double_click: ctrl.mouse_click(hold=32000) return l, r = mouse.eye_hist[-1] p = (l.gaze + r.gaze) / 2 main_gaze = -0.02 < p.x < 1.02 and -0.02 < p.y < 1.02 and bool( l or r) if not main_gaze: pass # return ctrl.cursor_visible(False) self.gaze = eye_config.size_px * p capture = self.gaze - (config.screen_area / 2) capture.x = min(max(capture.x, 0), main_screen.width - config.screen_area.x) capture.y = min(max(capture.y, 0), main_screen.height - config.screen_area.y) self.rect = (capture.x, capture.y, config.screen_area.x, config.screen_area.y) self.pos = self.gaze - (config.screen_area * config.img_scale) / 2 self.pos.x = min( max(self.pos.x, 0), main_screen.width - config.screen_area.x * config.img_scale) self.pos.y = min( max(self.pos.y, 0), main_screen.height - config.screen_area.y * config.img_scale) self.size = Point2d(config.screen_area.x * config.img_scale, config.screen_area.y * config.img_scale) self.off = Point2d(0, 0) self.frame = 0 self.canvas = canvas.Canvas(self.pos.x, self.pos.y, self.size.x, self.size.y) if not config.live: self.capture() self.canvas.register('draw', self.draw) self.state = STATE_OVERLAY elif self.state == STATE_OVERLAY: self.state = STATE_IDLE ctrl.cursor_visible(True) self.canvas.unregister('draw', self.draw) self.canvas.close() self.canvas = None dot, origin = self.get_pos() if origin: ctrl.mouse(origin.x, origin.y) ctrl.mouse_click(hold=32000) self.last_click = time.time()
def delayed_click(m, button=0, times=1, down=None, up=None): old = eye.config.control_mouse eye.config.control_mouse = False x, y = click_pos(m) ctrl.mouse(x, y) for i in range(times): time.sleep(0.016) ctrl.mouse_click(x, y, button=button, times=i+1, down=down, up=up) time.sleep(0.032) eye.config.control_mouse = old
def control_zoom_mouse(m): ctrl.mouse(10, 10) if eye_zoom_mouse.zoom_mouse.enabled: eye_zoom_mouse.zoom_mouse.disable() else: eye_zoom_mouse.zoom_mouse.enable() eye_zoom_mouse.zoom_mouse.toggle() if eye_mouse.control_mouse.enabled: eye_mouse.control_mouse.toggle()
def on_move(self, typ, e): if typ != tap.MMOVE: return self.mouse_last = pos = Point2d(e.x, e.y) if self.hiss_start and not self.dragging: if (pos - self.mouse_origin).len() > 10: self.dragging = True self.button = 0 x, y = self.mouse_origin.x, self.mouse_origin.y ctrl.mouse(x, y) ctrl.mouse_click(x, y, button=0, down=True)
def warp(self, name): window = ui.active_window() bundle = window.app.bundle try: x_offset, y_offset = self.data[bundle][name] except KeyError: return rect = window.rect x = rect.left + (x_offset % rect.width) y = rect.top + (y_offset % rect.height) ctrl.mouse(x, y)
def restore(self): # l, r = mouse.eye_hist[-1] # print(f"{(l.pos.z + r.pos.z) / 2}") ctrl.cursor_visible(True) if self.top is not None: # print(f"Restore left: {pos} {self.saved_mouse_left}") if self.saved_mouse_top: mouse.last_ctrl = self.saved_mouse_top ctrl.mouse(self.saved_mouse_top.x, self.saved_mouse_top.y) # self.saved_mouse_left = None self.main_gaze = False
def open_dragon_menubar(): old = ctrl.mouse_pos() x = applescript.run(""" tell application "System Events" to tell process "Dragon" to tell (menu bar item 1 of menu bar 2) set AppleScript's text item delimiters to ", " position as string end tell """) x, y = map(int, x.split(", ")) ctrl.mouse(x, y + 5) ctrl.mouse_click() ctrl.mouse(*old)
def delayed_click(m, button=0, times=1, from_end=False, mods=None): if mods is None: mods = [] old = eye_mouse.config.control_mouse eye_mouse.config.control_mouse = False x, y = click_pos(m, from_end=from_end) ctrl.mouse(x, y) for key in mods: ctrl.key_press(key, down=True) ctrl.mouse_click(x, y, button=button, times=times, wait=16000) for key in mods[::-1]: ctrl.key_press(key, up=True) time.sleep(0.032) eye_mouse.config.control_mouse = old
def final_pos_click(m, button=0, times=1, down=None, up=None): old = eye.config.control_mouse eye.config.control_mouse = False x, y = get_final_mouse_pos(m) ctrl.mouse(x, y) ctrl.mouse_click(x, y, button=button, down=down, up=up, times=times, wait=16000) time.sleep(0.032) eye.config.control_mouse = old
def open_dragon_pad(): "Open DragonPad" old = ctrl.mouse_pos() x = applescript.run(""" tell application "System Events" to tell process "Dragon" to tell (menu bar item 1 of menu bar 2) set AppleScript's text item delimiters to ", " position as string end tell """) x, y = map(int, x.split(", ")) ctrl.mouse(x, y) ctrl.mouse_click() ctrl.mouse(*old) applescript.run(""" tell application "System Events" to tell process "Dragon" to tell (menu bar item 1 of menu bar 2) click menu item "Help" of menu 1 click menu item "DragonPad" of menu of menu item "Help" of menu 1 end tell """)
def restore(self): # l, r = mouse.eye_hist[-1] # print(f"{(l.pos.z + r.pos.z) / 2}") ctrl.cursor_visible(True) pos = mouse.xy_hist[-1] if self.right is None or (pos.x < main.width / 2 and self.left is not None): # print(f"Restore left: {pos} {self.saved_mouse_left}") if self.saved_mouse_left: mouse.last_ctrl = self.saved_mouse_left ctrl.mouse(self.saved_mouse_left.x, self.saved_mouse_left.y) # self.saved_mouse_left = None self.main_gaze = False elif pos.x > main.width / 2: # print(f"Restore right: {pos} {self.saved_mouse_right}") if self.saved_mouse_right: mouse.last_ctrl = self.saved_mouse_right ctrl.mouse(self.saved_mouse_right.x, self.saved_mouse_right.y) # self.saved_mouse_right = None self.main_gaze = False
def descend(self, m): ctx.set_list('current', self.roots.keys()) word = str(m['menus.current'][0]) # print(word, self.path) new_menu = False if word in self.roots: if self.path: new_menu = True self.path = [word] elif word == 'menu back': self.path.pop() else: self.path.append(word) if word == 'menu cancel' or word == 'menu back' and not self.path: ctrl.key_press('escape') self.update() return pos = self.roots.get(word) or self.leafs.get(word) if pos and False: x, y = map(int, pos) ctrl.mouse(x, y) if not new_menu: ctrl.mouse_click() app = get_app() cur, menu = get_menu(app.menu_bars[1], self.path) if not pos or True: if new_menu: ctrl.key_press('escape') cur.click() self.leafs = name_and_centers(menu.menu_items) if self.leafs: # print(self.leafs) ctx.set_list( 'current', list(self.leafs.keys()) + ['menu back', 'menu cancel'] + list(self.roots.keys())) else: self.update()
def draw(self, canvas): if not self.canvas: return False if config.live and self.rect: self.capture() self.frame += 1 if self.frame < config.frames: t = ((self.frame + 1) / config.frames)**2 anim_pos_from = Point2d(self.rect[0], self.rect[1]) anim_pos_to = Point2d(canvas.x, canvas.y) anim_size_from = config.screen_area anim_size_to = Point2d(canvas.width, canvas.height) pos = anim_pos_from + (anim_pos_to - anim_pos_from) * t size = anim_size_from + (anim_size_to - anim_size_from) * t dst = Rect(pos.x, pos.y, size.x, size.y) elif self.frame == config.frames: self.canvas.set_panel(True) dst = Rect(canvas.x, canvas.y, canvas.width, canvas.height) else: dst = Rect(canvas.x, canvas.y, canvas.width, canvas.height) src = Rect(0, 0, self.img.width, self.img.height) canvas.draw_image_rect(self.img, src, dst) dot, origin = self.get_pos() if not dot: return paint = canvas.paint paint.style = paint.Style.FILL paint.color = 'ffffff' canvas.draw_circle(dot.x, dot.y, config.img_scale + 1) canvas.draw_circle(origin.x, origin.y, 2) paint.color = '000000' canvas.draw_circle(dot.x, dot.y, config.img_scale) canvas.draw_circle(origin.x, origin.y, 1) ctrl.mouse(origin.x, origin.y)
def restore(self): if self.saved_mouse: mouse.last_ctrl = self.saved_mouse ctrl.mouse(self.saved_mouse.x, self.saved_mouse.y) self.saved_mouse = None self.main_gaze = False
def navigate_left(m): press('ctrl-cmd-shift-h') (x, y) = ctrl.mouse_pos() ctrl.mouse(x - distance_to_navigate, y)
def navigate_right(m): press('ctrl-cmd-shift-l') (x, y) = ctrl.mouse_pos() ctrl.mouse(x + distance_to_navigate, y)
def delayed_click(m, button=0, times=1): x, y = click_pos(m) ctrl.mouse(x, y) ctrl.mouse_click(x, y, button=button, times=times, wait=16000) time.sleep(0.032)
def control_mouse(m): ctrl.mouse(0, 0) eye_mouse.control_mouse.toggle() if eye_zoom_mouse.zoom_mouse.enabled: eye_zoom_mouse.zoom_mouse.enable()
def move_mouse_to_position(m): ctrl.mouse(xPos, yPos)
def move(m): x, y = click_pos(m) ctrl.mouse(x, y, dy=amount)