cdebel2005

How to read value from ComboBox from another form?

5 posts in this topic

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!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

 

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
1 person likes this

I am not a lawyer.  (-_-) Xandy About  (^o^) Discord - Xandy Programmer

Share this post


Link to post
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

1 person likes this

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

 

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

I am not a lawyer.  (-_-) Xandy About  (^o^) Discord - Xandy Programmer

Share this post


Link to post
Share on other sites

I don't see how this will help to get the ID at a specific screen coordinates.

I've found what i neede here from _WinAPI_GetAncestor and _Mouse_Control_GetInfo.

Thanks for the help you have provided

1 person likes this

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