Mr. Analogy Posted July 17, 2005 Share Posted July 17, 2005 I"m trying to get and set the text of a combo box. Can't get it to work, although I can mainpulate other controls (textbox, etc.) on the same form. I've tried to manipulate the Combo Box on 3 differeent programs: Goldmine A vb script: Opt("WinTextMatchMode", 2) ;1=complete, 2=quick Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced $ComboBox="Tedit1" $ComboBoxIDNum=461162 $Checkbox="TCheckBox1" $TextBox="ThunderRT6TextBox1" $WindowName="Form1" ;msgbox (0,"combo box text",ControlCommand ($WindowName,"",$ComboBox,"GetSelected", "")); does not work msgbox (0,"debug","GetCurrentSelection=" & ControlCommand ($WindowName,"",$ComboBox,"GetCurrentSelection", "")) ControlHide ($WindowName,"",$ComboBox) ;fails ControlCommand ($WindowName,"",$Checkbox,"Check","") ;works is this behavior: 1. As intended, and the apps I've tried to interact with just have odd combo and listboxes? (My examle here is with a Combo Box, but have had same symptom with ListBox) 2. An error in my script. 3. A bug in AutoIT. Any help appreciated.Test_getting_ComboBox_selection.zip Link to comment Share on other sites More sharing options...
GaryFrost Posted July 17, 2005 Share Posted July 17, 2005 This code requires beta, and also works on windows standard combo box, not sure if it work on any other programs custom combo boxes. but feel free to give it a try, might work for you. Global Const $CB_ERR = -1 Global Const $CB_GETCURSEL = 0x147 Global Const $CB_GETLBTEXT = 0x148 Global Const $CB_GETLBTEXTLEN = 0x149 $hcombobox = ControlGetHandle($WindowName,"",$ComboBox) $ret = DllCall("user32.dll","int","SendMessage","hwnd",$hcombobox, "int", $CB_GETCURSEL, "int", 0, "int", 0) MsgBox(0,"test",$ret[0]) $s_text = "" _ComboGetLBText($hcombobox, $ret[0], $s_text) MsgBox(0,"text",$s_text) Func _ComboGetLBText($hcombobox, $i_index, ByRef $s_text) Local $ret = DllCall("user32.dll","int","SendMessage","hwnd",$hcombobox, "int", $CB_GETLBTEXTLEN, "int", $i_index, "int", 0) Local $i, $len $len = $ret[0] $s_text = "" Local $p $p = DllStructCreate ("char[" & $len + 1 & "]") $ret = DllCall("user32.dll","int","SendMessage","hwnd", $hcombobox, "int", $CB_GETLBTEXT, "int", $i_index, "ptr", DllStructGetPtr ($p)) If ($ret[0] == $CB_ERR) Then DllStructDelete ($p) Return $CB_ERR EndIf $s_text = DllStructGetData ($p, 1) DllStructDelete ($p) Return $ret[0] EndFunc ;==>_ComboGetLBText SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now