I run this code and get a list of all windows in return.
def winEnumHandler(hwnd, ctx):
if win32gui.IsWindowVisible(hwnd):
# print(hex(hwnd), win32gui.GetWindowText(hwnd))
print(
"{:} - [{:}] - {:}".format(hex(hwnd), win32gui.GetWindowText(hwnd),
hex(win32gui.GetWindowLong(hwnd,
win32con.GWL_EXSTYLE))))
Result: 0x306be - [Calculator] - 0x200100
Now I am trying to run:
window = win32gui.FindWindow(None, 0x306be)
It doesn't find it by the hex value. Is there a way to use 0x306be or 0x200100 to find the window? I have A few windows with the same name and I am not sure how to make it find the correct one besides using one of those values.
You got 0x306be by converting the integer inside hwnd to a hex value, which win32gui.findWindow() cannot read. It can however read an integer so you can use hwnd instead.
window = win32gui.FindWindow(None, hwnd)