Jump to content

Get macro to select correct option in list box


Go to solution Solved by jdelaney,

Recommended Posts

Hi,

I'm trying to get autoit to choose a specific option from this titleless listbox. 

 fshpWE7.jpg

ie. I want the macro to select the CHEMISTRY2 option by pressing the up and down keys. 

Possibly by,

macro checking option currently highlighted.

if it is equal to CHEMISTRY2, press enter

if not press down

repeat

However I'm unsure of the coding as I'm new to autoit. All help will be much appreciated. Thank you in advance.

 

Link to comment
Share on other sites

Were you focused on the control, or the window.  If window, get the output again, for the control.

#include <WinAPI.au3>
$hWin = WinGetHandle("The parent window title that opens that 'enabled popup'")
$hPopup = _WinAPI_GetWindow($hWin,6)
$hControl_List = ControlGetHandle($hPopup,"","you need to provide more info to get the control")
$hControl_Button = ControlGetHandle($hPopup,"","[TEXT:&OK]")

WinActivate($hPopup)
ControlFocus($hPopup,"",$hControl_List)
ControlCommand($hPopup,"",$hControl_List,"SelectString", 'whatever you want to select in list')

ControlFocus($hPopup,"",$hControl_Button)
ControlClick($hPopup,"",$hControl_Button)
Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

  • Solution

; plug in your parent window, and the value you want to set, and good to go

#include <WinAPI.au3>
$hWin = WinGetHandle("The parent window title that opens that 'enabled popup'")
$hPopup = _WinAPI_GetWindow($hWin,6)
$hControl_List = ControlGetHandle($hPopup,"",1011)
$hControl_Button = ControlGetHandle($hPopup,"","[TEXT:&OK]")

WinActivate($hPopup)
ControlFocus($hPopup,"",$hControl_List)
ControlCommand($hPopup,"",$hControl_List,"SelectString", 'whatever you want to select in list')

ControlFocus($hPopup,"",$hControl_Button)
ControlClick($hPopup,"",$hControl_Button)

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...