Richy Posted November 27, 2008 Share Posted November 27, 2008 First of all hi to everyone. Ive been using autoit for a short time and been reading the forums for a while i never had to post before but today i encountered a problem with my code and i want to see if any of you could help me out with it, i just dont get what im doing wrong here: #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <ComboConstants.au3> #Include <Constants.au3> #Include <GuiComboBoxEx.au3> $mainWindow = GUICreate("ComboBoxEx Create", 450, 500) global $cf1=1000 global $cf2=1000, $cf3, $cf4, $cf5, $cf6, $cf7, $cf8 $coord = 40 for $i = 8 to 1 step -1 assign(eval("cf" & $i),_GUICtrlComboBoxEx_Create ($mainWindow, _ "1|2|3|4|5|6|7|8", _ 2, $coord, 394, 268,$CBS_DROPDOWNLIST)) _GUICtrlComboBoxEx_SetCurSel(eval("cf" & $i), $i) GUICtrlSetState(eval("cf" & $i), $GUI_ONTOP) $coord += 35 next GUISetState() while 1 $msg = GUIGetMsg() if $msg == $GUI_EVENT_CLOSE then exit WEnd The problem is that this code doesnt set the combo box value but at random time it does set it but only the number 2 to a random combo box. Execute it like 10 times to see what im saying. Thanks in advance. Link to comment Share on other sites More sharing options...
monoceres Posted November 27, 2008 Share Posted November 27, 2008 Couldn't reproduce, but hey! You should really learn about arrays, it will save you loads of time and problems instead of that eval,assign crap. Oh and welcome to the forums Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 28, 2008 Share Posted November 28, 2008 Couldn't reproduce, but hey! You should really learn about arrays, it will save you loads of time and problems instead of that eval,assign crap. Oh and welcome to the forums I agree, and there doesn't seem to be any requirement for 'Ex' versions of the _GuiCtrlComboBox_* stuff. This works either way, and gets the default selections desired: Regular UDF: #include <GUIConstantsEx.au3> #Include <GuiComboBox.au3> Global $mainWindow = GUICreate("ComboBox Create", 450, 500) Global $avComboBoxes[8] For $i = 0 to UBound($avComboBoxes) - 1 $avComboBoxes[$i] = _GUICtrlComboBox_Create ($mainWindow, _ "1|2|3|4|5|6|7|8", _ 20, 40 + ($i * 35), 394, 268, $CBS_DROPDOWNLIST) _GUICtrlComboBox_SetCurSel($avComboBoxes[$i], $i) GUICtrlSetState($avComboBoxes[$i], $GUI_ONTOP) Next GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GuiComboBoxEx UDF: #include <GUIConstantsEx.au3> #Include <GuiComboBoxEx.au3> Global $mainWindow = GUICreate("ComboBoxEx Create", 450, 500) Global $avComboBoxes[8] For $i = 0 to UBound($avComboBoxes) - 1 $avComboBoxes[$i] = _GUICtrlComboBoxEx_Create ($mainWindow, _ "1|2|3|4|5|6|7|8", _ 20, 40 + ($i * 35), 394, 268, $CBS_DROPDOWNLIST) _GUICtrlComboBoxEx_SetCurSel($avComboBoxes[$i], $i) GUICtrlSetState($avComboBoxes[$i], $GUI_ONTOP) Next GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE The handles to the eight combo boxes are in $avComboBoxes[0] thru $avComboBoxes[7]. Much easier to deal with that way. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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