Jump to content
Sign in to follow this  
PieMan

Is it possible to pull data from a drop down box?

Recommended Posts

PieMan

In one of our applications there is a drop down box that has about 50 entries... is it possible to extract those entries into a text file?

I personally dont think you can but im new to AutoIT so i thought i might ask..

Thanks.

Share this post


Link to post
Share on other sites
MDCT

Maybe with _GUICtrlComboBoxEx_GetList?

http://www.autoitscript.com/autoit3/docs/l...xEx_GetList.htm

Good luck.

Here's one example:

#include <WinAPI.au3>
#include <GUIComboBoxEx.au3>
Opt('WinTitleMatchMode', 4)

while 1
    Sleep(50)
    if _WinAPI_GetClassName(WinGetHandle("[ACTIVE]"))  <> "#32770" Then
        Sleep(100)
    Else
        $Combobox = ControlGetHandle(WinGetHandle("[ACTIVE]"), "", "[CLASS:ComboBox; INSTANCE:1]")
        tooltip(_GUICtrlComboBoxEx_GetList ($Combobox),0,0)
    EndIf
    Sleep(50)
WEnd

It will show the combobox of Open/Save dialog. So, to try it, you would need to open the dialog, just "save as" on notepad or scite to open the dialog.

Edited by MDCT

Share this post


Link to post
Share on other sites
PieMan

Maybe with _GUICtrlComboBoxEx_GetList?

http://www.autoitscript.com/autoit3/docs/l...xEx_GetList.htm

Good luck.

Here's one example:

#include <WinAPI.au3>
#include <GUIComboBoxEx.au3>
Opt('WinTitleMatchMode', 4)

while 1
    Sleep(50)
    if _WinAPI_GetClassName(WinGetHandle("[ACTIVE]"))  <> "#32770" Then
        Sleep(100)
    Else
        $Combobox = ControlGetHandle(WinGetHandle("[ACTIVE]"), "", "[CLASS:ComboBox; INSTANCE:1]")
        tooltip(_GUICtrlComboBoxEx_GetList ($Combobox),0,0)
    EndIf
    Sleep(50)
WEnd

It will show the combobox of Open/Save dialog. So, to try it, you would need to open the dialog, just "save as" on notepad or scite to open the dialog.

Great thank you so much... its not fully working but at least it's pulling the data from the list (my code).

Edited by PieMan

Share this post


Link to post
Share on other sites
MDCT

Hmmm, you're right. It will correctly retrieve all the data in the combobox only after the combobox is drop-downed. Otherwise, it will only retrieve the current item and the items before.

I moded the code earlier so it will dropdown the combobox, retrieve the data, and then hide the dropdown.

#include <WinAPI.au3>
#include <GUIComboBoxEx.au3>

Opt('WinTitleMatchMode', 4)

while 1
    Sleep(50)
    if _WinAPI_GetClassName(WinGetHandle("[ACTIVE]"))  <> "#32770" Then
        Sleep(100)
    Else
        $Combobox = ControlGetHandle(WinGetHandle("[ACTIVE]"), "", "[CLASS:ComboBox; INSTANCE:1]")
        _GUICtrlComboBoxEx_ShowDropDown($Combobox, True)
        $list=_GUICtrlComboBoxEx_GetListArray($Combobox)
        Sleep(25)
        _GUICtrlComboBoxEx_ShowDropDown($Combobox, False)
        for $x=1 to $list[0]
            tooltip("Total data: "&$list[0] &" Current data: "&$list[$x],0,0)
            sleep(200)
        next
    EndIf
    Sleep(50)
WEnd

I know the work around is not pretty, but I believe the experts here could help you to get all the data better than this.

Good luck.

Share this post


Link to post
Share on other sites
Thamiel

Here's a snippet from a program I've been working on, the Function delete's an entry from a ComboBox, after which it delete's the old ini file, then sorts the ComboBox entries, removes any dupes and lastly writes the remaining ComboBox entries back out to an ini file.

Func Del()
    _GUICtrlComboBox_DeleteString($PickIt, _GUICtrlComboBox_FindStringExact($PickIt, ControlGetText('', '', '[CLASS:Edit; INSTANCE:2]'), -1))
    If FileExists($ST_INI) Then FileDelete($ST_INI)
    $aList = _GUICtrlComboBox_GetListArray($PickIt)
    _ArraySort($aList)
    _ArrayRemoveDuplicates($aList)
    $file = FileOpen($ST_INI, 1)
    For $x = 1 To $aList[0]
    FileWriteLine($file, $aList[$x])
    Next
    FileClose($file)
EndFunc   ;==>Del

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.