Jump to content

Tab Related Question


Recommended Posts

Hi everyone,

Sorry to be a pest, but I couldn't find anything from the help or the search. Basically, I have 2 tabs and the problem I'm experiencing is that only one or the other tab would responds to my click, but never 2 tabs.

Let me explains it a little more here:

I have 2 tabs. Say tab1 has a button A and tab2 has a button B. Since tab1 is the first tab, by default it is active and I can click on the button and it will do whatever i wanted it to do. However, if I select tab2 and push button B, it would not respond. How do I get both tabs to respond? Thanks for any help in advance. :rolleyes:

#include <GuiConstants.au3>

Opt ("TrayIconDebug", 1)

$tnr_Bold = "Times New Roman Bold"

$tahoma_Bold = "Tahoma Bold"

GUICreate ("Test4", 310, 300, -1, -1)

GUICtrlCreateTab (0, 0, 310, 300)

GUICtrlCreateTabitem ("Misc.")

GUICtrlCreateLabel ("Choose software below to install then click RUN", 0, 40, 310, 20, $SS_CENTER)

GUICtrlSetFont (-1, 9, 400, 0, $tnr_Bold)

GUICtrlSetColor (-1, 0x191970)

$group_2 = GUICtrlCreateGroup ("", 20, 70, 270, 115)

$nai = GUICtrlCreateCheckbox ("NAI 8.5", 35, 90, 60, 20)

$defender = GUICtrlCreateCheckbox ("Windows Defender", 35, 120, 110, 20)

$adobe = GUICtrlCreateCheckbox ("Adobe Acrobat 8.0", 35, 150, 110, 20)

$vnc = GUICtrlCreateCheckbox ("VNC", 185, 90, 50, 20)

$vpn = GUICtrlCreateCheckbox ("Nortel Contivity", 185, 120, 90, 20)

$secureCRT = GUICtrlCreateCheckbox ("SecureCRT", 185, 150, 80, 20)

$run = GUICtrlCreateButton ("RUN", 110, 225, 90, 30)

GUICtrlSetFont (-1, 9, 400, 0, $tahoma_Bold)

dim $check1

dim $check2

dim $check3

dim $check4

dim $check5

dim $check6

GuiSetState(@SW_SHOW)

getMsg ()

;Miscellaneous Tab

Func getMsg ()

Do

$msg2 = GuiGetMsg()

$check1 = GUICtrlRead ($nai)

$check2 = GUICtrlRead ($defender)

$check3 = GUICtrlRead ($adobe)

$check4 = GUICtrlRead ($vnc)

$check5 = GUICtrlRead ($vpn)

$check6 = GUICtrlRead ($secureCRT)

Until $msg2 = $GUI_EVENT_CLOSE Or $msg2 = $Run

If $msg2 = $GUI_EVENT_CLOSE Then

Exit

EndIf

While $msg2 = $Run And $check1 = 4 And $check2 = 4 And $check3 = 4 And $check4 = 4 And $check5 = 4 And $check6 = 4

MsgBox (0, "", "Please select a program to install.")

getMsg ()

WEnd

If $check1 = 1 Then nai()

If $check2 = 1 Then defender ()

If $check3 = 1 Then acrobat ()

If $check4 = 1 Then vnc ()

If $check5 = 1 Then vpn ()

If $check6 = 1 Then secureCRT ()

MsgBox (0, "", "Installation is completed!")

getMsg ()

EndFunc

Func nai ()

MsgBox (0, "", "Running program NAI")

EndFunc

Func defender ()

MsgBox (0, "", "Running program Window Defender")

EndFunc

Func acrobat ()

MsgBox (0, "", "Running program Adobe Acrobat")

EndFunc

.

.

.

.

Link to comment
Share on other sites

I took a look at your program and I only see 1 tab... I apologize if I'm missing something.

Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Link to comment
Share on other sites

Here's a working TabItem demo, done by some really good looking flightless water fowl a little while ago.

It reads required information from an INI file, but you cut that our easily and directly code your stuff, if required.

And, like Airwold123 said, the code you showed only has one tab (literally 'tabitem').

:rolleyes:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Sorry for wasting your time, I was in a rush and posted the wrong script. :rolleyes: Here's the correct one.

#include <GUIConstants.au3>

Opt ("TrayIconDebug", 1)

GUICreate ("Automated Installer", 310, 300,-1, -1)

$lucida = "Lucida Sans Unicode"

$tahoma_Bold = "Tahoma Bold"

$tnr_Bold = "Times New Roman Bold"

GUICtrlCreateTab (0, 0, 310, 300, $WS_EX_TRANSPARENT)

GUICtrlCreateTabitem ("Microsoft")

GUICtrlCreateLabel("MICROSOFT SOFTWARE INSTALLATION", 0, 45, 310, 20, $SS_CENTER)

GUICtrlSetFont (-1, 9, 400, 0, $tnr_Bold)

GUICtrlSetColor (-1, 0x191970)

GUICtrlCreateLabel("Created by", 0, 65, 310, 20, $SS_CENTER)

GUICtrlCreateLabel("3PAR IT DEPARTMENT", 0, 85, 310, 20, $SS_CENTER)

GUICtrlSetColor (-1, 0xff0000)

GUICtrlSetFont (-1, 9, 600, 0, $lucida)

GUICtrlCreateLabel ("Version 1.1", 0, 280, 310, 20, $SS_CENTER)

GUICtrlSetColor (-1, 0x0000ff)

$group_1 = GUICtrlCreateGroup ("", 20, 110, 270, 163)

$project = GUICtrlCreateButton ("MS Project 2003", 30, 130, 110, 30)

GUICtrlSetFont (-1, 8, 400, 0, $tahoma_Bold)

$project_sp = GUICtrlCreateButton ("Project 2003 SP1", 30, 180, 110, 30)

GUICtrlSetFont (-1, 8, 400, 0, $tahoma_Bold)

$office_std = GUICtrlCreateButton ("Office 2003 STD", 170, 130, 110, 30)

GUICtrlSetFont (-1, 8, 400, 0, $tahoma_Bold)

$visio = GUICtrlCreateButton ("MS Visio 2003", 30, 230, 110, 30)

GUICtrlSetFont (-1, 8, 400, 0, $tahoma_Bold)

$office_pro = GUICtrlCreateButton ("Office 2003 PRO", 170, 180, 110, 30)

GUICtrlSetFont (-1, 8, 400, 0, $tahoma_Bold)

$exit = GUICtrlCreateButton ("Exit", 170, 230, 110, 30)

GUICtrlSetFont (-1, 8, 400, 0, $tahoma_Bold)

;Misc Tab

GUICtrlCreateTab (0, 0, 310, 300)

GUICtrlCreateTabitem ("Misc.")

GUICtrlCreateLabel ("Choose software below to install then click RUN", 0, 40, 310, 20, $SS_CENTER)

GUICtrlSetFont (-1, 9, 400, 0, $tnr_Bold)

GUICtrlSetColor (-1, 0x191970)

$group_2 = GUICtrlCreateGroup ("", 20, 70, 270, 115)

$nai = GUICtrlCreateCheckbox ("NAI 8.5", 35, 90, 60, 20)

$defender = GUICtrlCreateCheckbox ("Windows Defender", 35, 120, 110, 20)

$adobe = GUICtrlCreateCheckbox ("Adobe Acrobat 8.0", 35, 150, 110, 20)

$vnc = GUICtrlCreateCheckbox ("VNC", 185, 90, 50, 20)

$vpn = GUICtrlCreateCheckbox ("Nortel Contivity", 185, 120, 90, 20)

$secureCRT = GUICtrlCreateCheckbox ("SecureCRT", 185, 150, 80, 20)

$run = GUICtrlCreateButton ("RUN", 110, 225, 90, 30)

GUICtrlSetFont (-1, 9, 400, 0, $tahoma_Bold)

dim $check1

dim $check2

dim $check3

dim $check4

dim $check5

dim $check6

GUISetState(@SW_SHOW)

;Microsoft Tab

Do

$msg = GUIGetMsg()

Select

Case $msg = $visio

SoundPlay ( @WindowsDir & "\media\start.wav", 1)

$checkV = msVisio_Check ()

If $checkV Then

GUIGetMsg ()

Else

msVisio_Install ()

EndIf

Case $msg = $project

SoundPlay ( @WindowsDir & "\media\start.wav", 1)

$checkP = msProject_Check ()

If $checkP Then

GUIGetMsg ()

Else

msProject_Install ()

EndIf

Case $msg = $office_std

SoundPlay ( @WindowsDir & "\media\start.wav", 1)

$checkStd = officeStd_Check ()

If $checkStd Then

GUIGetMsg ()

Else

officeStd_Install ()

EndIf

Case $msg = $office_pro

SoundPlay ( @WindowsDir & "\media\start.wav", 1)

$checkPro = officePro_Check ()

If $checkPro Then

GUIGetMsg ()

Else

officePro_Install ()

EndIf

Case $msg = $project_sp

SoundPlay ( @WindowsDir & "\media\start.wav", 1)

msProject_Update ()

Case $msg = $exit

SoundPlay ( @WindowsDir & "\media\start.wav", 1)

Exit

Case $msg = $GUI_EVENT_CLOSE

Exit

EndSelect

Until 1 = 0

getMsg ()

;Miscellaneous Tab

Func getMsg ()

Do

$msg2 = GuiGetMsg()

$check1 = GUICtrlRead ($nai)

$check2 = GUICtrlRead ($defender)

$check3 = GUICtrlRead ($adobe)

$check4 = GUICtrlRead ($vnc)

$check5 = GUICtrlRead ($vpn)

$check6 = GUICtrlRead ($secureCRT)

Until $msg2 = $GUI_EVENT_CLOSE Or $msg2 = $Run

If $msg2 = $GUI_EVENT_CLOSE Then

Exit

EndIf

While $msg2 = $Run And $check1 = 4 And $check2 = 4 And $check3 = 4 And $check4 = 4 And $check5 = 4 And $check6 = 4

MsgBox (0, "", "Please select a program to install.")

getMsg ()

WEnd

If $check1 = 1 Then nai()

If $check2 = 1 Then defender ()

If $check3 = 1 Then acrobat ()

If $check4 = 1 Then vnc ()

If $check5 = 1 Then vpn ()

If $check6 = 1 Then secureCRT ()

MsgBox (0, "", "Installation is completed!")

getMsg ()

EndFunc

Link to comment
Share on other sites

Sorry for wasting your time, I was in a rush and posted the wrong script. :rambo: Here's the correct one.

Hhrumph... :rolleyes:

You should only be creating one 'Tab', and two 'TabItems'. Also, arrays make handling lists of controls much easier:

#include <GUIConstants.au3>

Opt("TrayIconDebug", 1)

GUICreate("Automated Installer", 310, 300, -1, -1)
$lucida = "Lucida Sans Unicode"
$tahoma_Bold = "Tahoma Bold"
$tnr_Bold = "Times New Roman Bold"
GUICtrlCreateTab(0, 0, 310, 300, $WS_EX_TRANSPARENT)
GUICtrlCreateTabItem("Microsoft")
GUICtrlCreateLabel("MICROSOFT SOFTWARE INSTALLATION", 0, 45, 310, 20, $SS_CENTER)
GUICtrlSetFont(-1, 9, 400, 0, $tnr_Bold)
GUICtrlSetColor(-1, 0x191970)
GUICtrlCreateLabel("Created by", 0, 65, 310, 20, $SS_CENTER)
GUICtrlCreateLabel("3PAR IT DEPARTMENT", 0, 85, 310, 20, $SS_CENTER)
GUICtrlSetColor(-1, 0xff0000)
GUICtrlSetFont(-1, 9, 600, 0, $lucida)
GUICtrlCreateLabel("Version 1.1", 0, 280, 310, 20, $SS_CENTER)
GUICtrlSetColor(-1, 0x0000ff)
$group_1 = GUICtrlCreateGroup("", 20, 110, 270, 163)
$project = GUICtrlCreateButton("MS Project 2003", 30, 130, 110, 30)
GUICtrlSetFont(-1, 8, 400, 0, $tahoma_Bold)
$project_sp = GUICtrlCreateButton("Project 2003 SP1", 30, 180, 110, 30)
GUICtrlSetFont(-1, 8, 400, 0, $tahoma_Bold)
$office_std = GUICtrlCreateButton("Office 2003 STD", 170, 130, 110, 30)
GUICtrlSetFont(-1, 8, 400, 0, $tahoma_Bold)
$visio = GUICtrlCreateButton("MS Visio 2003", 30, 230, 110, 30)
GUICtrlSetFont(-1, 8, 400, 0, $tahoma_Bold)
$office_pro = GUICtrlCreateButton("Office 2003 PRO", 170, 180, 110, 30)
GUICtrlSetFont(-1, 8, 400, 0, $tahoma_Bold)
$exit = GUICtrlCreateButton("Exit", 170, 230, 110, 30)
GUICtrlSetFont(-1, 8, 400, 0, $tahoma_Bold)

;Misc Tab
GUICtrlCreateTab(0, 0, 310, 300)
GUICtrlCreateTabItem("Misc.")
GUICtrlCreateLabel("Choose software below to install then click RUN", 0, 40, 310, 20, $SS_CENTER)
GUICtrlSetFont(-1, 9, 400, 0, $tnr_Bold)
GUICtrlSetColor(-1, 0x191970)
$group_2 = GUICtrlCreateGroup("", 20, 70, 270, 115)
Global $CheckBoxes[6] = ["NAI 8.5", "Windows Defender", "Adobe Acrobat 8.0", "VNC", "Nortel Contivity", "SecureCRT"]
$CheckBoxes[0] = GUICtrlCreateCheckbox($CheckBoxes[0], 35, 90, 60, 20)
$CheckBoxes[1] = GUICtrlCreateCheckbox($CheckBoxes[1], 35, 120, 110, 20)
$CheckBoxes[2] = GUICtrlCreateCheckbox($CheckBoxes[2], 35, 150, 110, 20)
$CheckBoxes[3] = GUICtrlCreateCheckbox($CheckBoxes[3], 185, 90, 50, 20)
$CheckBoxes[4] = GUICtrlCreateCheckbox($CheckBoxes[4], 185, 120, 90, 20)
$CheckBoxes[5] = GUICtrlCreateCheckbox($CheckBoxes[5], 185, 150, 80, 20)
$run = GUICtrlCreateButton("RUN", 110, 225, 90, 30)
GUICtrlSetFont(-1, 9, 400, 0, $tahoma_Bold)

GUISetState(@SW_SHOW)

Do
    $msg = GUIGetMsg()
    Select
        Case $msg = $visio
            MsgBox(64, "Debug:Button Hit", "Visio")
        Case $msg = $project
            MsgBox(64, "Debug:Button Hit", "Project")
        Case $msg = $office_std
            MsgBox(64, "Debug:Button Hit", "Office Std")
        Case $msg = $office_pro
            MsgBox(64, "Debug:Button Hit", "Office Pro")
        Case $msg = $project_sp
            MsgBox(64, "Debug:Button Hit", "Project Update")
        Case $msg = $run
            $sText = "Selected options:" & @CRLF
            For $n = 0 To 5
                If ControlCommand("Automated Installer", "", $CheckBoxes[$n], "IsChecked") Then _
                        $sText &= @TAB & ControlGetText("Automated Installer", "", $CheckBoxes[$n]) & @CRLF
            Next
            MsgBox(64, "Debug:Button Hit", $sText)
        Case $msg = $exit
            Exit
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
Until 0

:x

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I was wondering how you would go about simplifying my codes a lil bit more with these two concerns. One thing I wanted do but couldn't figure it out is "If none of the checkbox is checked, and when the user click Run, a msgbox will appear and tell them to make a selection. blush.gif Secondly, I don't really like the function "execute_program ()," I know it can be done via For Loop to simplify it a little more, but I couldn't figure that one out either. :rolleyes: Any help is greatly welcome and appreciated.

Thanks in advance!

#include <GUIConstants.au3>

Opt("TrayIconDebug", 1)

GUICreate("Automated Installer", 310, 300, -1, -1)
$lucida = "Lucida Sans Unicode"
$tahoma_Bold = "Tahoma Bold"
$tnr_Bold = "Times New Roman Bold"
GUICtrlCreateTab(0, 0, 310, 300, $WS_EX_TRANSPARENT)
GUICtrlCreateTabItem("Microsoft")
GUICtrlCreateLabel("MICROSOFT SOFTWARE INSTALLATION", 0, 45, 310, 20, $SS_CENTER)
GUICtrlSetFont(-1, 9, 400, 0, $tnr_Bold)
GUICtrlSetColor(-1, 0x191970)
GUICtrlCreateLabel("Created by", 0, 65, 310, 20, $SS_CENTER)
GUICtrlCreateLabel("3PAR IT DEPARTMENT", 0, 85, 310, 20, $SS_CENTER)
GUICtrlSetColor(-1, 0xff0000)
GUICtrlSetFont(-1, 9, 600, 0, $lucida)
GUICtrlCreateLabel("Version 1.1", 0, 280, 310, 20, $SS_CENTER)
GUICtrlSetColor(-1, 0x0000ff)
$group_1 = GUICtrlCreateGroup("", 20, 110, 270, 163)
$project = GUICtrlCreateButton("MS Project 2003", 30, 130, 110, 30)
GUICtrlSetFont(-1, 8, 400, 0, $tahoma_Bold)
$project_sp = GUICtrlCreateButton("Project 2003 SP1", 30, 180, 110, 30)
GUICtrlSetFont(-1, 8, 400, 0, $tahoma_Bold)
$office_std = GUICtrlCreateButton("Office 2003 STD", 170, 130, 110, 30)
GUICtrlSetFont(-1, 8, 400, 0, $tahoma_Bold)
$visio = GUICtrlCreateButton("MS Visio 2003", 30, 230, 110, 30)
GUICtrlSetFont(-1, 8, 400, 0, $tahoma_Bold)
$office_pro = GUICtrlCreateButton("Office 2003 PRO", 170, 180, 110, 30)
GUICtrlSetFont(-1, 8, 400, 0, $tahoma_Bold)
$exit = GUICtrlCreateButton("Exit", 170, 230, 110, 30)
GUICtrlSetFont(-1, 8, 400, 0, $tahoma_Bold)

;Misc Tab
GUICtrlCreateTab(0, 0, 310, 300)
GUICtrlCreateTabItem("Misc.")
GUICtrlCreateLabel("Choose software below to install then click RUN", 0, 40, 310, 20, $SS_CENTER)
GUICtrlSetFont(-1, 9, 400, 0, $tnr_Bold)
GUICtrlSetColor(-1, 0x191970)
$group_2 = GUICtrlCreateGroup("", 20, 70, 270, 115)
Global $CheckBoxes[6] = ["NAI 8.5", "Windows Defender", "Adobe Acrobat 8.0", "VNC", "Nortel Contivity", "SecureCRT"]
$CheckBoxes[0] = GUICtrlCreateCheckbox($CheckBoxes[0], 35, 90, 60, 20)
$CheckBoxes[1] = GUICtrlCreateCheckbox($CheckBoxes[1], 35, 120, 110, 20)
$CheckBoxes[2] = GUICtrlCreateCheckbox($CheckBoxes[2], 35, 150, 110, 20)
$CheckBoxes[3] = GUICtrlCreateCheckbox($CheckBoxes[3], 185, 90, 50, 20)
$CheckBoxes[4] = GUICtrlCreateCheckbox($CheckBoxes[4], 185, 120, 90, 20)
$CheckBoxes[5] = GUICtrlCreateCheckbox($CheckBoxes[5], 185, 150, 80, 20)
$run = GUICtrlCreateButton("RUN", 110, 225, 90, 30)
GUICtrlSetFont(-1, 9, 400, 0, $tahoma_Bold)

GUISetState(@SW_SHOW)

Do
    $msg = GUIGetMsg()
    Select
        Case $msg = $visio
            SoundPlay ( @WindowsDir & "\media\start.wav", 1)
            $checkV = msVisio_Check ()
            If $checkV Then
                GUIGetMsg ()
            Else
                msVisio_Install ()
            EndIf
        Case $msg = $project
            SoundPlay ( @WindowsDir & "\media\start.wav", 1)
            $checkP = msProject_Check ()
            If $checkP Then
                GUIGetMsg ()
            Else
                msProject_Install ()
            EndIf
        Case $msg = $office_std
            SoundPlay ( @WindowsDir & "\media\start.wav", 1)
            $checkStd = officeStd_Check ()
            If $checkStd Then
                GUIGetMsg ()
            Else
                officeStd_Install ()
            EndIf
        Case $msg = $office_pro
            SoundPlay ( @WindowsDir & "\media\start.wav", 1)
            $checkPro = officePro_Check ()
            If $checkPro Then
                GUIGetMsg ()
            Else
                officePro_Install ()
            EndIf
        Case $msg = $project_sp
            SoundPlay ( @WindowsDir & "\media\start.wav", 1)        
            msProject_Update ()
        Case $msg = $run
            Local $j
                For $n = 0 To 5
                    If ControlCommand("Automated Installer", "", $CheckBoxes[$n], "IsChecked") Then
                        execute_program ($n)
                    EndIf
                Next
        Case $msg = $exit
            Exit
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
Until 0

Func execute_program ($n)
    If $n = 0 Then nai_install()
    If $n = 1 Then defender_install ()
    If $n = 2 Then acrobat_install ()
    If $n = 3 Then vnc_install ()
    If $n = 4 Then vpn_install ()
    If $n = 5 Then secureCRT_install ()
EndFunc
Link to comment
Share on other sites

I was wondering how you would go about simplifying my codes a lil bit more with these two concerns. One thing I wanted do but couldn't figure it out is "If none of the checkbox is checked, and when the user click Run, a msgbox will appear and tell them to make a selection. blush.gif Secondly, I don't really like the function "execute_program ()," I know it can be done via For Loop to simplify it a little more, but I couldn't figure that one out either. :rolleyes: Any help is greatly welcome and appreciated.

Put a flag like $Selection = False before the loop that tests all the checkboxes.

In the If/Then inside the loop for a checked box, change the flag to $Selection = True. Then after the loop is done:

If Not $Selection Then MsgBox(16, "Error", "Nothing to do, you must check one of the boxes!", 10)

I prefer GuiOnEventMode to GuiGetMsg(). I would put the whole thing in EventMode and have just one function to handle all the buttons. The function can tell which button by @GUI_CTRLID macro.

:rambo:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...