Sign in to follow this  
Followers 0
WesW

Tab Help

9 posts in this topic

#1 ·  Posted (edited)

Hello, I am trying to create a tab from with buttons to install software... Each tab will have different software to install. I can’t seem to get the buttons to work inside the tab. Any help would be great... Thanks very much!

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=C:\Users\walkersw\Documents\Gui.kxf
$Gui = GUICreate("Test", 301, 525, 214, 131)
$tab = GUICtrlCreateTab(5, 5, 290, 510)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$tab1 = GUICtrlCreateTabItem("Tab1")
$Button1 = GUICtrlCreateButton("Install", 15, 74, 49, 25, $WS_GROUP)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label1 = GUICtrlCreateLabel("01-Startup.exe", 71, 78, 73, 17)

$tab2 = GUICtrlCreateTabItem("Tab2")
$tab3 = GUICtrlCreateTabItem("Tab3")
$tab4 = GUICtrlCreateTabItem("Tab4")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
                Case $Tab1

                        Case $Button1
            FileCopy("\\path", "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup")
            Sleep(1000)
            MsgBox(64, 'Startup.exe.', 'File Copied.')

    EndSwitch
WEnd
Edited by WesW

Share this post


Link to post
Share on other sites



A few small issues with your script.

First, you have 2 program loops (WHILE 1 .... WEND), and the program will never leave the first one until it completely exits. So the 2nd WHILE loop was never getting executed.

Second, your SWITCH statement was indented oddly, making me think you misunderstood how they are used. You should review the help on their usage if you need.

Regardless, no nesting is required in this case, you don't need to worry about what tab each button is on, as each control handle should be stored in a unique variable (or array element). All you need to check for is if $button1 was pressed. You might consider a variable naming convention such as $t1btn1 (tab 1 button 1) if it helps you keep it straight.

Below I commented out the superfluous WHILE loop, which isn't needed at all. Also commented out the Filecopy() function, just to get the script working as a test, but I assume you'll have valid paths to use in there once the program is working.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=C:\Users\walkersw\Documents\Gui.kxf
$Gui = GUICreate("Test", 301, 525, 214, 131)
$tab = GUICtrlCreateTab(5, 5, 290, 510)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$tab1 = GUICtrlCreateTabItem("Tab1")
$Button1 = GUICtrlCreateButton("Install", 15, 74, 49, 25, $WS_GROUP)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label1 = GUICtrlCreateLabel("01-Startup.exe", 71, 78, 73, 17)

$tab2 = GUICtrlCreateTabItem("Tab2")
$tab3 = GUICtrlCreateTabItem("Tab3")
$tab4 = GUICtrlCreateTabItem("Tab4")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;~ While 1
;~  $nMsg = GUIGetMsg()
;~  Switch $nMsg
;~      Case $GUI_EVENT_CLOSE
;~          Exit

;~  EndSwitch
;~ WEnd

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
;~            FileCopy("\\path", "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup")
;~            Sleep(1000)
            MsgBox(64, 'Startup.exe.', 'File Copied.')

    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

A few small issues with your script.

First, you have 2 program loops (WHILE 1 .... WEND), and the program will never leave the first one until it completely exits. So the 2nd WHILE loop was never getting executed.

Second, your SWITCH statement was indented oddly, making me think you misunderstood how they are used. You should review the help on their usage if you need.

Regardless, no nesting is required in this case, you don't need to worry about what tab each button is on, as each control handle should be stored in a unique variable (or array element). All you need to check for is if $button1 was pressed. You might consider a variable naming convention such as $t1btn1 (tab 1 button 1) if it helps you keep it straight.

Below I commented out the superfluous WHILE loop, which isn't needed at all. Also commented out the Filecopy() function, just to get the script working as a test, but I assume you'll have valid paths to use in there once the program is working.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=C:\Users\walkersw\Documents\Gui.kxf
$Gui = GUICreate("Test", 301, 525, 214, 131)
$tab = GUICtrlCreateTab(5, 5, 290, 510)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$tab1 = GUICtrlCreateTabItem("Tab1")
$Button1 = GUICtrlCreateButton("Install", 15, 74, 49, 25, $WS_GROUP)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label1 = GUICtrlCreateLabel("01-Startup.exe", 71, 78, 73, 17)

$tab2 = GUICtrlCreateTabItem("Tab2")
$tab3 = GUICtrlCreateTabItem("Tab3")
$tab4 = GUICtrlCreateTabItem("Tab4")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;~ While 1
;~  $nMsg = GUIGetMsg()
;~  Switch $nMsg
;~      Case $GUI_EVENT_CLOSE
;~          Exit

;~  EndSwitch
;~ WEnd

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
;~            FileCopy("\\path", "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup")
;~            Sleep(1000)
            MsgBox(64, 'Startup.exe.', 'File Copied.')

    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

Stupid me!!!!! Thanks for your help. I might have a question later… Thanks for your help…

A few small issues with your script.

First, you have 2 program loops (WHILE 1 .... WEND), and the program will never leave the first one until it completely exits. So the 2nd WHILE loop was never getting executed.

Second, your SWITCH statement was indented oddly, making me think you misunderstood how they are used. You should review the help on their usage if you need.

Regardless, no nesting is required in this case, you don't need to worry about what tab each button is on, as each control handle should be stored in a unique variable (or array element). All you need to check for is if $button1 was pressed. You might consider a variable naming convention such as $t1btn1 (tab 1 button 1) if it helps you keep it straight.

Below I commented out the superfluous WHILE loop, which isn't needed at all. Also commented out the Filecopy() function, just to get the script working as a test, but I assume you'll have valid paths to use in there once the program is working.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=C:\Users\walkersw\Documents\Gui.kxf
$Gui = GUICreate("Test", 301, 525, 214, 131)
$tab = GUICtrlCreateTab(5, 5, 290, 510)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$tab1 = GUICtrlCreateTabItem("Tab1")
$Button1 = GUICtrlCreateButton("Install", 15, 74, 49, 25, $WS_GROUP)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Label1 = GUICtrlCreateLabel("01-Startup.exe", 71, 78, 73, 17)

$tab2 = GUICtrlCreateTabItem("Tab2")
$tab3 = GUICtrlCreateTabItem("Tab3")
$tab4 = GUICtrlCreateTabItem("Tab4")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;~ While 1
;~  $nMsg = GUIGetMsg()
;~  Switch $nMsg
;~      Case $GUI_EVENT_CLOSE
;~          Exit

;~  EndSwitch
;~ WEnd

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
;~            FileCopy("\\path", "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup")
;~            Sleep(1000)
            MsgBox(64, 'Startup.exe.', 'File Copied.')

    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

Glad to be able to help. I'll keep an eye on this topic for a bit if you have any other questions.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Ok, heres my other question, I am have 3 radio buttons setup and trying to run 3 installs from one button. the way I have it now the first install run no matter what radio button I click! please help....

Case $t3btn1   ;Radio1 checked
            If BitAND(GUICtrlGetState($Radio1), $GUI_HIDE) Then GUICtrlSetState($Radio1, $GUI_SHOW)
            Run("\\Network path\Bentley Installs\Other Installs\Designer build V8I 03.16.2011.exe")
    Case $t3btn1   ;Radio1 checked
            If BitAND(GUICtrlGetState($Radio1), $GUI_HIDE) Then GUICtrlSetState($Radio1, $GUI_SHOW)
            Run("\\Network path\Bentley Installs\Other Installs\Engineer Build 03.27.2011.exe")

    Case $t3btn1
            If BitAND(GUICtrlGetState($Radio3), $GUI_HIDE) Then GUICtrlSetState($Radio3, $GUI_SHOW)
            Run("\\Network path\Bentley Installs\pwclt081107443en\dotnetfx\dotnetfx35.exe")
Edited by WesW

Share this post


Link to post
Share on other sites

Ok, heres my other question, I am have 3 radio buttons setup and trying to run 3 installs from one button. the way I have it now the first install run no matter what radio button I click! please help....

Case $t3btn1   ;Radio1 checked
            If BitAND(GUICtrlGetState($Radio1), $GUI_HIDE) Then GUICtrlSetState($Radio1, $GUI_SHOW)
            Run("\\Network path\Bentley Installs\Other Installs\Designer build V8I 03.16.2011.exe")
    Case $t3btn1   ;Radio1 checked
            If BitAND(GUICtrlGetState($Radio1), $GUI_HIDE) Then GUICtrlSetState($Radio1, $GUI_SHOW)
            Run("\\Network path\Bentley Installs\Other Installs\Engineer Build 03.27.2011.exe")

    Case $t3btn1
            If BitAND(GUICtrlGetState($Radio3), $GUI_HIDE) Then GUICtrlSetState($Radio3, $GUI_SHOW)
            Run("\\Network path\Bentley Installs\pwclt081107443en\dotnetfx\dotnetfx35.exe")

Hope everyone had a fun friday night. can someone show me what I am doing wrong here.

Share this post


Link to post
Share on other sites

Hope everyone had a fun friday night. can someone show me what I am doing wrong here.

Just a typical friday night :)

I would expect BitAnd() to return a number and for you to compare that number to something. Have a look at GUICtrlCreateRadio for an example.

I may expect something like for example

If BitAND(GUICtrlGetState($Radio1), $GUI_HIDE) = $GUI_HIDE Then;...

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Why are you checking a radio button to see if it's hidden? Shouldn't you be looking to see if it's checked with $GUI_CHECKED instead? That's the first thing I see wrong, without more code I'd be shooting in the dark to try and see what is happening.

EDIT: Also, you should probably be using GUICtrlRead to check that it's checked or not. I forget if GetState will tell you that or not, as I haven't ever tried it that way.

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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