Sign in to follow this  
Followers 0
hennes000

Get macro to select correct option in list box

5 posts in this topic

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.

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi, 

thank you for your prompt reply

I was focused on the window

this is the info I get when focused on the control

kxltLX7.jpg

Edited by hennes000

Share this post


Link to post
Share on other sites

; 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)

1 person likes this

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.

Share this post


Link to post
Share on other sites

Thank you so much. 

Share this post


Link to post
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
Sign in to follow this  
Followers 0