Skip to content

Commit d6ea2db

Browse files
authored
add list_windows computer action (#80)
1 parent 7000246 commit d6ea2db

5 files changed

Lines changed: 59 additions & 2 deletions

File tree

hyperbrowser/client/managers/async_manager/computer_action.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
ComputerActionMouseButton,
1919
GetClipboardTextActionParams,
2020
PutSelectionTextActionParams,
21+
ListWindowsActionParams,
2122
)
2223

2324

@@ -175,3 +176,11 @@ async def put_selection_text(
175176
text=text, return_screenshot=return_screenshot
176177
)
177178
return await self._execute_request(session, params)
179+
180+
async def list_windows(
181+
self,
182+
session: Union[SessionDetail, str],
183+
return_screenshot: bool = False,
184+
) -> ComputerActionResponse:
185+
params = ListWindowsActionParams(return_screenshot=return_screenshot)
186+
return await self._execute_request(session, params)

hyperbrowser/client/managers/sync_manager/computer_action.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
ComputerActionMouseButton,
1919
GetClipboardTextActionParams,
2020
PutSelectionTextActionParams,
21+
ListWindowsActionParams,
2122
)
2223

2324

@@ -175,3 +176,11 @@ def put_selection_text(
175176
text=text, return_screenshot=return_screenshot
176177
)
177178
return self._execute_request(session, params)
179+
180+
def list_windows(
181+
self,
182+
session: Union[SessionDetail, str],
183+
return_screenshot: bool = False,
184+
) -> ComputerActionResponse:
185+
params = ListWindowsActionParams(return_screenshot=return_screenshot)
186+
return self._execute_request(session, params)

hyperbrowser/models/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,10 @@
233233
ComputerActionMouseButton,
234234
GetClipboardTextActionParams,
235235
PutSelectionTextActionParams,
236+
ListWindowsActionParams,
237+
ComputerActionWindow,
236238
ComputerActionResponseDataClipboardText,
239+
ComputerActionResponseDataListWindows,
237240
ComputerActionResponseData,
238241
)
239242
from .session import (
@@ -628,7 +631,10 @@
628631
"ComputerActionMouseButton",
629632
"GetClipboardTextActionParams",
630633
"PutSelectionTextActionParams",
634+
"ListWindowsActionParams",
635+
"ComputerActionWindow",
631636
"ComputerActionResponseDataClipboardText",
637+
"ComputerActionResponseDataListWindows",
632638
"ComputerActionResponseData",
633639
# web
634640
"StartBatchFetchJobParams",

hyperbrowser/models/computer_action.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class ComputerAction(str, Enum):
1818
TYPE_TEXT = "type_text"
1919
GET_CLIPBOARD_TEXT = "get_clipboard_text"
2020
PUT_SELECTION_TEXT = "put_selection_text"
21+
LIST_WINDOWS = "list_windows"
2122

2223

2324
ComputerActionMouseButton = Literal[
@@ -183,6 +184,17 @@ class PutSelectionTextActionParams(BaseModel):
183184
)
184185

185186

187+
class ListWindowsActionParams(BaseModel):
188+
"""Parameters for list windows action."""
189+
190+
model_config = ConfigDict(use_enum_values=True)
191+
192+
action: Literal[ComputerAction.LIST_WINDOWS] = ComputerAction.LIST_WINDOWS
193+
return_screenshot: bool = Field(
194+
serialization_alias="returnScreenshot", default=False
195+
)
196+
197+
186198
ComputerActionParams = Union[
187199
ClickActionParams,
188200
DragActionParams,
@@ -196,6 +208,7 @@ class PutSelectionTextActionParams(BaseModel):
196208
MouseUpActionParams,
197209
GetClipboardTextActionParams,
198210
PutSelectionTextActionParams,
211+
ListWindowsActionParams,
199212
]
200213

201214

@@ -207,7 +220,27 @@ class ComputerActionResponseDataClipboardText(BaseModel):
207220
clipboard_text: Optional[str] = Field(default=None, alias="clipboardText")
208221

209222

210-
ComputerActionResponseData = Union[ComputerActionResponseDataClipboardText]
223+
class ComputerActionWindow(BaseModel):
224+
model_config = ConfigDict(populate_by_alias=True)
225+
226+
id: str
227+
name: str
228+
active: bool
229+
230+
231+
class ComputerActionResponseDataListWindows(BaseModel):
232+
"""Data for list windows action."""
233+
234+
model_config = ConfigDict(populate_by_alias=True)
235+
236+
active_window_id: str = Field(default="", alias="activeWindowId")
237+
windows: List[ComputerActionWindow] = Field(default_factory=list)
238+
239+
240+
ComputerActionResponseData = Union[
241+
ComputerActionResponseDataListWindows,
242+
ComputerActionResponseDataClipboardText,
243+
]
211244

212245

213246
class ComputerActionResponse(BaseModel):

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "hyperbrowser"
3-
version = "0.90.7"
3+
version = "0.90.8"
44
description = "Python SDK for hyperbrowser"
55
authors = ["Nikhil Shahi <nshahi1998@gmail.com>"]
66
license = "MIT"

0 commit comments

Comments
 (0)