Jump to content

ComboBox value selection - Third Party Software


Recommended Posts

Hi Forum,

I am struggling to select an IP address from "Server Interface" dropdown (ComboBox2) of tftpd32 client.

tftpd32 is a TFTP server - TFTPD32 : an opensource IPv6 ready TFTP server/service for windows : TFTP server (pagesperso-orange.fr)

The IP addresses (and the associated interfaces) are dynamic in ComboBox2.

What I want to do is to select an item from ComboBox2 which contains a given IP address (eg. 192.168.2.1) - (which is hidden in the picture as it is at the bottom of the list) and fill the edit field with the selection. (Note : the ComboBox items contain the IP address and the Interface name, therefore IP address is just a part of the item)

I am not sure whether functions such as _GUICtrlComboBox_SelectString() are only to be used with Autoit generated ComboBoxes.

Please help !!!!

My code below, it does not select the ComboBox2 item with my IP address 192.168.2.1.

Local $hWnd=ControlGetHandle("Tftpd32 by Ph. Jounin", "", 4008)
    Sleep(100)
    ControlFocus("Tftpd32 by Ph. Jounin", "", $hWnd)
    Sleep(100)
    Local $IP = "192.168.2.1"
    _GUICtrlComboBox_SelectString($HWnd, $IP)

ComboBox2 ID = 4008

image.png.84cd17e44ab3be66aed1937a73333a73.png

image.png.11b46d8326473f31035248fef35d5931.png

Link to comment
Share on other sites

Also try to test return value and @error after ControlGetHandle() to be sure it was called without problems and $hwnd is valid handle ...

 

EDIT:

In general _GUICtrlComboBox_SelectString() should work also with non-AutoIt Combo boxes in external appliactions,

but it must be standard Windows Combo boxes and some applications resist to such automatize.

 

EDIT2:

Try _GUICtrlComboBox_FindString() instead of _GUICtrlComboBox_SelectString() to see if it finds corresponding index of item in ComboBox

Edited by Zedna
Link to comment
Share on other sites

Thank you so much Zedna. I tried both of your suggestions, but no luck.

Are these functions such as  _GUICtrlComboBox_SelectString() only for Autoit generated ComboBoxes or can they be used for third part applications too ?

image.png.7c9ced47679b36b927683fda09587e41.png

Link to comment
Share on other sites

Thank you again Zedna,

I tried all your advices and the outputs are captured in MsgBoxes as shown below.

;-----------------------------
    Local $title = "Tftpd32 by Ph. Jounin"
    Local $IP = "192.168.2.1"
    Local $hWnd=ControlGetHandle($title, "", "ComboBox2")
    MsgBox(0, "", "Error = " & @error & " - hWnd = " & $hWnd)
    ;-----------------------------
    ControlFocus($title, "", $hWnd)
    Sleep(100)
    Local $Select_String = _GUICtrlComboBox_SelectString($hWnd, $IP)
    MsgBox(0, "SelectString", $Select_String)
    Local $Find_String = _GUICtrlComboBox_FindString($hWnd, $IP)
    MsgBox(0, "FindString", $Find_String)
    ;-----------------------------
    Global $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0)
    ; Get List
     ;$aList = _GUICtrlComboBox_GetListArray($hWnd)
    $aList = StringSplit(_GUICtrlComboBox_GetList($hWnd), ",")
    For $x = 1 To $aList[0]
        MemoWrite($aList[$x])
    Next
    ;-----------------------------
; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

image.png.e96372389b370c5215ad3d41ee5f4f77.png

It appears that no error returned and the hWnd is returned correctly.

image.png.e2bcc695cff73e3b6fc84fa22eb29a45.png

The index returned when _GUICtrlComboBox_SelectString($hWnd, $IP) is used look incorrect.

And _GUICtrlComboBox_FindString($hWnd, $IP) returns the following.

image.png.142a17d0b411125825c1229decd3526c.png

It is exactly the same as above.

Below is the output of _GUICtrlComboBox_GetListArray($hWnd).

image.png.bab20f2dca5e3c07dcfb1fec25952434.png

There are 6 lines which correspond to the 6 items in ComboBox2, but with weird characters.

And the output generated by _GUICtrlComboBox_GetList($hWnd) is below.

image.png.037ae426ed0d9a4e3a7344d21f0cc363.png

Similar to above but this time displayed horizontally.

I am completely lost. Hope you can assist me further please.

Thank you.

Edited by ute_man
Link to comment
Share on other sites

1) Value 4294967295 returned by FindString corresponds to  $CB_ERR = -1, i.e. failure to find desired item in ListBox inside ComboBox

2) Texts got by _GUICtrlComboBox_GetListArray(seems to be some Unicode stuff, maybe some ListBoxs trick similar to _GUICtrlListView_GetUnicodeFormat() in ListViews will be needed ... ?

EDIT:

3) Try to force 32bit compilation of your EXE by 

#AutoIt3Wrapper_UseX64=n

or

#pragma compile(x64, False)

 

Edited by Zedna
Link to comment
Share on other sites

Link to comment
Share on other sites

Thank you both @Zedna and @Nine

@Zedna 

I changed to

#AutoIt3Wrapper_UseX64=n

Now both _GUICtrlComboBox_SelectString($hWnd, $IP) and _GUICtrlComboBox_FindString($hWnd, $IP) return -1 indicating a failure.

Looks like we are getting somewhere ????

I also tried making 

_GUICtrlListView_SetUnicodeFormat($hWnd, True)

as previously it returned "False" with _GUICtrlListView_GetUnicodeFormat ($hWnd)

However, no change in character displays but same output as before.

@Nine

ControlFocus($title, "", $hWnd)
    Sleep(100)
    ControlSend($title, "", $hWnd, $IP)

I tried this but doesn't do anything unfortunately.

It may be because the ComboBox2 entries are dynamic and it is not only the IP address in a given line but also the adapter details too. 

Therefore sending IP address alone will not select that line.

image.png

Edited by ute_man
Link to comment
Share on other sites

Link to comment
Share on other sites

Thanks @Nine, much appreciated.

I tried using controlclick() on the ComboBox2 and then sending  {UP} or {DOWN}, but the issue is that I don't know how to locate the desired line containing my IP address as both _GUICtrlComboBox_SelectString($hWnd, $IP) and _GUICtrlComboBox_FindString($hWnd, $IP) don't seem to "work".

Any tips will be appreciated.

Thanks again @Nine

Link to comment
Share on other sites

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

×
×
  • Create New...