Skip to content

Commit 5345345

Browse files
jurgisppsarka
authored andcommitted
Scroll has coordinate
1 parent a1dd6eb commit 5345345

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/generalagents/action.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class ActionDrag:
105105
class ActionScroll:
106106
kind: Literal["scroll"]
107107
scroll_delta: int
108+
coordinate: Coordinate
108109

109110

110111
@dataclass

src/generalagents/macos/computer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ def _execute_action(self, action: Action) -> None:
7676
pyautogui.moveTo(*self._scaled(start))
7777
pyautogui.dragTo(*self._scaled(end), duration=0.5)
7878

79-
case ActionScroll(kind="scroll", scroll_delta=delta):
79+
case ActionScroll(kind="scroll", scroll_delta=delta, coordinate=coord):
80+
pyautogui.moveTo(*self._scaled(coord))
8081
pyautogui.scroll(float(delta * self.scale_factor))
8182

8283
case ActionWait(kind="wait"):

tests/test_structure.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ def test_structure():
6666
assert action == cattrs.structure(dict_, Action) # pyright: ignore [reportArgumentType]
6767

6868
# Test ActionScroll
69-
dict_ = {"kind": "scroll", "scroll_delta": -100}
70-
action = ActionScroll(kind="scroll", scroll_delta=-100)
69+
dict_ = {"kind": "scroll", "scroll_delta": -100, "coordinate": {"x": 100, "y": 200}}
70+
action = ActionScroll(kind="scroll", scroll_delta=-100, coordinate=Coordinate(x=100, y=200))
7171
assert action == cattrs.structure(dict_, Action) # pyright: ignore [reportArgumentType]
7272

7373
# Test ActionWait

0 commit comments

Comments
 (0)