Jump to content

cowofevil

Members
  • Posts

    1
  • Joined

  • Last visited

About cowofevil

  • Birthday 07/09/1980

Profile Information

  • Location
    Portland, OR
  • Interests
    Python programming

cowofevil's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. I know you're expecting a question, but actually this is just the answer to the question! I decided to post this here because through some mega-googling and forum snooping I finally came up with a solution to the problem. Since this forum has been very informative to me in the past I decided it was my duty to post this information here so the next guy doesn't need to waste many hours of his life trying to solve the problem. Issue: You need to know the index of the current selection of a combo box using AutoIt via the COM interface in Python. Pre-Reqs: Python 2.7 or greater. PyWin32 (If you just have the ActiveState version of Python installed this will be done automatically) AutoIt 3.3 or greater. Imports: from win32com.client import Dispatch from win32api import SendMessage from win32con import CB_GETCURSEL The first import is for actually loading the COM class of AutoIt. The second import is a Win32 function for sending messages to controls. The third import is a constant that represents the message type you want to send. Solution: #init strWindowTitle = 'TESTAPP' strComboBoxID = '[CLASS:ComboBox; INSTANCE:1]' #COM handle for AutoIt comAutoIt = Dispatch("AutoItX3.Control") #Get handle on combobox control. #We get a string representation of hex that needs to be converted to int. hdlComboBox = int(comAutoIt.ControlGetHandle(strWindowTitle, '', strComboBoxID), 16) #Get the current index of the combobox. (Index is 0 based) intIndex = SendMessage(hdlComboBox, CB_GETCURSEL, 0, 0) Hope that was helpful!
×
×
  • Create New...