Esempio n. 1
0
def do_start_digits(m):
    try:
        for d in m["mouseSnapNineStarter.digits"]:
            mg.narrow(int(digits[d]))
        ctrl.mouse_move(*mg.pos())
    except KeyError:
        pass
Esempio n. 2
0
 def internal(m):
     win = ui.active_window()
     rect = win.rect
     center_x = rect.x + rect.width / 2
     center_y = rect.y + rect.height / 2
     region = regions[m._words[1]]
     if region == "west":
         pos = (center_x - multiplier * rect.width / 4, center_y)
     elif region == "east":
         pos = (center_x + multiplier * rect.width / 4, center_y)
     elif region == "north":
         pos = (center_x, center_y - multiplier * rect.height / 4)
     elif region == "south":
         pos = (center_x, center_y + multiplier * rect.height / 4)
     elif region == "northeast":
         pos = (
             center_x + multiplier * rect.width / 4,
             center_y - multiplier * rect.height / 4,
         )
     elif region == "northwest":
         pos = (
             center_x - multiplier * rect.width / 4,
             center_y - multiplier * rect.height / 4,
         )
     elif region == "southeast":
         pos = (
             center_x + multiplier * rect.width / 4,
             center_y + multiplier * rect.height / 4,
         )
     elif region == "southwest":
         pos = (
             center_x - multiplier * rect.width / 4,
             center_y + multiplier * rect.height / 4,
         )
     ctrl.mouse_move(*pos)
Esempio n. 3
0
 def mouse_move(directions: str):
     """Moves the mouse relative to the current position"""
     for d in directions.split(" "):
         [dx, dy] = d.split(",")
         dx, dy = int(dx), int(dy)
         x, y = ctrl.mouse_pos()
         print(f'current mouse pos: {x},{y}, move {dx},{dy}')
         ctrl.mouse_move(x + dx, y + dy)
Esempio n. 4
0
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_move(x, y)
    ctrl.mouse_click(pos=(x, y), button=button, times=times, wait=16000)
    time.sleep(0.032)
    eye_mouse.config.control_mouse = old
 def slack_close_right_sidebar():
     "close right sidebar"
     rect = ui.active_window().rect
     old_x, old_y = ctrl.mouse_pos()
     x = rect.width - 30
     ctrl.mouse_move(x, 123)
     ctrl.mouse_click()
     ctrl.mouse_move(old_x, old_y)
Esempio n. 6
0
 def mouse_cardinal_move_1d(direction: str, distance: int):
     """Move the mouse along a cardinal, e.g. 'move 1 left'"""
     x, y = ctrl.mouse_pos()
     horiz, pos = parse_cardinal(direction, distance)
     if horiz:
         x = pos
     else:
         y = pos
     ctrl.mouse_move(x, y)
Esempio n. 7
0
def mouse_go_away(m):
    if eye_mouse.config.control_mouse:
        eye_mouse.control_mouse.toggle()

    win = ui.active_window()
    rect = win.rect
    center = (rect.x + rect.width * 0.95, rect.y + rect.height / 4)
    print(rect, center)
    ctrl.mouse_move(*center)
Esempio n. 8
0
 def mouse_cardinal_move_2d(dir1: str, dist1: int, dir2: str, dist2: str):
     """Move the mouse along a 2d cardinal, e.g. 'move 1 left 2 up'"""
     horiz1, pos1 = parse_cardinal(dir1, dist1)
     horiz2, pos2 = parse_cardinal(dir2, dist2)
     if horiz1 == horiz2:
         raise ValueError('cannot move twice along the same axis')
     x, y = pos1, pos2
     if horiz2:
         y, x = x, y
     ctrl.mouse_move(x, y)
Esempio n. 9
0
 def narrow(self, which):
     self.save_state()
     row = int(which - 1) // 3
     col = int(which - 1) % 3
     self.offset_x += int(col * self.width // 3)
     self.offset_y += int(row * self.height // 3)
     self.width //= 3
     self.height //= 3
     ctrl.mouse_move(*self.pos())
     self.count += 1
     if self.count >= 4:
         self.reset(None)
Esempio n. 10
0
 def move_mouse_relative(direction: str, distance: int):
     """Moves mouse relative to current position"""
     pixels_to_travel = 50 * distance
     direction_vector = {
         'up': (0, -1),
         'right': (1, 0),
         'down': (0, 1),
         'left': (-1, 0)
     }[direction]
     (x, y) = ctrl.mouse_pos()
     ctrl.mouse_move(x + direction_vector[0] * pixels_to_travel,
                     y + direction_vector[1] * pixels_to_travel)
Esempio n. 11
0
    def draw(self, canvas):
        paint = canvas.paint
        paint.color = "ff00ff"
        paint.stroke_width = 5
        # print(paint.__dir__())
        now = time.time()
        pos = Point2d(self.radius, 0)
        pos.rot(self.angle)

        ctrl.mouse_move(pos.x, pos.y)
        canvas.draw_line(self.center_x, self.center_y, pos.x, pos.y)
        self.last_draw = now
Esempio n. 12
0
 def narrow(self, which, move=True):
     if which < 1 or which > 9:
         return
     self.save_state()
     rect = self.calc_narrow(which, self.rect)
     # check count so we don't bother zooming in _too_ far
     if self.count < 5:
         self.rect = rect.copy()
         self.count += 1
     if move:
         ctrl.mouse_move(*rect.center)
     self.mcanvas.freeze()
Esempio n. 13
0
def drag_window(win=None):
    if win is None:
        win = ui.active_window()
    fs = win.children.find(AXSubrole="AXFullScreenButton")[0]
    rect = fs.AXFrame["$rect2d"]
    x = rect["x"] + rect["width"] + 5
    y = rect["y"] + rect["height"] / 2
    ctrl.mouse_move(x, y)
    ctrl.mouse_click(button=0, down=True)
    yield
    time.sleep(0.1)
    ctrl.mouse_click(button=0, up=True)
Esempio n. 14
0
def do_fancy_drawing(m):
    x0, y0 = ctrl.mouse_pos()
    n = 1000
    amp = 50
    for i in range(n):
        t = (float(i) / float(n)) * 2 * math.pi
        x = x0 + amp * math.sin(1 * t) + amp * math.sin(
            3 * t) + amp * math.sin(5 * t)
        y = y0 + amp * math.cos(1 * t) + amp * math.cos(
            3 * t) + amp * math.cos(5 * t)
        ctrl.mouse_move(x, y)
        ctrl.mouse_click()
        time.sleep(0.01)
def left_right_click_southeast(m):
    win = ui.active_window()
    rect = win.rect
    center_x = rect.x + rect.width / 2
    center_y = rect.y + rect.height / 2
    multiplier = 1.7
    pos = (
        center_x + multiplier * rect.width / 4,
        center_y + multiplier * rect.height / 4,
    )
    ctrl.mouse_move(*pos)
    ctrl.mouse_click(button=0, times=1, wait=16000)
    ctrl.mouse_click(button=1, times=1, wait=16000)
def move_mouse_relative(m):
    direction_type = m._words[1].word
    pixels_to_travel = 50
    if pixels_to_travel == None:
        return
    direction_vector = {
        'up': (0, -1),
        'right': (1, 0),
        'down': (0, 1),
        'left': (-1, 0)
    }[direction_type]
    (x, y) = ctrl.mouse_pos()
    ctrl.mouse_move(x + direction_vector[0] * pixels_to_travel,
                    y + direction_vector[1] * pixels_to_travel)
Esempio n. 17
0
 def narrow(self, digits):
     self.save_state()
     # print(digits)
     row = int(digits[0]) * 10 + int(digits[1])
     col = int(digits[2]) * 10 + int(digits[3])
     # print(row, col)
     offset_x = self.offset_x + int(col * self.width // self.cols)
     offset_y = self.offset_y + int(row * self.height // self.rows)
     width = self.width // self.cols
     height = self.height // self.cols
     # print(offset_x + width//2, offset_y + height//2)
     ctrl.mouse_move(offset_x + width // 2, offset_y + height // 2)
     self.count += 1
     if self.count >= 2:
         self.reset(None)
Esempio n. 18
0
 def narrow(self, which, move=True):
     if which < 1 or which > 9:
         return
     self.save_state()
     self.offset_x, self.offset_y, self.width, self.height = self.calc_narrow(
         which, self.offset_x, self.offset_y, self.width, self.height)
     if move:
         ctrl.mouse_move(*self.pos())
     self.count += 1
     self.mcanvas.freeze()
     if self.count >= 2:
         self.wants_capture = 1
     # if self.count >= 4:
     # self.reset(None)
     self.mcanvas.freeze()
Esempio n. 19
0
def move_mouse_relative(m):
    direction_type = m._words[1].word
    multiplier = 100
    pixels_to_travel = parse_words_as_integer(m._words[2:]) * multiplier
    if pixels_to_travel == None:
        return
    direction_vector = {
        'up': (0, -1),
        'right': (1, 0),
        'down': (0, 1),
        'left': (-1, 0)
    }[direction_type]
    (x, y) = ctrl.mouse_pos()
    ctrl.mouse_move(x + direction_vector[0] * pixels_to_travel,
                    y + direction_vector[1] * pixels_to_travel)
Esempio n. 20
0
    def outliner_init(self):
        """Close all of the entries after opening the outliner.

        This assumes that the outliner has been configured to have all of the
        entries opened by default.

        """
        self.toggle_outliner()
        sleep(0.1)
        entries = self.outliner["entries"]
        for entry in entries.keys():
            print(entry)
            sleep(0.075)
            x, y = self.get_pos(entries, entry)
            ctrl.mouse_move(x, y)
            ctrl.mouse_click(button=0, hold=16000)
Esempio n. 21
0
def final_pos_click(m, button=0, times=1, down=None, up=None):
    old = eye_mouse.config.control_mouse
    eye_mouse.config.control_mouse = False
    x, y = get_final_mouse_pos(m)
    x_current, y_current = get_current_mouse_pos(m)
    ctrl.mouse_move(x, y)
    ctrl.mouse_click(pos=(x, y),
                     button=button,
                     down=down,
                     up=up,
                     times=times,
                     wait=800)
    ctrl.mouse_move(x_current, y_current)
    time.sleep(0.032)
    eye_mouse.config.control_mouse = old
    eye_mouse.mouse.last_move = 0
    eye_mouse.mouse.last_ctrl = Point2d(x_current, y_current)
Esempio n. 22
0
 def internal(m):
     cur_x, cur_y = ctrl.mouse_pos()
     region = regions[m._words[1]]
     if region == "west":
         pos = (cur_x - no_pixels_int, cur_y)
     elif region == "east":
         pos = (cur_x + no_pixels_int, cur_y)
     elif region == "north":
         pos = (cur_x, cur_y - no_pixels_int)
     elif region == "south":
         pos = (cur_x, cur_y + no_pixels_int)
     elif region == "northeast":
         pos = (cur_x + no_pixels_int, cur_y - no_pixels_int)
     elif region == "northwest":
         pos = (cur_x - no_pixels_int, cur_y - no_pixels_int)
     elif region == "southeast":
         pos = (cur_x + no_pixels_int, cur_y + no_pixels_int)
     elif region == "southwest":
         pos = (cur_x - no_pixels_int, cur_y + no_pixels_int)
     ctrl.mouse_move(*pos)
Esempio n. 23
0
    def draw(self, canvas):
        paint = canvas.paint
        paint.color = "ff00ff"
        paint.stroke_width = 5
        # print(paint.__dir__())
        now = time.time()
        elapsed = now - self.last_draw
        hiss_dt = now - self.hiss_start
        c = cos(self.angle)
        s = sin(self.angle)
        delta = Point2d(self.speed * c, self.speed * s)
        # print(delta)
        delta = delta.apply(self.accel, hiss_dt / 100)
        # print(delta)
        self.offset_x += delta.x
        if self.offset_x < 0:
            self.offset_x = 0
        elif self.offset_x > self.main_screen.width:
            self.offset_x = self.main_screen.width
        self.offset_y += delta.y
        if self.offset_y < 0:
            self.offset_y = 0
        elif self.offset_y > self.main_screen.height:
            self.offset_y = self.main_screen.height
        ctrl.mouse_move(self.offset_x, self.offset_y)
        line1 = self.rotate(c, s, 0, 0, -2 * SIZE, SIZE)
        line2 = self.rotate(c, s, 0, 0, -2 * SIZE, -SIZE)
        line3 = (line1[2], line1[3], line2[2], line2[3])

        canvas.draw_line(self.offset_x + line1[0], self.offset_y + line1[1],
                         self.offset_x + line1[2], self.offset_y + line1[3])
        canvas.draw_line(self.offset_x + line2[0], self.offset_y + line2[1],
                         self.offset_x + line2[2], self.offset_y + line2[3])
        canvas.draw_line(self.offset_x + line3[0], self.offset_y + line3[1],
                         self.offset_x + line3[2], self.offset_y + line3[3])
        self.last_draw = now
    def jump(self, spoken_letters, number=-1, compasspoint=None):
        if number == -1:
            number = self.default_superblock + 1
        base_rect = self.superblocks[number - 1].copy()
        base_rect.x += self.rect.x
        base_rect.y += self.rect.y
        spoken_letters = spoken_letters.upper()

        x_idx = letters.index(spoken_letters[1])
        y_idx = letters.index(spoken_letters[0])

        if compasspoint != None:
            index = direction_name_step.index(compasspoint)
            point = direction_vectors[index]

        else:
            point = Point2d(0, 0)

        ctrl.mouse_move(
            point.x + base_rect.x + x_idx * self.field_size +
            self.field_size / 2, point.y + base_rect.y +
            y_idx * self.field_size + self.field_size / 2)

        self.input_so_far = ""
Esempio n. 25
0
def move_to_ocr(m):
    old_pos = ctrl.mouse_pos()
    start = time.time()
    screen = ui.main_screen()
    factor = 1
    if (int(screen.width), int(screen.height)) == RETINA_SIZE:
        factor = RETINA_FACTOR
    midpoint = None
    bounds = [screen.x, screen.y, screen.width, screen.height]
    which = int(parse_word(m._words[1]))
    row = int(which - 1) // 3
    col = int(which - 1) % 3
    bounds = [
        screen.x + int(col * screen.width // 3),
        screen.y + int(row * screen.height // 3),
        screen.width // 3,
        screen.height // 3,
    ]
    midpoint = (bounds[0] + bounds[2] // 2, bounds[1] + bounds[3] // 2)
    print(which, row, col, bounds, midpoint)
    # noinspection PyProtectedMember
    search = join_words(list(map(parse_word, m.dgnwords[0]._words))).lower().strip()
    ctrl.mouse_move(*midpoint)
    print(f"Starting teleport {which} to {search}")
    hocr = ocr_screen(*bounds, factor=factor)
    print(f"... OCR'd screen: {time.time() - start} seconds.")
    tree = ElementTree.XML(hocr)  # type: list[ElementTree.Element]
    # print(list(tree[1]))
    best_pos = None
    best_distance = screen.width + screen.height
    for span in tree[1].iter():
        # print(span, span.attrib.get("class", ""))
        if span.attrib.get("class", "") == "ocrx_word":
            if search in span.text.lower():
                # title is something like"bbox 72 3366 164 3401; x_wconf 95"
                title = span.attrib["title"]  # type: str
                x, y, side, bottom = [
                    int(i) / (SCALE * factor) for i in title.split(";")[0].split()[1:]
                ]
                candidate = bounds[0] + (x + side) / 2, bounds[1] + (y + bottom) / 2
                dist = distance(candidate, midpoint)
                if dist < best_distance:
                    # print(search, span.text, span.attrib["title"])
                    best_pos = candidate
    if best_pos is not None:
        print(f"... Found match, moving to {best_pos}.  {time.time() - start} seconds.")
        ctrl.mouse_move(best_pos[0], best_pos[1])
        return
    print(f"... No match. {time.time() - start} seconds.")
    ctrl.mouse_move(*old_pos)
Esempio n. 26
0
def click():
    pos = smooth_location()
    ctrl.mouse_move(pos[0], pos[1])
    ctrl.mouse_click(button=0, hold=16000)
    last_click = time.time()
Esempio n. 27
0
 def mouse_move_center_active_window():
     """move the mouse cursor to the center of the currently active window"""
     rect = ui.active_window().rect
     ctrl.mouse_move(rect.left + (rect.width / 2),
                     rect.top + (rect.height / 2))
Esempio n. 28
0
def _set_cursor_pos(x, y):
    """Helper to set the cursor position."""
    # TODO: Special case for full screen move - use os-native maximize, rather
    #   than setting the position?

    ctrl.mouse_move(x, y)
Esempio n. 29
0
def mouse_center(m):
    win = ui.active_window()
    rect = win.rect
    center = (rect.x + rect.width / 2, rect.y + rect.height / 2)
    print(rect, center)
    ctrl.mouse_move(*center)
Esempio n. 30
0
 def mouse_move(x: int, y: int):
     ctrl.mouse_move(x, y)