Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions ufo/automator/ui_control/screenshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,17 @@ def __init__(self, control: UIAWrapper):
"""
self.control = control

def capture(self, save_path: str = None, scalar: List[int] = None) -> Image.Image:
def capture(self, save_path: str = None, scalar: List[int] = None) -> Optional[Image.Image]:
"""
Capture a screenshot.
:param save_path: The path to save the screenshot.
:return: The screenshot.
:param scalar: Optional rescale dimensions [width, height].
:return: The screenshot, or None if the control is unavailable.
"""
if self.control is None:
logger.warning("Cannot capture screenshot: control element is None.")
return None

# Capture single window screenshot
screenshot = self.control.capture_as_image()
if scalar is not None:
Expand Down