From 4d3554de320c58b6442562dbf846e982e0cb282b Mon Sep 17 00:00:00 2001 From: simoschip2000 Date: Tue, 24 Jan 2023 17:24:11 +0100 Subject: [PATCH 1/2] Fix time.sleep without movement I had the problem that there was a time.sleep in the output script, even though the mouse was not moved. I moved the check, if there is enough mouse movement to the on_move function. Like this it should be cleaner and there is only a sleep if the mouse is really moving :) --- atbswp/control.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/atbswp/control.py b/atbswp/control.py index 6643990..0a5dfaa 100644 --- a/atbswp/control.py +++ b/atbswp/control.py @@ -182,21 +182,6 @@ def write_mouse_action(self, engine="pyautogui", move="", parameters=""): move -- the mouse movement (mouseDown, mouseUp, scroll, moveTo) parameters -- the details of the movement """ - def isinteger(s): - try: - int(s) - return True - except: - return False - - if move == "moveTo": - coordinates = [int(s) - for s in parameters.split(", ") if isinteger(s)] - if abs(coordinates[0] - self._lastx) < self.mouse_sensibility \ - and abs(coordinates[1] - self._lasty) < self.mouse_sensibility: - return - else: - self._lastx, self._lasty = coordinates self._capture.append(engine + "." + move + '(' + parameters + ')') def write_keyboard_action(self, engine="pyautogui", move="", key=""): @@ -219,6 +204,20 @@ def on_move(self, x, y): """Triggered by a mouse move.""" if not self.recording: return False + + def isinteger(s): + try: + int(s) + return True + except: + return False + + if abs(x - self._lastx) < self.mouse_sensibility \ + and abs(y - self._lasty) < self.mouse_sensibility: + return + else: + self._lastx, self._lasty = x,y + b = time.perf_counter() timeout = float(b - self.last_time) if timeout > 0.0: From ef2f06f976e2df281459ad3810ee068cc905b01e Mon Sep 17 00:00:00 2001 From: simoschip2000 Date: Tue, 24 Jan 2023 17:27:38 +0100 Subject: [PATCH 2/2] Update control.py --- atbswp/control.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/atbswp/control.py b/atbswp/control.py index 0a5dfaa..460a8b3 100644 --- a/atbswp/control.py +++ b/atbswp/control.py @@ -204,13 +204,6 @@ def on_move(self, x, y): """Triggered by a mouse move.""" if not self.recording: return False - - def isinteger(s): - try: - int(s) - return True - except: - return False if abs(x - self._lastx) < self.mouse_sensibility \ and abs(y - self._lasty) < self.mouse_sensibility: