diff --git a/control_mouse.py b/control_mouse.py index 3657c8f15d47ef767069259235774b953c27ce3c..45aad11b600fe33d747ea60a3e37f16aafa00ffb 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)