Sign in to follow this  
Followers 0
soonyee91

Perform function on selected checkbox (and tab)

5 posts in this topic

#1 ·  Posted (edited)

Basically I have no idea to proceed from here. Any tips on doing it? I'm able to perform function on selected checkbox but when I implement tab item. 

I want:

Tab1:

when select function 1,2,3, it will perform function

Tab2:

when select function 4,5,6, it will perform function

Tab3:

when select function 7,8,9, it will perform function

The problem I encounter is when I have select Tab 1 function 1,2,3 and go to Tab 2 and selected function 4,5,6. The code will perform function on 1,2,3,4,5,6. 

How to perform function only based on tab item? Is my explanation clear?

What I mean is to on Tab 1. I only want to perform function 1,2,3 but not 4,5,6,7,8,9

Below is my code for what I've described:

#include <GUIConstantsEx.au3>
#include <GuiButton.au3>
Example()

Func Example()
    Local $tab
    Local $msg

    GUICreate("My GUI Tab", 500, 500); will create a dialog box that when displayed is centered

    $btn_perform = GUICtrlCreateButton("Perform", 150, 420)
    $tab = GUICtrlCreateTab(10, 10, 400, 400)

    $t1 = GUICtrlCreateTabItem("tab1")
    $f1 = GUICtrlCreateCheckbox(" 1", 30, 260)
    $f2 = GUICtrlCreateCheckbox(" 2", 30, 280)
    $f3 = GUICtrlCreateCheckbox(" 3", 30, 300)

    $t2 = GUICtrlCreateTabItem("tab2")
    $f4 = GUICtrlCreateCheckbox(" 4", 30, 260)
    $f5 = GUICtrlCreateCheckbox(" 5", 30, 280)
    $f6 = GUICtrlCreateCheckbox(" 6", 30, 300)

    $t3 = GUICtrlCreateTabItem("tab3")
    $f7 = GUICtrlCreateCheckbox(" 7", 30, 260)
    $f8 = GUICtrlCreateCheckbox(" 8", 30, 280)
    $f9 = GUICtrlCreateCheckbox(" 9", 30, 300)

    GUICtrlCreateTabItem(""); end tabitem definition



    GUISetState()

    ; Run the GUI until the dialog is closed
    While 1
        $st1 = _GUICtrlButton_GetCheck($f1)
        $st2 = _GUICtrlButton_GetCheck($f2)
        $st3 = _GUICtrlButton_GetCheck($f3)
        $st4 = _GUICtrlButton_GetCheck($f4)
        $st5 = _GUICtrlButton_GetCheck($f5)
        $st6 = _GUICtrlButton_GetCheck($f6)
        $st7 = _GUICtrlButton_GetCheck($f7)
        $st8 = _GUICtrlButton_GetCheck($f8)
        $st9 = _GUICtrlButton_GetCheck($f9)

        $msg = GUIGetMsg()
        Switch $msg
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $btn_perform

                If $st1 = 1 Then
                    MsgBox("", "", "1")
                EndIf
                If $st2 = 1 Then
                    MsgBox("", "", "2")
                EndIf
                If $st3 = 1 Then
                    MsgBox("", "", "3")
                EndIf

                If $st4 = 1 Then
                    MsgBox("", "", "4")
                EndIf
                If $st5 = 1 Then
                    MsgBox("", "", "5")
                EndIf
                If $st6 = 1 Then
                    MsgBox("", "", "6")
                EndIf

                If $st7 = 1 Then
                    MsgBox("", "", "7")
                EndIf
                If $st8 = 1 Then
                    MsgBox("", "", "8")
                EndIf
                If $st9 = 1 Then
                    MsgBox("", "", "9")
                EndIf
        EndSwitch
    WEnd
EndFunc
Edited by soonyee91

Share this post


Link to post
Share on other sites



#region    ;************ Includes ************
#include <GuiTab.au3>
#include <GUIConstantsEx.au3>
#include <GuiButton.au3>
#endregion    ;************ Includes ************
Example()

Func Example()
    Local $tab
    Local $msg

    GUICreate("My GUI Tab", 500, 500); will create a dialog box that when displayed is centered

    $btn_perform = GUICtrlCreateButton("Perform", 150, 420)
    $tab = GUICtrlCreateTab(10, 10, 400, 400)

    $t1 = GUICtrlCreateTabItem("tab1")
    $f1 = GUICtrlCreateCheckbox(" 1", 30, 260)
    $f2 = GUICtrlCreateCheckbox(" 2", 30, 280)
    $f3 = GUICtrlCreateCheckbox(" 3", 30, 300)

    $t2 = GUICtrlCreateTabItem("tab2")
    $f4 = GUICtrlCreateCheckbox(" 4", 30, 260)
    $f5 = GUICtrlCreateCheckbox(" 5", 30, 280)
    $f6 = GUICtrlCreateCheckbox(" 6", 30, 300)

    $t3 = GUICtrlCreateTabItem("tab3")
    $f7 = GUICtrlCreateCheckbox(" 7", 30, 260)
    $f8 = GUICtrlCreateCheckbox(" 8", 30, 280)
    $f9 = GUICtrlCreateCheckbox(" 9", 30, 300)

    GUICtrlCreateTabItem(""); end tabitem definition

    GUISetState()

    ; Run the GUI until the dialog is closed
    While 1


        $msg = GUIGetMsg()
        Switch $msg
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $btn_perform
                $st1 = _GUICtrlButton_GetCheck($f1)
                $st2 = _GUICtrlButton_GetCheck($f2)
                $st3 = _GUICtrlButton_GetCheck($f3)
                $st4 = _GUICtrlButton_GetCheck($f4)
                $st5 = _GUICtrlButton_GetCheck($f5)
                $st6 = _GUICtrlButton_GetCheck($f6)
                $st7 = _GUICtrlButton_GetCheck($f7)
                $st8 = _GUICtrlButton_GetCheck($f8)
                $st9 = _GUICtrlButton_GetCheck($f9)

                $t = _GUICtrlTab_GetCurSel($tab)
                ConsoleWrite($t)
                Switch $t
                    Case 0


                        If $st1 = 1 Then
                            MsgBox("", "", "1")
                        EndIf
                        If $st2 = 1 Then
                            MsgBox("", "", "2")
                        EndIf
                        If $st3 = 1 Then
                            MsgBox("", "", "3")
                        EndIf
                    Case 1

                        If $st4 = 1 Then
                            MsgBox("", "", "4")
                        EndIf
                        If $st5 = 1 Then
                            MsgBox("", "", "5")
                        EndIf
                        If $st6 = 1 Then
                            MsgBox("", "", "6")
                        EndIf

                    Case 2

                        If $st7 = 1 Then
                            MsgBox("", "", "7")
                        EndIf
                        If $st8 = 1 Then
                            MsgBox("", "", "8")
                        EndIf
                        If $st9 = 1 Then
                            MsgBox("", "", "9")
                        EndIf

                EndSwitch
        EndSwitch
    WEnd
EndFunc   ;==>Example


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Also, better use GUICtrlRead instead of _GUICtrlButton_GetCheck (and $GUI_CHECKED/UNCHECKED for the state).

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

soonyee91,

Just check the boxes which appear on the current tab: ;)

#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $tab
    Local $msg

    GUICreate("My GUI Tab", 500, 500); will create a dialog box that when displayed is centered

    $btn_perform = GUICtrlCreateButton("Perform", 150, 420)
    $tab = GUICtrlCreateTab(10, 10, 400, 400)

    $t1 = GUICtrlCreateTabItem("tab1")
    $f1 = GUICtrlCreateCheckbox(" 1", 30, 260)
    $f2 = GUICtrlCreateCheckbox(" 2", 30, 280)
    $f3 = GUICtrlCreateCheckbox(" 3", 30, 300)

    $t2 = GUICtrlCreateTabItem("tab2")
    $f4 = GUICtrlCreateCheckbox(" 4", 30, 260)
    $f5 = GUICtrlCreateCheckbox(" 5", 30, 280)
    $f6 = GUICtrlCreateCheckbox(" 6", 30, 300)

    $t3 = GUICtrlCreateTabItem("tab3")
    $f7 = GUICtrlCreateCheckbox(" 7", 30, 260)
    $f8 = GUICtrlCreateCheckbox(" 8", 30, 280)
    $f9 = GUICtrlCreateCheckbox(" 9", 30, 300)

    GUICtrlCreateTabItem(""); end tabitem definition

    GUISetState()

    ; Run the GUI until the dialog is closed
    While 1


        $msg = GUIGetMsg()
        Switch $msg
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $btn_perform

                Switch GUICtrlRead($tab)
                    Case 0
                        If GUICtrlRead($f1) = 1 Then
                            MsgBox("", "", "1")
                        EndIf
                        If GUICtrlRead($f2) = 1 Then
                            MsgBox("", "", "2")
                        EndIf
                        If GUICtrlRead($f3) = 1 Then
                            MsgBox("", "", "3")
                        EndIf
                    Case 1
                        If GUICtrlRead($f4) = 1 Then
                            MsgBox("", "", "4")
                        EndIf
                        If GUICtrlRead($f5) = 1 Then
                            MsgBox("", "", "5")
                        EndIf
                        If GUICtrlRead($f6) = 1 Then
                            MsgBox("", "", "6")
                        EndIf
                    Case 2
                        If GUICtrlRead($f7) = 1 Then
                            MsgBox("", "", "7")
                        EndIf
                        If GUICtrlRead($f8) = 1 Then
                            MsgBox("", "", "8")
                        EndIf
                        If GUICtrlRead($f9) = 1 Then
                            MsgBox("", "", "9")
                        EndIf
                EndSwitch
        EndSwitch
    WEnd
EndFunc

All clear? :)

M23

Edit: Well it must the good solution as so many of us have posted it! :D

Edited by Melba23

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

Thanks for so many solution!!!! Appreciate alot!

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