Skip to content

ahk.win_move to another monitor #322

Answered by trajano
trajano asked this question in Q&A
Jun 27, 2024 · 2 comments · 2 replies
Discussion options

You must be logged in to vote

I used the screeninfo library and the raw Win32 API to move the window

import screeninfo
import ctypes
from ctypes import wintypes

user32 = ctypes.WinDLL('user32', use_last_error=True)

def monitor_xy(x: int, y: int, monitor=0) -> tuple[int, int]:
    monitors = screeninfo.get_monitors()
    if monitor >= len(monitors):
        raise ValueError(
            f"Monitor index {monitor} is out of range. There are only {len(monitors)} monitors."
        )
    return (x + monitors[monitor].x, y + monitors[monitor].y)

def one_note() -> None:
    one_note_ahk_title = "ahk_exe ONENOTE.EXE"
    (x, y) = monitor_xy(0, 0, monitor=1)
    window =ahk.win_get(one_note_ahk_title)
        
    if not us…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@trajano
Comment options

@spyoungtech
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by trajano
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants