-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmouse_controller.py
More file actions
21 lines (18 loc) · 882 Bytes
/
mouse_controller.py
File metadata and controls
21 lines (18 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'''
This is a sample class that you can use to control the mouse pointer.
It uses the pyautogui library. You can set the precision for mouse movement
(how much the mouse moves) and the speed (how fast it moves) by changing
precision_dict and speed_dict.
Calling the move function with the x and y output of the gaze estimation model
will move the pointer.
This class is provided to help get you started; you can choose whether you want to use it or create your own from scratch.
'''
import pyautogui
class MouseController:
def __init__(self, precision, speed):
precision_dict={'high':100, 'low':1000, 'medium':500}
speed_dict={'fast':1, 'slow':10, 'medium':5}
self.precision=precision_dict[precision]
self.speed=speed_dict[speed]
def move(self, x, y):
pyautogui.moveRel(x*self.precision, -1*y*self.precision, duration=self.speed)