chrome/updater/test/service/win/ui.py
def SendKeyToWindow(hwnd, key_to_press):
  """Sends a key press to the window.

  This is a blocking call until all keys are pressed.

  Args:
    hwnd: handle of  the window to press key.
    key_to_press: Actual key to send to window. eg.'{Enter}'. See `window_shell`
        documentation for key definitions.
  """
  try:
    window_shell = win32com.client.Dispatch('WScript.Shell')
    SetForegroundWindow(hwnd)
    window_shell.AppActivate(str(win32gui.GetForegroundWindow()))
    window_shell.SendKeys(key_to_press)
    logging.info('Sent %s to window %x.', key_to_press, hwnd)
  except pywintypes.error as err:
    logging.error('Failed to press key: %s', err)
    raise
  except pythoncom.com_error as err:
    logging.error('COM exception occurred: %s, is CoInitialize() called?', err)
    raise
Sends a key press to the window.

  This is a blocking call until all keys are pressed.

  Args:
    hwnd: handle of  the window to press key.
    key_to_press: Actual key to send to window. eg.'{Enter}'. See `window_shell`
        documentation for key definitions.
  
Sends a key press to the window.
This is a blocking call until all keys are pressed.
Sends a key press to the window . This is a blocking call until all keys are pressed .
def SendKeyToWindow(hwnd, key_to_press):
  try:
    window_shell = win32com.client.Dispatch('WScript.Shell')
    SetForegroundWindow(hwnd)
    window_shell.AppActivate(str(win32gui.GetForegroundWindow()))
    window_shell.SendKeys(key_to_press)
    logging.info('Sent %s to window %x.', key_to_press, hwnd)
  except pywintypes.error as err:
    logging.error('Failed to press key: %s', err)
    raise
  except pythoncom.com_error as err:
    logging.error('COM exception occurred: %s, is CoInitialize() called?', err)
    raise
def SendKeyToWindow ( hwnd , key_to_press ) : try : window_shell = win32com . client . Dispatch ( 'WScript.Shell' ) SetForegroundWindow ( hwnd ) window_shell . AppActivate ( str ( win32gui . GetForegroundWindow ( ) ) ) window_shell . SendKeys ( key_to_press ) logging . info ( 'Sent %s to window %x.' , key_to_press , hwnd ) except pywintypes . error as err : logging . error ( 'Failed to press key: %s' , err ) raise except pythoncom . com_error as err : logging . error ( 'COM exception occurred: %s, is CoInitialize() called?' , err ) raise
Sends a key press to the window.
Sends a key press to the window .
"""Sends a key press to the window.

  This is a blocking call until all keys are pressed.

  Args:
    hwnd: handle of  the window to press key.
    key_to_press: Actual key to send to window. eg.'{Enter}'. See `window_shell`
        documentation for key definitions.
  """
hwnd
handle of  the window to press key.
handle of the window to press key .
key_to_press
Actual key to send to window.
Actual key to send to window .