-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathmouse.py
56 lines (37 loc) · 1.14 KB
/
mouse.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from win import get_cursor_pos, set_cursor_pos
def get_cases():
return [
jump_cursor_to_active_window,
move_cursor_left,
move_cursor_right,
move_cursor_up,
move_cursor_down,
]
def move_cursor_left(handler, mock_app):
x = get_cursor_pos()[0]
handler.send_command('h')
delta = x - get_cursor_pos()[0]
return delta > 0
def move_cursor_right(handler, mock_app):
x = get_cursor_pos()[0]
handler.send_command('l')
delta = get_cursor_pos()[0] - x
return delta > 0
def move_cursor_up(handler, mock_app):
y = get_cursor_pos()[1]
handler.send_command('k')
delta = y - get_cursor_pos()[1]
return delta > 0
def move_cursor_down(handler, mock_app):
y = get_cursor_pos()[1]
handler.send_command('j')
delta = get_cursor_pos()[1] - y
return delta > 0
def jump_cursor_to_active_window(handler, mock_app):
mock_app.focus()
cx, cy = mock_app.get_window_center()
width, height = mock_app.get_window_size()
set_cursor_pos(cx + width + 20, cy + height + 20)
handler.send_command('t')
x, y = get_cursor_pos()
return x == cx and y == cy