Sign in to follow this  
Followers 0
Pawi

Multi-Functions

2 posts in this topic

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.

Share this post


Link to post
Share on other sites



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. :P

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0