win_magnification
Aug 11, 2023
Author: MaxBQb | Microsoft Docs | Header
- class WinMagnificationAPI[source]
Bases:
object
Object-Oriented wrapper
for Magnification APIAlso managesinitialize()
andfinalize()
calls- property fullscreen: win_magnification._objects.FullscreenController
- property window: win_magnification._objects.CustomWindowController
- get_fullscreen_color_effect() types.ColorMatrix [source]
Retrieves the color transformation matrix associated with the full-screen magnifier.
- Returns
The color transformation matrix, or the identity matrix (
COLOR_NO_EFFECT
) if no color effect has been set.- Return type
- Raises
OSError – On fail
RuntimeError – On call from thead other than the first one, where
initialize()
was called
- set_fullscreen_color_effect(effect: types.ColorMatrix) None [source]
Changes the color transformation matrix associated with the full-screen magnifier.
- Parameters
effect (
ColorMatrix
) – The new color transformation matrix.- Raises
OSError – On fail
RuntimeError – On call from thead other than the first one, where
initialize()
was called
- set_fullscreen_transform(scale: float, offset: Tuple[int, int]) None [source]
Changes the magnification settings for the full-screen magnifier.
- Parameters
scale – The new magnification factor for the full-screen magnifier. 1.0 <= scale <= 4096.0. If this value is 1.0, the screen content is not magnified and no offsets are applied.
offset – The offset is relative to the upper-left corner of the primary monitor, in unmagnified coordinates. -262144 <= (x, y) <= 262144.
- Raises
OSError – On fail
RuntimeError – On call from thead other than the first one, where
initialize()
was called
- get_fullscreen_transform() types.FullscreenTransform [source]
Retrieves the magnification settings for the full-screen magnifier.
- Returns
Tuple of current magnification factor and offset
- Return type
FullscreenTransformRaw
- Raises
OSError – On fail
RuntimeError – On call from thead other than the first one, where
initialize()
was called
- get_color_effect(hwnd: int) types.ColorMatrix [source]
Gets the color transformation matrix for a magnifier control.
- Parameters
hwnd – The handle of the magnification window.
- Returns
Current color transformation matrix.
- Return type
- Raises
OSError – On fail
- set_color_effect(hwnd: int, effect: Optional[types.ColorMatrix]) None [source]
Sets the color transformation matrix for a magnifier control.
- Parameters
hwnd – The handle of the magnification window.
effect (
ColorMatrix
) – The color transformation matrix, or None to remove the current color effect, if any.
- Raises
OSError – On fail
- set_source(hwnd: int, rectangle: types.Rectangle) None [source]
Sets the source rectangle for the magnification window.
- Parameters
hwnd – The handle of the magnification window.
rectangle (
RectangleRaw
) – Magnification rectangle
- Raises
OSError – On fail
- get_source(hwnd: int) types.Rectangle [source]
Gets the rectangle of the area that is being magnified.
- Parameters
hwnd – The handle of the magnification window.
- Returns
Magnification rectangle
- Return type
RectangleRaw
- Raises
OSError – On fail
- set_filters(root_hwnd: int, *hwnds: int, exclude=True) None [source]
- Sets the list of windows to be magnified or the list of windows to be excluded from magnification.The magnification filter mode can be one of the following values:exclude = False |=> INCLUDE (This value is not supported on Windows 7 or newer).exclude = True |=> EXCLUDE (Magnifier acts as windows from list aren’t exist at all)
- Parameters
root_hwnd – The handle of the magnification window.
exclude – The magnification filter mode.
hwnds – List of window handles.
- Raises
OSError – On fail
- get_filters(hwnd: int) Tuple[bool, Tuple[int]] [source]
Retrieves the list of windows that are magnified or excluded from magnification.
- Parameters
hwnd – The handle of the magnification window.
- Returns
The filter mode and the list of window handles.
- Raises
OSError – On fail
RuntimeError – On invalid hwnd used
- get_input_transform() types.InputTransform [source]
Retrieves the current input transformation for pen and touch input, represented as a source rectangle and a destination rectangle.
- Returns
Tuple of is_enabled, source and destination
- Return type
InputTransformRaw
- Raises
OSError – On fail
- set_input_transform(is_enabled: bool, source: types.Rectangle, destination: types.Rectangle) None [source]
- Sets the current active input transformation for pen and touch input, represented as a source rectangle and a destination rectangle.Requires the calling process to have UIAccess privileges.
- Parameters
is_enabled – True to enable input transformation, or False to disable it.
source (
RectangleRaw
) – The new source rectangle, in unmagnified screen coordinates, that defines the area of the screen to magnify. This parameter is ignored if is_enabled is False.destination (
RectangleRaw
) – The new destination rectangle, in unmagnified screen coordinates, that defines the area of the screen where the magnified screen content is displayed. Pen and touch input in this rectangle is mapped to the source rectangle. This parameter is ignored if is_enabled is False.
- Raises
OSError – On fail
- set_cursor_visibility(show_cursor: bool)[source]
Shows or hides the system cursor.
Note
Invisibility applies until cursor moves
- Parameters
show_cursor – True to show the system cursor, or False to hide it.
- Raises
OSError – On fail
- finalize() None [source]
Destroys the magnifier run-time objects.
- Raises
OSError – On fail
RuntimeError – If
initialize()
never calledRuntimeError – On call from thead other than the first one, where
initialize()
was called
- get_transform(hwnd: int) types.SimpleTransform [source]
Use to get the magnification transformation (scale, offset) on the window provided by the window handle Offset counts from left-upper corner of magnification window
- Parameters
hwnd – The handle of the magnification window.
- Returns
Tuple of scale (x, y) and offset (x, y)
- Raises
OSError – On fail
- get_transform_advanced(hwnd: int) types.TransformationMatrix [source]
Use to get the magnification transformation matrix on the window provided by the window handle
- Parameters
hwnd – The handle of the magnification window.
- Returns
A 3x3 matrix of the magnification transformation.
- Return type
- Raises
OSError – On fail
- initialize() None [source]
Creates and initializes the magnifier run-time objects.
- Raises
OSError – On fail
RuntimeError – On call from thead other than the first one, where
initialize()
was called
- reset_color_effect(hwnd: int)[source]
Resets the color transformation matrix for a magnifier control.
- Parameters
hwnd – The handle of the magnification window.
- Raises
OSError – On fail
- reset_fullscreen_color_effect()[source]
Resets the color transformation matrix associated with the full-screen magnifier.
- Raises
OSError – On fail
- reset_fullscreen_transform()[source]
Resets the magnification settings for the full-screen magnifier.
- Raises
OSError – On fail
- reset_transform(hwnd: int)[source]
Resets the transformation matrix for a magnifier control.
- Parameters
hwnd – The handle of the magnification window.
- Raises
OSError – On fail
- set_transform(hwnd: int, scale: Union[float, Tuple[float, float]], offset: Union[float, Tuple[float, float]] = 0.0)[source]
Sets the transformation matrix for a magnifier control.
- Parameters
hwnd – The handle of the magnification window.
scale – Magnification factor, or it’s separate x, y components
offset – Magnifier offset from left upper corner
- Raises
OSError – On fail
- set_transform_advanced(hwnd: int, matrix: types.TransformationMatrix) None [source]
Sets the transformation matrix for a magnifier control.
- Parameters
hwnd – The handle of the magnification window.
matrix (
TransformationMatrix
) – A 3x3 matrix of the magnification transformation
- Raises
OSError – On fail
- to_simple_transform(matrix: types.TransformationMatrix) types.SimpleTransform [source]
Get (scale, offset) tuple from matrix
>>> to_simple_transform(tools.get_transform_matrix(1.0, 2.0, 3.0, 4.0)) ((1.0, 2.0), (3.0, 4.0))
- Parameters
matrix – Raw transform matrix
- Returns
(scale, offset)
- Raises
OSError – On fail