|
5 | 5 |
|
6 | 6 | import pyautogui |
7 | 7 | from PIL import Image |
| 8 | +from pytweening import easeInOutQuad |
8 | 9 |
|
9 | 10 | from generalagents.action import ( |
10 | 11 | Action, |
|
24 | 25 |
|
25 | 26 | pyautogui.FAILSAFE = True # Move mouse to corner to abort |
26 | 27 | pyautogui.PAUSE = 0.001 # We are waiting manually in the code |
| 28 | +MOUSE_SETTINGS = {"duration": 0.101, "tween": easeInOutQuad} # duration <= 0.1 is treated as 0 by pyautogui |
27 | 29 |
|
28 | 30 |
|
29 | 31 | class Computer: |
@@ -62,19 +64,19 @@ def _execute_action(self, action: Action) -> None: |
62 | 64 | pyautogui.write(text) |
63 | 65 |
|
64 | 66 | case ActionLeftClick(kind="left_click", coordinate=coord): |
65 | | - pyautogui.click(*self._scaled(coord), button="left") |
| 67 | + pyautogui.click(*self._scaled(coord), button="left", **MOUSE_SETTINGS) |
66 | 68 |
|
67 | 69 | case ActionRightClick(kind="right_click", coordinate=coord): |
68 | | - pyautogui.click(*self._scaled(coord), button="right") |
| 70 | + pyautogui.click(*self._scaled(coord), button="right", **MOUSE_SETTINGS) |
69 | 71 |
|
70 | 72 | case ActionDoubleClick(kind="double_click", coordinate=coord): |
71 | | - pyautogui.doubleClick(*self._scaled(coord)) |
| 73 | + pyautogui.doubleClick(*self._scaled(coord), **MOUSE_SETTINGS) |
72 | 74 |
|
73 | 75 | case ActionTripleClick(kind="triple_click", coordinate=coord): |
74 | | - pyautogui.tripleClick(*self._scaled(coord)) |
| 76 | + pyautogui.tripleClick(*self._scaled(coord), **MOUSE_SETTINGS) |
75 | 77 |
|
76 | 78 | case ActionMouseMove(kind="mouse_move", coordinate=coord): |
77 | | - pyautogui.moveTo(*self._scaled(coord)) |
| 79 | + pyautogui.moveTo(*self._scaled(coord), **MOUSE_SETTINGS) |
78 | 80 |
|
79 | 81 | case ActionDrag(kind="drag", drag_start=start, drag_end=end): |
80 | 82 | pyautogui.moveTo(*self._scaled(start)) |
|
0 commit comments