Skip to content

[Windows] win.rect assignment support #131

@knausj85

Description

@knausj85

Currently, the below is not yet implemented on Windows -

ui.active_window().rect = (0, 0, 500, 500)

2020-08-28 01:27:43 ERROR     9: talon\scripting\talon_script.py:431|
    8: talon\scripting\talon_script.py:210|
    7: talon\scripting\talon_script.py:398|
    6:      talon\scripting\actions.py:56 |
    5: -----------------------------------# cron thread
    4:        talon\scripting\types.py:304|
    3: user\knausj_talon\code\mouse.py:201| ui.active_window().rect = (0, 0, 500, ..
    2: -----------------------------------# 'cron' talon_plugins.engines.dragon:<lambda>()
    1:             talon\windows\ui.py:200|
NotImplementedError

Testing around the various options, GetWindowPlacement() & SetWindowPlacement() appear to be the ticket.

Example:

        win = ui.active_window()
        window_placement = win32gui.GetWindowPlacement(win.id)
        win32gui.SetWindowPlacement(
            win.id,
            (
                # flags - WPF_ASYNCWINDOWPLACEMENT
                0x0004,
                # showCmd - SW_RESTORE to actually force the resize
                win32con.SW_RESTORE,
                # POINT ptMinPosition - maintain the minimized position
                window_placement[2],
                # POINT ptMaxPosition - maintain the maximized position
                window_placement[3],
                # RECT  rcNormalPosition - the 'restored' position
                (8, 0, 500, 500),
            ),
        )

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions