Skip to content
Snippets Groups Projects
Commit 9006b7a3 authored by Vajay Mónika's avatar Vajay Mónika
Browse files

drag update

parent b98cf6be
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,7 @@ class Mouse:
self.move_distance = 10
self.scroll_distance = 10
self.time_checking = 0.5
self.stop_pos = None
def get_hand_pos(self, hand_pos):
self.hand_pos_x = hand_pos[0]
......@@ -63,6 +64,7 @@ class Mouse:
elif prediction == "stop moving":
pyautogui.move(0, 0) # Stop cursor
self.stop_pos = pyautogui.position()
elif prediction == "left click":
pyautogui.click() # Left click
elif prediction == "right click":
......@@ -81,6 +83,9 @@ class Mouse:
# THIS FUNCTION NOT WORKS ON WINDOWS
elif prediction == "drag":
pyautogui.mouseDown()
if self.previous_action == "stop moving":
pyautogui.moveTo(*self.stop_pos)
hand_x = np.clip(int(self.hand_pos_x*WIDTH), 0, WIDTH-1)
hand_y = np.clip(int(self.hand_pos_y*HEIGHT), 0, HEIGHT-1)
pyautogui.moveTo(hand_x, hand_y)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment