Capturing & Video
Screen/element capture and video recording, ported from FlaUI.Core.Capturing. Capture
provides static helpers that return a CaptureImage (savable via to_file and usable as a
context manager). VideoRecorder records the screen to a file and requires ffmpeg
(see VideoRecorder.download_ffmpeg).
flaui.core.capturing.Capture
Static screen/element capture helpers (mirrors FlaUI.Core.Capturing.Capture).
element(element, settings=None)
staticmethod
Capture a single automation element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
element
|
'AutomationElement'
|
The element to capture. |
required |
settings
|
Optional[CaptureSettings]
|
Optional output sizing settings. |
None
|
Returns:
| Type | Description |
|---|---|
CaptureImage
|
The captured image. |
Source code in flaui/core/capturing.py
element_rectangle(element, rectangle, settings=None)
staticmethod
Capture a rectangle (relative to the element) inside an element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
element
|
'AutomationElement'
|
The element whose region to capture. |
required |
rectangle
|
Rectangle
|
The rectangle relative to the element's top-left corner. |
required |
settings
|
Optional[CaptureSettings]
|
Optional output sizing settings. |
None
|
Returns:
| Type | Description |
|---|---|
CaptureImage
|
The captured image. |
Source code in flaui/core/capturing.py
main_screen(settings=None)
staticmethod
Capture the primary screen.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
Optional[CaptureSettings]
|
Optional output sizing settings. |
None
|
Returns:
| Type | Description |
|---|---|
CaptureImage
|
The captured image. |
Source code in flaui/core/capturing.py
rectangle(bounds, settings=None)
staticmethod
Capture a desktop-relative rectangle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bounds
|
Rectangle
|
The screen region to capture. |
required |
settings
|
Optional[CaptureSettings]
|
Optional output sizing settings. |
None
|
Returns:
| Type | Description |
|---|---|
CaptureImage
|
The captured image. |
Source code in flaui/core/capturing.py
screen(screen_index=-1, settings=None)
staticmethod
Capture a screen (or the whole virtual desktop when screen_index is out of range).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
screen_index
|
int
|
Zero-based monitor index; |
-1
|
settings
|
Optional[CaptureSettings]
|
Optional output sizing settings. |
None
|
Returns:
| Type | Description |
|---|---|
CaptureImage
|
The captured image. |
Source code in flaui/core/capturing.py
screens_with_element(element, settings=None)
staticmethod
Capture every screen the given element overlaps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
element
|
'AutomationElement'
|
The element to locate across screens. |
required |
settings
|
Optional[CaptureSettings]
|
Optional output sizing settings. |
None
|
Returns:
| Type | Description |
|---|---|
CaptureImage
|
The captured image. |
Source code in flaui/core/capturing.py
flaui.core.capturing.CaptureImage
Bases: BaseModel
A captured image (mirrors FlaUI.Core.Capturing.CaptureImage).
Wraps the C# result of a :class:Capture call. Use :meth:to_file to persist it, or use it as a
context manager to dispose the underlying bitmap automatically.
bitmap
property
Return the underlying C# Bitmap.
original_bounds
property
Return the desktop-relative bounding rectangle this image was captured from.
__enter__()
__exit__(*exc_info)
Dispose the image on context-manager exit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exc_info
|
Any
|
Standard |
()
|
apply_overlays(*overlays)
Draw the given C# ICaptureOverlay objects onto the image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
overlays
|
Any
|
Raw C# overlay instances (e.g. |
()
|
Returns:
| Type | Description |
|---|---|
'CaptureImage'
|
This :class: |
Source code in flaui/core/capturing.py
dispose()
to_file(file_path)
Save the image to a file; the extension selects the format (defaults to PNG).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Destination path ( |
required |
Source code in flaui/core/capturing.py
flaui.core.capturing.CaptureSettings
Bases: BaseModel
Output sizing options for a capture (mirrors FlaUI.Core.Capturing.CaptureSettings).
cs_object
property
Return the underlying C# CaptureSettings built from this model.
flaui.core.capturing.VideoRecorder
Bases: BaseModel
Records the screen (or a custom frame source) to a video file.
Mirrors FlaUI.Core.Capturing.VideoRecorder. Start a recording with :meth:start, then call
:meth:stop (or use it as a context manager). Requires ffmpeg — see the module note.
target_video_path
property
Return the output video file path.
__enter__()
__exit__(*exc_info)
Stop and dispose the recorder on context-manager exit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exc_info
|
Any
|
Standard |
()
|
dispose()
download_ffmpeg(target_folder)
staticmethod
Download a static ffmpeg build into target_folder (blocking).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_folder
|
str
|
Folder to download ffmpeg into. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The path to the downloaded ffmpeg executable. |
Source code in flaui/core/capturing.py
start(settings, capture_method=None)
classmethod
Start recording.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
VideoRecorderSettings
|
Recorder settings (must include |
required |
capture_method
|
Optional[Callable[['VideoRecorder'], CaptureImage]]
|
Optional callback |
None
|
Returns:
| Type | Description |
|---|---|
'VideoRecorder'
|
The running :class: |
Source code in flaui/core/capturing.py
flaui.core.capturing.VideoRecorderSettings
Bases: BaseModel
Settings for :class:VideoRecorder (mirrors FlaUI.Core.Capturing.VideoRecorderSettings).
cs_object
property
Return the underlying C# VideoRecorderSettings built from this model.
flaui.core.capturing.VideoFormat
Bases: Enum
Video codec used by :class:VideoRecorder (mirrors FlaUI.Core.Capturing.VideoFormat).