code: def getWindowPID(self, hwnd):
          
          pid = ctypes.c_ulong()
          ctypes.windll.user32.GetWindowThreadProcessId(hwnd, ctypes.byref(pid))
          return int(pid.value)
docs: Gets the process ID that the specified window belongs to