title: Choose Combobox item with Pywinauto
body: <p>I've programmed a script to automate some activities. <a href="https://i.stack.imgur.com/GFOfJ.png" rel="nofollow noreferrer">The figure 1 shows the window that I face some problems</a>, specifically  the "Locomotora" drop down menu. 
  The information is in Spanish, however It isn't a problem to the error description.</p>
  
  <p>The current implementation receives 2 entry parameters:</p>
  
  <ul>
  <li>Locomotora item position: position of the item selected in the drop down menu "Locomotora".  </li>
  <li>number of messages: how many times "Enviar" will
  be pressed, sending messages with data filled.</li>
  </ul>
  
  <p>The code below it is the current script that I developed.</p>
  
  <p>With control_identifiers method, in the while loop, <a href="https://i.stack.imgur.com/QUjKH.png" rel="nofollow noreferrer">returned value</a>, I've discovered that the menu can be controlled with libreComboBox2.</p>
  
  <pre><code>from pywinauto import application
  import sys, time
  
  def send_message(repeat_number,locomotora,content):
      app = application.Application().connect(path ="C:\APP\app.exe")
  
      command = "%HQ{{DOWN {} }}".format(locomotora)
      iterCounter = 0
  
      while (iterCounter &lt; repeat_number):
          try:
          #Get window focused
              tfrmenviarmacrolivredlg = app.top_window()
              tfrmenviarmacrolivredlg.SetFocus()
  
          #print window control identifiers
              tfrmenviarmacrolivredlg.print_control_identifiers()
  
          # Choose locomotora 
              tfrmenviarmacrolivredlg.libreComboBox2.type_keys(command)
  
          #Set text content
              tfrmenviarmacrolivredlg['Edit'].set_text(content)
  
          #Send(Enviar) Message
              tfrmenviarmacrolivredlg['Enviar'].click()
              time.sleep(1)
  
              iterCounter += 1
  
          except IOError as e:
             print("I/O error({0}): {1}".format(e.errno, e.strerror))
          except ValueError as v:
             print("Could not convert data to an integer.".format(v.errno, v.strerror))
          except Exception as ex:
             print("Unexpected error:".format(ex.errno, ex.strerror))
             sys.exc_info()[0]
  
  if __name__ == '__main__':
      if len(sys.argv) &lt; 3:
          print("Not enough arguments")
          print("python3 send_message_pywinauto.py [number_of_messages] [locomotora] ")
          exit(1)
  
      n_rows = int(sys.argv[1])
  
      locomotora_item_position  = int(sys.argv[2])
      send_message(n_rows,locomotora_item_position,"0123456789"*30)
  </code></pre>
  
  <p>It works, but to choose an item from the "Locomotora" drop down menu the script "types" {DOWN} until reach the item position ( tfrmenviarmacrolivredlg.libreComboBox2.type_keys(command) ). </p>
  
  <p>The appropriate execution must use "select" method to choose the "locomotora" in the drop down.</p>
  
  <p>I tried the following command, but it didn't work:</p>
  
  <pre><code>tfrmenviarmacrolivredlg.libreComboBox2.select("locomotora_name")
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/HaIb1.png" rel="nofollow noreferrer">Command result</a></p>
  
  <p>How can I select the item with its name?</p>