Desktop Monitor
Overview
You can obtain monitor objects using the app.get_primary_monitor()
or app.get_all_monitors()
methods. Through these monitor objects, you can perform various functions and utilize several methods of the Monitor
object to query or modify the properties and states of the monitor.
Methods
capture(save_path: str, x: Optional[int] = None, y: Optional[int] = None, width: Optional[int] = None, height: Optional[int] = None)
capture(save_path: str, x: Optional[int] = None, y: Optional[int] = None, width: Optional[int] = None, height: Optional[int] = None)
Description: Captures the entire desktop screen.
Parameters:
save_path
(str): Path to save the captured image.x
,y
,width
,height
(int, optional): Coordinates and size of the area to capture.
Return Value: Returns the path of the saved image. Returns
None
if an error occurs.Example:
info() -> dict[str, Any]
info() -> dict[str, Any]
Description: Returns all information about the monitor.
Return Value: A dictionary containing all monitor information.
Example:
is_primary() -> bool
is_primary() -> bool
Description: Checks if the monitor is the primary monitor.
Return Value:
True
if it's the primary monitor,False
otherwise.Example:
size() -> dict[str, int]
size() -> dict[str, int]
Description: Returns the size of the monitor.
Return Value: A dictionary containing the width and height of the monitor.
Example:
geometry() -> dict[str, int]
geometry() -> dict[str, int]
Description: Returns the x, y, width, height information of the monitor.
Return Value: A dictionary containing the x, y, width, height information of the monitor.
Example:
available_geometry() -> dict[str, int]
available_geometry() -> dict[str, int]
Description: Returns the available x, y, width, height information of the monitor.
Return Value: A dictionary containing the x, y, width, height information of the monitor, excluding system UI elements.
Example:
available_size() -> dict[str, int]
available_size() -> dict[str, int]
Description: Returns the available size of the monitor.
Return Value: A dictionary containing the width and height of the monitor, excluding system UI elements.
Example:
virtual_geometry() -> dict[str, int]
virtual_geometry() -> dict[str, int]
Description: Returns the virtual x, y, width, height information of the monitor.
Return Value: A dictionary containing the combined x, y, width, height information of all monitors in a multi-monitor setup.
Example:
virtual_size() -> dict[str, int]
virtual_size() -> dict[str, int]
Description: Returns the virtual size of the monitor.
Return Value: A dictionary containing the combined width and height of all monitors in a multi-monitor setup.
Example:
available_virtual_geometry() -> dict[str, int]
available_virtual_geometry() -> dict[str, int]
Description: Returns the available virtual x, y, width, height information of the monitor.
Return Value: A dictionary containing the virtual x, y, width, height information, excluding system UI elements.
Example:
available_virtual_size() -> dict[str, int]
available_virtual_size() -> dict[str, int]
Description: Returns the available virtual size of the monitor.
Return Value: A dictionary containing the virtual size, excluding system UI elements.
Example:
physical_size() -> dict[str, float]
physical_size() -> dict[str, float]
Description: Returns the physical size of the monitor.
Return Value: A dictionary containing the actual physical width and height of the monitor.
Example:
depth() -> int
depth() -> int
Description: Returns the color depth of the monitor.
Return Value: The color depth of the monitor.
Example:
device_pixel_ratio() -> float
device_pixel_ratio() -> float
Description: Returns the device pixel ratio of the monitor.
Return Value: The device pixel ratio of the monitor.
Example:
logical_dots_per_inch() -> float
logical_dots_per_inch() -> float
Description: Returns the logical DPI of the monitor.
Return Value: The logical DPI of the monitor.
Example:
logical_dots_per_inch_x() -> float
logical_dots_per_inch_x() -> float
Description: Returns the logical DPI on the X-axis of the monitor.
Return Value: The logical DPI on the X-axis of the monitor.
Example:
logical_dots_per_inch_y() -> float
logical_dots_per_inch_y() -> float
Description: Returns the logical DPI on the Y-axis of the monitor.
Return Value: The logical DPI on the Y-axis of the monitor.
Example:
orientation() -> str
orientation() -> str
Description: Returns the orientation of the monitor.
Return Value: The orientation of the monitor.
Example:
physical_dots_per_inch() -> float
physical_dots_per_inch() -> float
Description: Returns the physical DPI of the monitor.
Return Value: The physical DPI of the monitor.
Example:
physical_dots_per_inch_x() -> float
physical_dots_per_inch_x() -> float
Description: Returns the physical DPI on the X-axis of the monitor.
Return Value: The physical DPI on the X-axis of the monitor.
Example:
physical_dots_per_inch_y() -> float
physical_dots_per_inch_y() -> float
Description: Returns the physical DPI on the Y-axis of the monitor.
Return Value: The physical DPI on the Y-axis of the monitor.
Example:
refresh_rate() -> float
refresh_rate() -> float
Description: Returns the refresh rate of the monitor.
Return Value: The refresh rate of the monitor.
Example:
manufacturer() -> str
manufacturer() -> str
Description: Returns the manufacturer of the monitor.
Return Value: The manufacturer of the monitor.
Example:
model() -> str
model() -> str
Description: Returns the model of the monitor.
Return Value: The model of the monitor.
Example:
name() -> str
name() -> str
Description: Returns the name of the monitor.
Return Value: The name of the monitor.
Example:
serial_number() -> str
serial_number() -> str
Description: Returns the serial number of the monitor.
Return Value: The serial number of the monitor.
Example:
geometry_changed(callback: Callable)
geometry_changed(callback: Callable)
Description: Registers a callback to be called when the monitor's geometry changes.
Parameters:
callback
(Callable): Function to be called when the geometry changes.
Example:
orientation_changed(callback: Callable)
orientation_changed(callback: Callable)
Description: Registers a callback to be called when the monitor's orientation changes.
Parameters:
callback
(Callable): Function to be called when the orientation changes.
Example:
refresh_rate_changed(callback: Callable)
refresh_rate_changed(callback: Callable)
Description: Registers a callback to be called when the monitor's refresh rate changes.
Parameters:
callback
(Callable): Function to be called when the refresh rate changes.
Example:
The Monitor
class provides various other methods for querying monitor properties. Each method returns a specific attribute of the monitor, and usage examples are similar to those shown above.
Last updated