refactor: remove redundant native control checks from window and UI element tools
Some checks failed
CI / test (push) Failing after 9s

This commit is contained in:
Space-Banane
2026-05-31 21:46:37 +02:00
parent f0058d1057
commit 2495b6d62f

View File

@@ -2878,10 +2878,6 @@ class ScreenJobAgent:
}
def _tool_list_windows(self, args: dict[str, Any]) -> dict[str, Any]:
if not self._native_control_tools_enabled():
return self._native_control_unavailable_result(
message="Native window enumeration is disabled for this run.",
)
visible_only = bool(args.get("visible_only", True))
windows = self._list_windows_info(visible_only=visible_only)
active = self._get_active_window_info()
@@ -2897,10 +2893,6 @@ class ScreenJobAgent:
return result
def _tool_find_window(self, args: dict[str, Any]) -> dict[str, Any]:
if not self._native_control_tools_enabled():
return self._native_control_unavailable_result(
message="Native window lookup is disabled for this run.",
)
window = self._find_window_info(
hwnd=self._parse_int(args.get("hwnd"), default=0),
title_contains=str(args.get("title_contains") or ""),
@@ -2938,10 +2930,6 @@ class ScreenJobAgent:
return result
def _tool_focus_window(self, args: dict[str, Any]) -> dict[str, Any]:
if not self._native_control_tools_enabled():
return self._native_control_unavailable_result(
message="Native window focusing is disabled for this run.",
)
window = self._find_window_info(
hwnd=self._parse_int(args.get("hwnd"), default=0),
title_contains=str(args.get("title_contains") or ""),
@@ -3009,10 +2997,6 @@ class ScreenJobAgent:
return result
def _tool_close_window(self, args: dict[str, Any]) -> dict[str, Any]:
if not self._native_control_tools_enabled():
return self._native_control_unavailable_result(
message="Native window closing is disabled for this run.",
)
window = self._find_window_info(
hwnd=self._parse_int(args.get("hwnd"), default=0),
title_contains=str(args.get("title_contains") or ""),
@@ -3036,10 +3020,6 @@ class ScreenJobAgent:
return result
def _tool_wait_for_window(self, args: dict[str, Any]) -> dict[str, Any]:
if not self._native_control_tools_enabled():
return self._native_control_unavailable_result(
message="Native window waits are disabled for this run.",
)
timeout_seconds = self._parse_seconds(
args.get("timeout_seconds"),
default=self.options.dialog_timeout_seconds,
@@ -3188,10 +3168,6 @@ class ScreenJobAgent:
return result
def _tool_dialog_action(self, args: dict[str, Any]) -> dict[str, Any]:
if not self._native_control_tools_enabled():
return self._native_control_unavailable_result(
message="Native dialog actions are disabled for this run.",
)
action = str(args.get("action") or "").strip().lower()
dialog = self._find_dialog_info()
if self._parse_int(args.get("hwnd"), default=0):
@@ -3243,10 +3219,6 @@ class ScreenJobAgent:
return result
def _tool_dialog_set_filename(self, args: dict[str, Any]) -> dict[str, Any]:
if not self._native_control_tools_enabled():
return self._native_control_unavailable_result(
message="Native dialog filename entry is disabled for this run.",
)
filename = str(args.get("filename") or "")
if not filename:
return {"ok": False, "error": "Missing filename."}
@@ -3289,10 +3261,6 @@ class ScreenJobAgent:
return result
def _tool_wait_for_dialog_close(self, args: dict[str, Any]) -> dict[str, Any]:
if not self._native_control_tools_enabled():
return self._native_control_unavailable_result(
message="Native dialog waits are disabled for this run.",
)
hwnd = self._parse_int(args.get("hwnd"), default=0)
timeout_seconds = self._parse_seconds(
args.get("timeout_seconds"),
@@ -3336,10 +3304,6 @@ class ScreenJobAgent:
return self._get_active_window_info()
def _tool_list_ui_elements(self, args: dict[str, Any]) -> dict[str, Any]:
if not self._native_control_tools_enabled():
return self._native_control_unavailable_result(
message="Native UI element listing is disabled for this run.",
)
window = self._resolve_ui_scope_window(args)
if window is None or not bool(window.get("available")):
return {"ok": False, "error": "No target window available for list_ui_elements."}
@@ -3375,10 +3339,6 @@ class ScreenJobAgent:
return result
def _tool_invoke_ui_element(self, args: dict[str, Any]) -> dict[str, Any]:
if not self._native_control_tools_enabled():
return self._native_control_unavailable_result(
message="Native UI element invocation is disabled for this run.",
)
element = args.get("element") if isinstance(args.get("element"), dict) else {}
handle = self._resolve_target_handle(element)
if not handle:
@@ -3398,10 +3358,6 @@ class ScreenJobAgent:
return result
def _tool_set_ui_element_value(self, args: dict[str, Any]) -> dict[str, Any]:
if not self._native_control_tools_enabled():
return self._native_control_unavailable_result(
message="Native UI element value setting is disabled for this run.",
)
element = args.get("element") if isinstance(args.get("element"), dict) else {}
handle = self._resolve_target_handle(element)
text = str(args.get("text") or "")
@@ -3423,10 +3379,6 @@ class ScreenJobAgent:
return result
def _tool_select_ui_element(self, args: dict[str, Any]) -> dict[str, Any]:
if not self._native_control_tools_enabled():
return self._native_control_unavailable_result(
message="Native UI element selection is disabled for this run.",
)
self._require_windows()
user32 = ctypes.windll.user32
element = args.get("element") if isinstance(args.get("element"), dict) else {}
@@ -3473,10 +3425,6 @@ class ScreenJobAgent:
return result
def _tool_wait_for_ui_element(self, args: dict[str, Any]) -> dict[str, Any]:
if not self._native_control_tools_enabled():
return self._native_control_unavailable_result(
message="Native UI element waits are disabled for this run.",
)
timeout_seconds = self._parse_seconds(
args.get("timeout_seconds"),
default=self.options.ui_element_timeout_seconds,