Sign in to follow this  
Followers 0
Casey

InputBox to GUICtrlCreateLabel

5 posts in this topic

#cs
    All,
    
    I hope this is understandable. With this being my first attempt at a GUI and being new and all to AutoIt.
    I have trimmed out most of the code minimize what you would need to wade through on the other tabs.
    
    Question 1. Why does the data entered in the input boxes show through the various tabs or what
    can be done to correct it? I would like to use the data stored in this variable elsewhere
    like sending to a label printer but would also like it visible while the script is open.
    
    question 2. Any idea on how to take the InputBox data and change the case to capital letters before passing it to
    the label?
    
    V/r
    
    Casey
    
#ce
#include <GuiConstants.au3>
#include <File.au3>


; GUI
$GuiMain = GUICreate("2 GUI Questions", 1120, 490)
GUISetIcon(@SystemDir & "\drwatson.exe", 0)

$tab = GUICtrlCreateTab(5, 0, 1120, 900)
$tab0 = GUICtrlCreateTabItem("Application Installs")
$tab1 = GUICtrlCreateTabItem("Application Uninstalls")
;####################################################
$tab2 = GUICtrlCreateTabItem("Check List")
$CheckList_Button_1 = GUICtrlCreateButton("Old Name", 275, 143, 70, 20, 0x2000)
$CheckList_Button_2 = GUICtrlCreateButton("Old Serial", 275, 163, 70, 20, 0x2000)
$CheckList_Button_3 = GUICtrlCreateButton("New Name", 275, 183, 70, 20, 0x2000)
$CheckList_Button_4 = GUICtrlCreateButton("New Serial", 275, 203, 70, 20, 0x2000)
;#####################################################
$tab3 = GUICtrlCreateTabItem("Documentation")
$tab4 = GUICtrlCreateTabItem("Images")
$tab5 = GUICtrlCreateTabItem("Fixes")
$tab6 = GUICtrlCreateTabItem("New System Build")
$tab7 = GUICtrlCreateTabItem("Cartoon")
GUICtrlCreateTabItem("")

GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $CheckList_Button_1
            $CheckList_Button_1a = InputBox("Old Name", "Type OLD CPU Name without \\PSU-.", "", " M11")
            If @error == 0 Then
                $CheckList_Label_1b = GUICtrlCreateLabel("PSU-" & $CheckList_Button_1a, 350, 145, 249, 170, 0x2000)
                GUICtrlSetColor(-1, 0x99);0x99 = Blue, 0xFFFFFF = White, 0x571B7e = Purplish, 0x6633 = Green
            ElseIf @error == 1 Then
            EndIf
        Case $msg = $CheckList_Button_2
            $CheckList_Button_2a = InputBox("Old Serial", "Enter the OLD serial number..")
            If @error == 0 Then
                $CheckList_Label_2b = GUICtrlCreateLabel($CheckList_Button_2a, 350, 165, 249, 17)
                GUICtrlSetColor(-1, 0x99);0x99 = Blue
            ElseIf @error == 1 Then
            EndIf
        Case $msg = $CheckList_Button_3
            $CheckList_Button_3a = InputBox("New Name", "Type NEW CPU Name without \\PSU-.", "", " M11")
            If @error == 0 Then
                $CheckList_Label_3b = GUICtrlCreateLabel("PSU-" & $CheckList_Button_3a, 350, 185, 249, 17)
                GUICtrlSetColor(-1, 0x6633);0x6633 = Green
            ElseIf @error == 1 Then
            EndIf
        Case $msg = $CheckList_Button_4
            $CheckList_Button_4a = InputBox("New Serial", "Enter the NEW serial number..")
            If @error == 0 Then
                $CheckList_Label_4b = GUICtrlCreateLabel($CheckList_Button_4a, 350, 205, 249, 17)
                GUICtrlSetColor(-1, 0x6633)
            ElseIf @error == 1 Then
            EndIf
    EndSelect
WEnd

Share this post


Link to post
Share on other sites



Your problem here is that you're creating the labels out of the GUI creation code and your script assumes that you create these labels on every tab.

A solution will be to create these labels at the begining and hiding them. After your Input pops up and gets the data, you can "un-hide" the labels and update their content.

I did this for the first input - if the solution is acceptable to you, you will have to change the code for others too.

#include <GuiConstants.au3>
#include <File.au3>


; GUI
$GuiMain = GUICreate("2 GUI Questions", 1120, 490)
GUISetIcon(@SystemDir & "\drwatson.exe", 0)

$tab = GUICtrlCreateTab(5, 0, 1120, 900)
$tab0 = GUICtrlCreateTabItem("Application Installs")
$tab1 = GUICtrlCreateTabItem("Application Uninstalls")
;####################################################
$tab2 = GUICtrlCreateTabItem("Check List")
$CheckList_Button_1 = GUICtrlCreateButton("Old Name", 275, 143, 70, 20, 0x2000)
;#### code added here ----------
$CheckList_Label_1b = GUICtrlCreateLabel("", 350, 145, 249, 170, 0x2000)
GUICtrlSetColor(-1, 0x99)
GUICtrlSetState(-1, $GUI_HIDE)
;#### ---------------------------
$CheckList_Button_2 = GUICtrlCreateButton("Old Serial", 275, 163, 70, 20, 0x2000)
$CheckList_Button_3 = GUICtrlCreateButton("New Name", 275, 183, 70, 20, 0x2000)
$CheckList_Button_4 = GUICtrlCreateButton("New Serial", 275, 203, 70, 20, 0x2000)
;#####################################################
$tab3 = GUICtrlCreateTabItem("Documentation")
$tab4 = GUICtrlCreateTabItem("Images")
$tab5 = GUICtrlCreateTabItem("Fixes")
$tab6 = GUICtrlCreateTabItem("New System Build")
$tab7 = GUICtrlCreateTabItem("Cartoon")
GUICtrlCreateTabItem("")

GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $CheckList_Button_1
            $CheckList_Button_1a = InputBox("Old Name", "Type OLD CPU Name without \\PSU-.", "", " M11")
            If @error == 0 Then
                ;#### code removed/changed here ----------------
                GUICtrlSetState($CheckList_Label_1b, $GUI_SHOW)
                GUICtrlSetData($CheckList_Label_1b, "PSU-" & $CheckList_Button_1a)
                ;#### ------------------------------------------
            ElseIf @error == 1 Then
            EndIf
        Case $msg = $CheckList_Button_2
            $CheckList_Button_2a = InputBox("Old Serial", "Enter the OLD serial number..")
            If @error == 0 Then
                $CheckList_Label_2b = GUICtrlCreateLabel($CheckList_Button_2a, 350, 165, 249, 17)
                GUICtrlSetColor(-1, 0x99);0x99 = Blue
            ElseIf @error == 1 Then
            EndIf
        Case $msg = $CheckList_Button_3
            $CheckList_Button_3a = InputBox("New Name", "Type NEW CPU Name without \\PSU-.", "", " M11")
            If @error == 0 Then
                $CheckList_Label_3b = GUICtrlCreateLabel("PSU-" & $CheckList_Button_3a, 350, 185, 249, 17)
                GUICtrlSetColor(-1, 0x6633);0x6633 = Green
            ElseIf @error == 1 Then
            EndIf
        Case $msg = $CheckList_Button_4
            $CheckList_Button_4a = InputBox("New Serial", "Enter the NEW serial number..")
            If @error == 0 Then
                $CheckList_Label_4b = GUICtrlCreateLabel($CheckList_Button_4a, 350, 205, 249, 17)
                GUICtrlSetColor(-1, 0x6633)
            ElseIf @error == 1 Then
            EndIf
    EndSelect
WEnd

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

As for this

question 2. Any idea on how to take the InputBox data and change the case to capital letters before passing it to the label?

Check StringUpper().

Share this post


Link to post
Share on other sites

CODE
CODE

#cs

Thank you both for your assistance. After pouring over the forum for several hours

looking at pieces of code I am glad I sought your assistance.

For any beginners like me who should happen across this post this should show two ways

with two completely different results. For me it was a good lesson on exactly why

there is $GUI_HIDE and definitely how to put it to good use.

Thanks again,

Casey

#ce

#include <GuiConstants.au3>

#include <File.au3>

; GUI

$GuiMain = GUICreate("2 GUI Questions", 1120, 490)

GUISetIcon(@SystemDir & "\drwatson.exe", 0)

$tab = GUICtrlCreateTab(5, 0, 1120, 900)

$tab0 = GUICtrlCreateTabItem("Application Installs")

$tab1 = GUICtrlCreateTabItem("Application Uninstalls")

;####################################################

$tab2 = GUICtrlCreateTabItem("Check List")

$CheckList_Button_1 = GUICtrlCreateButton("Old Name", 275, 143, 70, 20, 0x2000)

;#### code added here by enaiman ----------

$CheckList_Label_1 = GUICtrlCreateLabel("", 350, 145, 249, 170, 0x2000)

GUICtrlSetColor(-1, 0x99)

GUICtrlSetState(-1, $GUI_HIDE)

;####---------------------------

;#### Change works exactly the way that I wanted it to. Changed remainder of labels.

;#### Altered variable names slightly so that it is easier to see relation/sequence

;#### in case below.

$CheckList_Button_2 = GUICtrlCreateButton("Old Serial", 275, 163, 70, 20, 0x2000)

$CheckList_Label_2 = GUICtrlCreateLabel("", 350, 165, 249, 17)

GUICtrlSetColor(-1, 0x99) ;0x99 = Blue

GUICtrlSetState(-1, $GUI_HIDE)

$CheckList_Button_3 = GUICtrlCreateButton("New Name", 275, 183, 70, 20, 0x2000)

$CheckList_Label_3 = GUICtrlCreateLabel("", 350, 185, 249, 17)

GUICtrlSetColor(-1, 0x6633) ;0x6633 = Green

GUICtrlSetState(-1, $GUI_HIDE)

$CheckList_Button_4 = GUICtrlCreateButton("New Serial", 275, 203, 70, 20, 0x2000)

$CheckList_Label_4 = GUICtrlCreateLabel("", 350, 205, 249, 17)

GUICtrlSetColor(-1, 0x6633)

GUICtrlSetState(-1, $GUI_HIDE)

;#####################################################

$tab3 = GUICtrlCreateTabItem("Documentation")

$tab4 = GUICtrlCreateTabItem("Images")

$tab5 = GUICtrlCreateTabItem("Fixes")

$tab6 = GUICtrlCreateTabItem("New System Build")

$tab7 = GUICtrlCreateTabItem("Cartoon")

GUICtrlCreateTabItem("")

GUISetState()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $CheckList_Button_1

$CheckList_Button_1a = InputBox("Old Name", "Type OLD CPU Name without \\PSU-.", "", " M11")

If @error == 0 Then

;#### code removed/changed here initially by enaiman changed slightly based on RobSaunders recommendation for question 2 ------

;####If there is a better way please provide input. --------------------

$CheckList_Button_1b = StringUpper("PSU-" & $CheckList_Button_1a)

GUICtrlSetState($CheckList_Label_1, $GUI_SHOW) ;

GUICtrlSetData ($CheckList_Label_1, $CheckList_Button_1b)

;#### -----------------------------------------------------------------------

ElseIf @error == 1 Then

EndIf

Case $msg = $CheckList_Button_2

$CheckList_Button_2a = InputBox("Old Serial", "Enter the OLD serial number..")

If @error == 0 Then

;#### code removed/changed here to match $CheckList_Button_1

$CheckList_Button_2b = StringUpper($CheckList_Button_2a)

GUICtrlSetState($CheckList_Label_2, $GUI_SHOW)

GUICtrlSetData ($CheckList_Label_2, $CheckList_Button_2b)

;#### ------------------------------------------

ElseIf @error == 1 Then

EndIf

Case $msg = $CheckList_Button_3

$CheckList_Button_3a = InputBox("New Name", "Type NEW CPU Name without \\PSU-.", "", " M11")

If @error == 0 Then

;#### code removed/changed here to match $CheckList_Button_1

$CheckList_Button_3b = StringUpper("PSU-" & $CheckList_Button_3a)

GUICtrlSetState($CheckList_Label_3, $GUI_SHOW)

GUICtrlSetData ($CheckList_Label_3, $CheckList_Button_3b)

;#### ------------------------------------------

ElseIf @error == 1 Then

EndIf

Case $msg = $CheckList_Button_4

$CheckList_Button_4a = InputBox("New Serial", "Enter the NEW serial number..")

If @error == 0 Then

;#### code removed/changed here to match $CheckList_Button_1

$CheckList_Button_4b = StringUpper($CheckList_Button_4a)

GUICtrlSetState($CheckList_Label_4, $GUI_SHOW)

GUICtrlSetData ($CheckList_Label_4, $CheckList_Button_4b)

;#### ------------------------------------------

ElseIf @error == 1 Then

EndIf

EndSelect

WEnd

Share this post


Link to post
Share on other sites

You're welcome ;)

Today you will learn another useful thing (isn't life wonderful?) - how to NOT put your reply between

tags

Be sure that your reply is outside [code=auto:0] tags next time so it will appear as a normal text.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

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