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. - (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

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

ComboBox2 ID = 4008



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



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.



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

Edited by Zedna
Link to post
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 ?


Link to post
Share on other sites
Posted (edited)

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 = ""
    Local $hWnd=ControlGetHandle($title, "", "ComboBox2")
    MsgBox(0, "", "Error = " & @error & " - hWnd = " & $hWnd)
    ControlFocus($title, "", $hWnd)
    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]
; Write a line to the memo control
Func MemoWrite($sMessage)
    GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite


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


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

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


It is exactly the same as above.

Below is the output of _GUICtrlComboBox_GetListArray($hWnd).


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.


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 post
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 ... ?


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



#pragma compile(x64, False)


Edited by Zedna
Link to post
Share on other sites
Link to post
Share on other sites
Posted (edited)

Thank you both @Zedna and @Nine


I changed to


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.


ControlFocus($title, "", $hWnd)
    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.


Edited by ute_man
Link to post
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 post
Share on other sites
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By anit
      I am trying to select a value from a drop-down (highlighted in the attached image). There is no control ID associated with the window, so I am unable to use the Control* type functions. There are two values starting with 'C' in the drop-down. I tried fetching the drop-down value by passing Send("{custom}") but it always selects the first occurrence of value starting with 'C'.
      Please suggest how may I resolve this.

    • By Colduction
      Hi, i have a source code of "Danny35d" and i have 2 main question that are:
       How to extract this function's results (Datas are as Array) to combo-box without set number of datas?  When i type 1, 2 in _SystemUsers($AccountType = 0) to get only Local or Domain users, it just give me both of them, it's old problem of this function, please share us debugged code :)❤ #include <Array.au3> $Users = _ArrayToString(_SystemUsers(), "|", 1) ConsoleWrite($Users & @CRLF) #cs =============================================================================== Function: _SystemUsers($AccountType = 0) Description: Return an array with the local or domain username Parameter(s): $AccountType: Local, domain or both username 0 = Local and Domain usernames 1 = Local usernames only 2 = Domain usernames only Returns: An array with the list of usernames - Succeeded @error 1 - Didn't query any username @error 2 - Failed to create Win32_SystemUsers object @error 3 - Invalid $AccountType Author(s): Danny35d #ce =============================================================================== Func _SystemUsers($AccountType = 0) Local $aSystemUsers Local $wbemFlagReturnImmediately = 0x10, $wbemFlagForwardOnly = 0x20 Local $colItems = "", $strComputer = "localhost" If Not StringRegExp($AccountType, '[012]') Then Return SetError(3, 3, '') $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_SystemUsers", "WQL", _ $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems $Output = StringSplit($objItem.PartComponent, ',') If IsArray($Output) Then $Temp = StringReplace(StringTrimLeft($Output[2], StringInStr($Output[2], '=', 0, -1)), '"', '') If $AccountType = 0 Or ($AccountType = 1 And @ComputerName = $Temp) Then $aSystemUsers &= StringReplace(StringTrimLeft($Output[1], StringInStr($Output[1], '=', 0, -1)), '"', '') & '|' ElseIf $AccountType = 2 And @ComputerName <> $Temp Then $aSystemUsers &= StringReplace(StringTrimLeft($Output[1], StringInStr($Output[1], '=', 0, -1)), '"', '') & '|' EndIf EndIf Next $aSystemUsers = StringTrimRight($aSystemUsers, 1) If $aSystemUsers = '' Then Return(SetError(1, 1, $aSystemUsers)) Return(SetError(0, 0, StringSplit($aSystemUsers, '|'))) Else $aSystemUsers = '' Return(SetError(2, 2, $aSystemUsers)) EndIf EndFunc ;==>_SystemUsers Thanks to your best Team.
    • By littleboy62
      For a project of a tool, I have to launch a program.
      This one: Display Properties control (run desk.cpl)
      I have to resize it, so we can see what's necessary.

      I'm getting there.
      The problem is that there is a drop-down menu: so I want to disable it.
      How to do this?

      I already did a test with the notepad. By deactivating the "close" button.
      Here is the code:
      Run("Notepad.exe") WinWait("[CLASS:Notepad]") $Hwnd = WinGetHandle("[CLASS:Notepad]") $menu = DllCall("user32.dll","hwnd","GetSystemMenu","hwnd", $Hwnd, "int",0) DllCall("user32.dll", "int", "RemoveMenu", "hwnd", $menu[0] , "int", 0xF060, "int", 0x0);SC_CLOSE MsgBox(0,'',1) $menu = DllCall("user32.dll","hwnd","GetSystemMenu","hwnd", $Hwnd, "int",1) DllCall("user32.dll", "int", "RemoveMenu", "hwnd", $menu[0] , "int", 0xF060, "int", 0x0);SC_CLOSE
      I would like to do the same, but with the drop-down menu (with DllCall).
      Is it possible to disable / block (or other) the drop-down menu of a program?

      Thank you for your answers.
    • By DannyJ
      Hello Forum, 
      I have one special Combo-box [with BitOR($CBS_DROPDOWNLIST, $GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE) ] and if I press one button I want to change the Combo-box's background color, and after I press Button B I want to change it to the basic settings and it not works.
      I wanna do this with one combo-box.
      I have already tried several methods and I tried  GUICtrlComboSetColors that I have found on this forum.
      (But this methods works perfectly with Cobo boxes that don't have BitOR($CBS_DROPDOWNLIST, $GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE). 
      Here is the example code
      #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= ;$CBS_DROPDOWNLIST ;$GUI_SS_DEFAULT_COMBO $Form1 = GUICreate("Form1", 504, 249, 252, 227) $Combo1 = GUICtrlCreateCombo("", 136, 24, 193, 25,BitOR($CBS_DROPDOWNLIST, $GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE)) ; I want to change this special combo's background color if I press button 1 $Button1 = GUICtrlCreateButton("Button1", 112, 96, 75, 25) $Button2 = GUICtrlCreateButton("Button2", 264, 96, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUICtrlSetData($Combo1," " & "|" & "apple" & "|" & "banana" & "|" & "cherry" ," ") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 GUICtrlSetBkColor($Combo1,0x0078D7) Case $Button2 ;Makes the original bc color GUICtrlSetBkColor($Combo1,0xFFFFFF) EndSwitch WEnd  
      Thanks you in advance your help
    • By UGH
      Autoit team are assbags.    They want to hold out that they are soooo much smarter than everyone else and they really don't want to help anyone with their questions.   In that case then why have a website.   Oh i know, they get their kicks out of laughing at everyone. 
  • Create New...