-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmouse_controller.py
24 lines (20 loc) · 944 Bytes
/
mouse_controller.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
'''
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':0.01, '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)
def move_abs(self,x,y):
pyautogui.moveTo(x,y)