Skip to content

How do I get hwnd of a Window? #324

Answered by spyoungtech
trajano asked this question in Q&A
Discussion options

You must be logged in to vote

They are the same:

>>> from ahk import AHK
>>> ahk = AHK(version='v2')
>>> import ctypes
>>> user32 = ctypes.windll.user32
>>> handle = user32.FindWindowW(None, u'Untitled - Notepad')
>>> print(handle)
40373466
>>> win = ahk.win_get(title='Untitled - Notepad')
>>> print(win.id)
40373466

For use with ctypes, you have to convert the type first:

success = user32.MoveWindow(int(window.id), x, y, 1920, 2100, True)

Replies: 1 comment 5 replies

Comment options

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

@spyoungtech
Comment options

Answer selected by trajano
@trajano
Comment options

@spyoungtech
Comment options

@trajano
Comment options

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