I am playing with python ctypes to control clicking through windows and menus and ran into an issue where I can click a button in a window and the windows contents change, yet I can't find a way to detect this change.
I used WinSpy to see if anything changes and noticed the ClassNN value increases, from #327701 to #327703.
Using the Windows API, how would I go about getting this information from a window?
EDIT: I have tried the following code, yet the information I find is inconclusive. The ClassName for example returns '??stBox' or '??2770' or even '????\x01'.
def get_window_class_information(handle, class_name):
WNDPROC = ctypes.WINFUNCTYPE(ctypes.c_long, ctypes.c_long, ctypes.c_long, ctypes.c_long, ctypes.c_long)
class WNDCLASSEXW(ctypes.Structure):
""" https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowinfo """
_fields_ = [('Size', ctypes.c_ulong),
('Style', ctypes.c_ulong),
('Procedure', WNDPROC),
('ClassExtra', ctypes.c_long),
('WindowExtra', ctypes.c_long),
('Instance', ctypes.c_void_p),
('Icon', ctypes.c_void_p),
('Cursor', ctypes.c_void_p),
('Background', ctypes.c_void_p),
('MenuName', ctypes.c_wchar_p),
('ClassName', ctypes.c_wchar_p),
('IconSmall', ctypes.c_void_p)]
def __init__(self):
self.Size = ctypes.sizeof(self)
super().__init__()
window_class = WNDCLASSEXW()
user32.GetClassInfoExW(handle, class_name, ctypes.byref(window_class))
return window_class