chrome/updater/test/service/win/ui.py
def FindWindowsWithText(parent, text_to_search):
  """Finds windows with given text.

  Args:
    parent: Handle to the parent window whose child windows are to be searched.
    text_to_search: Substring to search within Windows text, case-insensitive.

  Returns:
    A list of HWND that match the search condition.
  """

  class WindowFoundHandler(object):
    """Callback class for window enumeration."""

    def __init__(self, text_to_search):
      self.result = []
      self._text_to_search = text_to_search

    def Process(self, handle):
      """Callback function when enumerating a window.

      Args:
        handle: HWND to the enumerated window.
      """
      text = win32gui.GetWindowText(handle).lower()
      text_to_search = self._text_to_search.lower()

      if text_to_search in text:
        self.result.append(handle)

  def WinFoundCallback(hwnd, window_found_handler):
    window_found_handler.Process(hwnd)

  handler = WindowFoundHandler(text_to_search)
  try:
    win32gui.EnumChildWindows(parent, WinFoundCallback, handler)
  except pywintypes.error as e:
    logging.info('Error while searching [%s], error: [%s]', text_to_search, e)

  return handler.result
Finds windows with given text.

  Args:
    parent: Handle to the parent window whose child windows are to be searched.
    text_to_search: Substring to search within Windows text, case-insensitive.

  Returns:
    A list of HWND that match the search condition.
  
Finds windows with given text.
Finds windows with given text .
def FindWindowsWithText(parent, text_to_search):
  class WindowFoundHandler(object):
    def __init__(self, text_to_search):
      self.result = []
      self._text_to_search = text_to_search
    def Process(self, handle):
      text = win32gui.GetWindowText(handle).lower()
      text_to_search = self._text_to_search.lower()
      if text_to_search in text:
        self.result.append(handle)
  def WinFoundCallback(hwnd, window_found_handler):
    window_found_handler.Process(hwnd)
  handler = WindowFoundHandler(text_to_search)
  try:
    win32gui.EnumChildWindows(parent, WinFoundCallback, handler)
  except pywintypes.error as e:
    logging.info('Error while searching [%s], error: [%s]', text_to_search, e)
  return handler.result
def FindWindowsWithText ( parent , text_to_search ) : class WindowFoundHandler ( object ) : """Callback class for window enumeration.""" def __init__ ( self , text_to_search ) : self . result = [ ] self . _text_to_search = text_to_search def Process ( self , handle ) : """Callback function when enumerating a window.

      Args:
        handle: HWND to the enumerated window.
      """ text = win32gui . GetWindowText ( handle ) . lower ( ) text_to_search = self . _text_to_search . lower ( ) if text_to_search in text : self . result . append ( handle ) def WinFoundCallback ( hwnd , window_found_handler ) : window_found_handler . Process ( hwnd ) handler = WindowFoundHandler ( text_to_search ) try : win32gui . EnumChildWindows ( parent , WinFoundCallback , handler ) except pywintypes . error as e : logging . info ( 'Error while searching [%s], error: [%s]' , text_to_search , e ) return handler . result
Finds windows with given text.
Finds windows with given text .
"""Finds windows with given text.

  Args:
    parent: Handle to the parent window whose child windows are to be searched.
    text_to_search: Substring to search within Windows text, case-insensitive.

  Returns:
    A list of HWND that match the search condition.
  """ """Callback class for window enumeration.""" """Callback function when enumerating a window.

      Args:
        handle: HWND to the enumerated window.
      """
A list of HWND that match the search condition.
A list of HWND that match the search condition .
parent
Handle to the parent window whose child windows are to be searched.
Handle to the parent window whose child windows are to be searched .
text_to_search
Substring to search within Windows text, case-insensitive.
Substring to search within Windows text case - insensitive .