Boss007 Posted June 16, 2012 Share Posted June 16, 2012 Hi I am A total novice. I need to preform an action based on gender. I used koda to draw a box displaying a choose gender window with three buttons, select gender,Male,Female. I now want to run one of two actions dependant on the gender chosen... " if button 1 is selected then do this, if button 2 is selected then viper gender select.au3do that" here is my coding imported into Au3. I'm Lost any help would be appriciated thanks! #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=gender select.kxf $Form2 = GUICreate("Select your Gender", 279, 213, 468, 254) $GroupBox1 = GUICtrlCreateGroup("", 48, 33, 185, 129) GUICtrlSetBkColor(-1, 0x008080) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button1 = GUICtrlCreateButton("Male", 54, 107, 75, 25) GUICtrlSetBkColor(-1, 0x0054E3) $Button2 = GUICtrlCreateButton("Female", 149, 108, 75, 25) GUICtrlSetBkColor(-1, 0xFF00FF) $Button3 = GUICtrlCreateButton("Select Your Gender", 85, 52, 115, 25) GUICtrlSetBkColor(-1, 0x00FF00) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
pieeater Posted June 16, 2012 Share Posted June 16, 2012 (edited) well this will make your gui work. i dont really see the point of making the select gender a button expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=gender select.kxf $Form2 = GUICreate("Select your Gender", 279, 213, 468, 254) $GroupBox1 = GUICtrlCreateGroup("", 48, 33, 185, 129) GUICtrlSetBkColor(-1, 0x008080) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button1 = GUICtrlCreateButton("Male", 54, 107, 75, 25) GUICtrlSetBkColor(-1, 0x0054E3) $Button2 = GUICtrlCreateButton("Female", 149, 108, 75, 25) GUICtrlSetBkColor(-1, 0xFF00FF) $Button3 = GUICtrlCreateButton("Select Your Gender", 85, 52, 115, 25) GUICtrlSetBkColor(-1, 0x00FF00) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $Button1 _maleFunction() Case $Button2 _femaleFunction() EndSwitch WEnd Func _maleFunction() ;insert code here EndFunc Func _femaleFunction() ;insert code here EndFunc Edited June 16, 2012 by pieeater Boss007 1 [spoiler]My UDFs: Login UDF[/spoiler] Link to comment Share on other sites More sharing options...
Zedna Posted June 16, 2012 Share Posted June 16, 2012 Button3 have no sense as button it should be just label $label1 = GUICtrlCreateLabel("Select Your Gender", 85, 60, 115, 15, BitOr($GUI_SS_DEFAULT_LABEL, $SS_CENTER)) GUICtrlSetBkColor(-1, 0x00FF00) Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
Zedna Posted June 16, 2012 Share Posted June 16, 2012 Another way is to use Radio buttons expandcollapse popup#include <ButtonConstants.au3> #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=gender select.kxf $Form2 = GUICreate("Select your Gender", 279, 213, 468, 254) $GroupBox1 = GUICtrlCreateGroup("", 48, 33, 185, 129) GUICtrlSetBkColor(-1, 0x008080) $cbx_male = GUICtrlCreateRadio("Male", 54, 107, 75, 25) GUICtrlSetBkColor(-1, 0x0054E3) $cbx_female = GUICtrlCreateRadio("Female", 149, 108, 75, 25) GUICtrlSetBkColor(-1, 0xFF00FF) $Button1 = GUICtrlCreateButton("Select Your Gender", 85, 52, 115, 25) GUICtrlSetBkColor(-1, 0x00FF00) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 SelectGender() EndSwitch WEnd Func SelectGender() If IsChecked($cbx_male) Then ; insert code here for male ElseIf IsChecked($cbx_female) Then ; insert code here for female Else MsgBox(48,'Warning','Male or Female must be selected!') EndIf EndFunc Func IsChecked($control) Return BitAnd(GUICtrlRead($control),$GUI_CHECKED) = $GUI_CHECKED EndFunc Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
Boss007 Posted June 16, 2012 Author Share Posted June 16, 2012 well this will make your gui work. i dont really see the point of making the select gender a button expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=gender select.kxf $Form2 = GUICreate("Select your Gender", 279, 213, 468, 254) $GroupBox1 = GUICtrlCreateGroup("", 48, 33, 185, 129) GUICtrlSetBkColor(-1, 0x008080) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button1 = GUICtrlCreateButton("Male", 54, 107, 75, 25) GUICtrlSetBkColor(-1, 0x0054E3) $Button2 = GUICtrlCreateButton("Female", 149, 108, 75, 25) GUICtrlSetBkColor(-1, 0xFF00FF) $Button3 = GUICtrlCreateButton("Select Your Gender", 85, 52, 115, 25) GUICtrlSetBkColor(-1, 0x00FF00) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $Button1 _maleFunction() Case $Button2 _femaleFunction() EndSwitch WEnd Func _maleFunction() ;insert code here EndFunc Func _femaleFunction() ;insert code here EndFunc Thanks your absolutly correct I have adjusted the coding to reflect this.when I first used koda I had no idea of what I was doing,and used the coding generated by koda.Thanks for the selection routine.and the links aswell your a diamond! Link to comment Share on other sites More sharing options...
Boss007 Posted June 16, 2012 Author Share Posted June 16, 2012 Button3 have no sense as button it should be just label $label1 = GUICtrlCreateLabel("Select Your Gender", 85, 60, 115, 15, BitOr($GUI_SS_DEFAULT_LABEL, $SS_CENTER)) GUICtrlSetBkColor(-1, 0x00FF00) Yes your correct newbie error. thanks for the code! Link to comment Share on other sites More sharing options...
Boss007 Posted June 17, 2012 Author Share Posted June 17, 2012 Another way is to use Radio buttons expandcollapse popup#include <ButtonConstants.au3> #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=gender select.kxf $Form2 = GUICreate("Select your Gender", 279, 213, 468, 254) $GroupBox1 = GUICtrlCreateGroup("", 48, 33, 185, 129) GUICtrlSetBkColor(-1, 0x008080) $cbx_male = GUICtrlCreateRadio("Male", 54, 107, 75, 25) GUICtrlSetBkColor(-1, 0x0054E3) $cbx_female = GUICtrlCreateRadio("Female", 149, 108, 75, 25) GUICtrlSetBkColor(-1, 0xFF00FF) $Button1 = GUICtrlCreateButton("Select Your Gender", 85, 52, 115, 25) GUICtrlSetBkColor(-1, 0x00FF00) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 SelectGender() EndSwitch WEnd Func SelectGender() If IsChecked($cbx_male) Then ; insert code here for male ElseIf IsChecked($cbx_female) Then ; insert code here for female Else MsgBox(48,'Warning','Male or Female must be selected!') EndIf EndFunc Func IsChecked($control) Return BitAnd(GUICtrlRead($control),$GUI_CHECKED) = $GUI_CHECKED EndFunc thanks this worked as well! 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