Pawi Posted March 7, 2011 Posted March 7, 2011 Allright, it's been a while from last time i posted. But guys, i really need u help! I'm brainstorming ATM, how the hell my program can lunch multiple functions. Let's, for ex. say, i wrote a program, That can block unwanted ad-s in Internet Browser, and Auto-log on facebook. There are 4 button's: RadioButton1 - Activate Ad-s Blocker RadioButton2 - Disable Ad-s Blocker RadioButton3 - Activate Auto-login RadioButton4 - Disable Auto-Login I got only one idea, how to make it. Func _Disable() ... EndFunc Func _AutoLogin() ... EndFunc While 1 If GUICtrlRead(RadioButton1) = $GUI_CHECKED Then __Disable() Endif If GUICtrlRead(RadioButton3) = $GUI_CHECKED Then __AutoLogin() Endif WEnd It's ok, while i got only 2 functions. But if i would have like 20, it will make a mess as hell. Anyone know better way to do it? i feel i'm doin it wrong.
Moderators Melba23 Posted March 7, 2011 Moderators Posted March 7, 2011 Pawi, I would suggest using arrays. This should give you the idea - pressing the button fires the checked radios: #include <GUIConstantsEx.au3> Global $aRadio[4], $aAction[4] = ["Action 1", "Action 2", "Action 3", "Action 4"] $hGUI = GUICreate("Test", 500, 500) GUIStartGroup() For $i = 0 To 3 $aRadio[$i] = GUICtrlCreateRadio($aAction[$i], 10, 20 + ($i * 40), 200, 20) GUIStartGroup() Next $hButton = GUICtrlCreateButton("Action", 10, 200, 80, 30) $hCheck = GUICtrlCreateCheckbox(" Action on radio click", 10, 250, 200, 20) GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $aRadio[0] To $aRadio[3] If GUICtrlRead($hCheck) = 1 Then ContinueCase Case $hButton For $i = 0 To 3 If GUICtrlRead($aRadio[$i]) = 1 Then MsgBox(0, "Action", $aAction[$i]) Next EndSwitch WEnd If you check the checkbox, then you also fire the actions when you alter one of the radios - which may be of use too. Please ask if you have any quesitons. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
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