Jump to content

How to read value from ComboBox from another form?


Recommended Posts

Let's say i have an application xyz made by a 3rd party, and one of its form contain a ComboBox, is it possible to read the current value (text) of the combobox?

Yet, all i've found is informations to read values of combobox in form i've created with AutoIt, but that's not my goal.

 

Thanks for your help!

Link to comment
Share on other sites

 

Does this work?

#include <GuiComboBox.au3>

local $iCombo_index= -1
local $hControl= controlgethandle($handle_3rdparty_window, "", $i_3rdparty_combobox_control_id)
local $sData= "None"

$iCombo_index= _GUICtrlComboBox_GetCurSel($hControl); -1 on null unchoosen dropdown value
if $iCombo_index > -1 then
    _GUICtrlComboBox_GetLBText($hControl, $iCombo_index, $sData)
endif

consolewrite($sData)

Edit tried to touch it up by hand here and there were a few errors that I hopefully cleaned up.

You''ll have to get the handle to the 3rd party window and the control ID of the combobox query.

Edited by Xandy
Link to comment
Share on other sites

It work, but is there any way to get the informations of what's below the cursor or at a specific X,Y coord on the screen?

I've got the $handle_3rdparty_window from the Dialog Title  ("Preferences"), and got the $i_3rdparty_comobox_control_id from "AutoIt Windows Info" but i would prefer to do it programmatically.

Thanks

Link to comment
Share on other sites

 

Good job!

Can you modify this or you need me make it more readable?

func combo_items_write($client_record_id)
    local $hcontrol= 0, $combo_index= 0, $combo_item_string= "", $path= @scriptdir&"\Combo_Data\"
    $window= window_find()
    if $window<> "" then
        $hcontrol= controlgethandle($window, "", $field_info[$client_record_id][$fi_cid])
        if @error<> 0 then
            consolewrite("error obtaining control handle, in write_combo_items()"&@crlf&$wintitle&@crlf&$wintitle_occurance&@crlf&$field_info[$client_record_id][$fi_cid], 1)
            return
        endif
        dircreate($path); There will be a directory
        $combo_items= _GUICtrlComboBox_GetCount($hcontrol)
        if $combo_items> 0 then
            local $combo_items_a[$combo_items]
            for $combo_index= 0 to $combo_items-1
                _GUICtrlComboBox_GetLBText($hcontrol, $combo_index, $combo_items_a[$combo_index])
            next
            $file= fileopen($path&$field_info[$client_record_id][$fi_label]&".txt", 2)
            for $combo_index= 0 to $combo_items-1
                filewriteline($file, $combo_items_a[$combo_index])
            next
            fileclose($file)
        endif;combo_items> 0
    endif;win_a[0][0]> 0
EndFunc;write_combo_items()

 

Edited by Xandy
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...