From 9006b7a32d99cd9a4560b023108dccc0011f732d Mon Sep 17 00:00:00 2001
From: Moni <vajay.monika@hallgato.ppke.hu>
Date: Sun, 10 Nov 2024 12:45:46 +0100
Subject: [PATCH] drag update

---
 control_mouse.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/control_mouse.py b/control_mouse.py
index 3657c8f..45aad11 100644
--- a/control_mouse.py
+++ b/control_mouse.py
@@ -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)
-- 
GitLab