How do I get hwnd of a Window? #324
-
I tried from ahk import AHK
import pywinctl as pwc
from ahk.directives import NoTrayIcon
import pygetwindow as gw
import ctypes
from ctypes import wintypes
ahk = AHK(
executable_path="C:\\Users\\trajano\\AppData\\Local\\Programs\\AutoHotkey\\v2\\AutoHotkey64.exe",
version="v2",
directives=[NoTrayIcon(apply_to_hotkeys_process=True)],
)
one_note_ahk_title = "ahk_exe ONENOTE.EXE"
user32 = ctypes.WinDLL('user32', use_last_error=True)
window =ahk.win_get(one_note_ahk_title)
result = list(map(lambda it: it._hWnd, pwc.getAllWindows()))
print(result)
print(window.id)
entry = window.id
if entry in result:
print(f"{entry} is in the list.")
else:
print(f"{entry} is not in the list.") Attempting to use if not user32.MoveWindow(window.id, x, y, 1920, 2100, True):
raise ctypes.WinError(ctypes.get_last_error()) results in
|
Beta Was this translation helpful? Give feedback.
Answered by
spyoungtech
Jun 28, 2024
Replies: 1 comment 5 replies
-
The |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
They are the same:
For use with ctypes, you have to convert the type first: