code: def getWindowByTitle(self, wildcard, order=0):
          
          EnumWindowsProc = ctypes.WINFUNCTYPE(
              ctypes.c_bool,
              ctypes.POINTER(ctypes.c_int),
              ctypes.py_object)
          def callback(hwnd, context):
              if ctypes.windll.user32.IsWindowVisible(hwnd):
                  length = ctypes.windll.user32.GetWindowTextLengthW(hwnd)
                  buff = ctypes.create_unicode_buffer(length + 1)
                  ctypes.windll.user32.GetWindowTextW(hwnd, buff, length + 1)
                  if re.search(context["wildcard"], buff.value, flags=re.I) != None and not context["handle"]:
                      if context["order"] > 0:
                          context["order"] -= 1
                      else:
                          context["handle"] = hwnd
              return True
          data = {"wildcard": wildcard, "handle": None, "order": order}
          ctypes.windll.user32.EnumWindows(EnumWindowsProc(callback), ctypes.py_object(data))
          return data["handle"]
docs: Returns a handle for the first window that matches the provided "wildcard" regex