Get HWND of each Window?

You mixed up ctypes and win32gui.
The hwnd you’ve got is obtained via ctypes and is a LP_c_long object. That’s why win32gui.MoveWindow didn’t accept it. You should pass it to

ctypes.windll.user32.MoveWindow(titles[5][0], 0, 0, 760, 500, True)

If you want to use win32gui.MoveWindow, you can use python function as callback directly.
For example,

import win32gui

def enumHandler(hwnd, lParam):
    if win32gui.IsWindowVisible(hwnd):
        if 'Stack Overflow' in win32gui.GetWindowText(hwnd):
            win32gui.MoveWindow(hwnd, 0, 0, 760, 500, True)

win32gui.EnumWindows(enumHandler, None)

Leave a Comment