ToyBoi Posted August 12, 2008 Share Posted August 12, 2008 This will make a combobox with the month of the year, and it will return the correct month when you select it. However it seems to always return the month Jan no matter which month I select. Any idea? expandcollapse popup#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GUIComboBox.au3> #include <GuiConstantsEx.au3> #include <Constants.au3> Opt('MustDeclareVars', 1) $Debug_CB = False; Check ClassName being passed to ComboBox/ComboBoxEx functions, set to True and use a handle to another control to see it work global $Month $Month = Example() msgbox(1,"OK", $Month) Func Example() Local $Button_1, $msg local $Months[12] $Months[0] = "Jan" $Months[1] = "Feb" $Months[2] = "Mar" $Months[3] = "Apr" $Months[4] = "May" $Months[5] = "Jun" $Months[6] = "Jul" $Months[7] = "Aug" $Months[8] = "Sep" $Months[9] = "Oct" $Months[10] = "Nov" $Months[11] = "Dec" Local $hCombo ; Create GUI GUICreate("Please select the Month", 400, 296) $Button_1 = GUICtrlCreateButton("OK", 10, 90, 100) $hCombo = GUICtrlCreateCombo("", 2, 2, 396, 296) ;GUISetState() _GUICtrlComboBox_AddString($hCombo,$Months[0]) _GUICtrlComboBox_AddString($hCombo,$Months[1]) _GUICtrlComboBox_AddString($hCombo,$Months[2]) _GUICtrlComboBox_AddString($hCombo,$Months[3]) _GUICtrlComboBox_AddString($hCombo,$Months[4]) _GUICtrlComboBox_AddString($hCombo,$Months[5]) _GUICtrlComboBox_AddString($hCombo,$Months[6]) _GUICtrlComboBox_AddString($hCombo,$Months[7]) _GUICtrlComboBox_AddString($hCombo,$Months[8]) _GUICtrlComboBox_AddString($hCombo,$Months[9]) _GUICtrlComboBox_AddString($hCombo,$Months[10]) _GUICtrlComboBox_AddString($hCombo,$Months[11]) GUICtrlSetFont(-1, 14, 300) GUISetState() ; Loop until user exits $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $Button_1 return $Month case $msg = $Months[0] $Month = $Months[0] case $msg = $Months[1] $Month = $Months[1] case $msg = $Months[2] $Month = $Months[2] case $msg = $Months[3] $Month = $Months[3] case $msg = $Months[4] $Month = $Months[4] case $msg = $Months[5] $Month = $Months[5] case $msg = $Months[6] $Month = $Months[6] case $msg = $Months[7] $Month = $Months[7] case $msg = $Months[8] $Month = $Months[8] case $msg = $Months[9] $Month = $Months[9] case $msg = $Months[10] $Month = $Months[10] case $msg = $Months[11] $Month = $Months[11] EndSelect Wend EndFunc ;==>Example Link to comment Share on other sites More sharing options...
Andreik Posted August 12, 2008 Share Posted August 12, 2008 expandcollapse popup#include <GUIComboBox.au3> #include <GuiConstantsEx.au3> #include <Constants.au3> Opt('MustDeclareVars', 1) $Debug_CB = False; Check ClassName being passed to ComboBox/ComboBoxEx functions, set to True and use a handle to another control to see it work global $Month $Month = Example() msgbox(1,"OK", $Month) Func Example() Local $Button_1, $msg local $Months[12] $Months[0] = "Jan" $Months[1] = "Feb" $Months[2] = "Mar" $Months[3] = "Apr" $Months[4] = "May" $Months[5] = "Jun" $Months[6] = "Jul" $Months[7] = "Aug" $Months[8] = "Sep" $Months[9] = "Oct" $Months[10] = "Nov" $Months[11] = "Dec" Local $hCombo ; Create GUI GUICreate("Please select the Month", 400, 296) $Button_1 = GUICtrlCreateButton("OK", 10, 90, 100) $hCombo = GUICtrlCreateCombo("", 2, 2, 396, 296) ;GUISetState() For $INDEX = 0 To 11 GUICtrlSetData($hCombo,$Months[$INDEX] & "|") Next GUICtrlSetFont(-1, 14, 300) GUISetState() ; Loop until user exits $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() If $msg = $Button_1 Then $Month = GUICtrlRead($hCombo) Return $Month EndIf Wend EndFunc ;==>Example When the words fail... music speaks. Link to comment Share on other sites More sharing options...
ToyBoi Posted August 12, 2008 Author Share Posted August 12, 2008 (edited) expandcollapse popup#include <GUIComboBox.au3> #include <GuiConstantsEx.au3> #include <Constants.au3> Opt('MustDeclareVars', 1) $Debug_CB = False; Check ClassName being passed to ComboBox/ComboBoxEx functions, set to True and use a handle to another control to see it work global $Month $Month = Example() msgbox(1,"OK", $Month) Func Example() Local $Button_1, $msg local $Months[12] $Months[0] = "Jan" $Months[1] = "Feb" $Months[2] = "Mar" $Months[3] = "Apr" $Months[4] = "May" $Months[5] = "Jun" $Months[6] = "Jul" $Months[7] = "Aug" $Months[8] = "Sep" $Months[9] = "Oct" $Months[10] = "Nov" $Months[11] = "Dec" Local $hCombo ; Create GUI GUICreate("Please select the Month", 400, 296) $Button_1 = GUICtrlCreateButton("OK", 10, 90, 100) $hCombo = GUICtrlCreateCombo("", 2, 2, 396, 296) ;GUISetState() For $INDEX = 0 To 11 GUICtrlSetData($hCombo,$Months[$INDEX] & "|") Next GUICtrlSetFont(-1, 14, 300) GUISetState() ; Loop until user exits $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() If $msg = $Button_1 Then $Month = GUICtrlRead($hCombo) Return $Month EndIf Wend EndFunc;==>Example thank you very much for helping me, it worked! and with less code too! so $msg won't be able to retrieve the selection? Edited August 12, 2008 by ToyBoi Link to comment Share on other sites More sharing options...
Monamo Posted August 12, 2008 Share Posted August 12, 2008 This will make a combobox with the month of the year, and it will return the correct month when you select it. However it seems to always return the month Jan no matter which month I select. Any idea? CODE#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <GUIComboBox.au3> #include <GuiConstantsEx.au3> #include <Constants.au3> Opt('MustDeclareVars', 1) $Debug_CB = False; Check ClassName being passed to ComboBox/ComboBoxEx functions, set to True and use a handle to another control to see it work global $Month $Month = Example() msgbox(1,"OK", $Month) Func Example() Local $Button_1, $msg local $Months[12] $Months[0] = "Jan" $Months[1] = "Feb" $Months[2] = "Mar" $Months[3] = "Apr" $Months[4] = "May" $Months[5] = "Jun" $Months[6] = "Jul" $Months[7] = "Aug" $Months[8] = "Sep" $Months[9] = "Oct" $Months[10] = "Nov" $Months[11] = "Dec" Local $hCombo ; Create GUI GUICreate("Please select the Month", 400, 296) $Button_1 = GUICtrlCreateButton("OK", 10, 90, 100) $hCombo = GUICtrlCreateCombo("", 2, 2, 396, 296) ;GUISetState() _GUICtrlComboBox_AddString($hCombo,$Months[0]) _GUICtrlComboBox_AddString($hCombo,$Months[1]) _GUICtrlComboBox_AddString($hCombo,$Months[2]) _GUICtrlComboBox_AddString($hCombo,$Months[3]) _GUICtrlComboBox_AddString($hCombo,$Months[4]) _GUICtrlComboBox_AddString($hCombo,$Months[5]) _GUICtrlComboBox_AddString($hCombo,$Months[6]) _GUICtrlComboBox_AddString($hCombo,$Months[7]) _GUICtrlComboBox_AddString($hCombo,$Months[8]) _GUICtrlComboBox_AddString($hCombo,$Months[9]) _GUICtrlComboBox_AddString($hCombo,$Months[10]) _GUICtrlComboBox_AddString($hCombo,$Months[11]) GUICtrlSetFont(-1, 14, 300) GUISetState() ; Loop until user exits $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $Button_1 return $Month case $msg = $Months[0] $Month = $Months[0] case $msg = $Months[1] $Month = $Months[1] case $msg = $Months[2] $Month = $Months[2] case $msg = $Months[3] $Month = $Months[3] case $msg = $Months[4] $Month = $Months[4] case $msg = $Months[5] $Month = $Months[5] case $msg = $Months[6] $Month = $Months[6] case $msg = $Months[7] $Month = $Months[7] case $msg = $Months[8] $Month = $Months[8] case $msg = $Months[9] $Month = $Months[9] case $msg = $Months[10] $Month = $Months[10] case $msg = $Months[11] $Month = $Months[11] EndSelect Wend EndFunc ;==>ExampleQuick edit solution would be to change your case for $Button_1 to: Case $msg = $Button_1 return GUICtrlRead($hCombo) - MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup] 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