Sign in to follow this  
Followers 0
StuparuIG

Need help! dont work to use Try Buton-what is rong?

4 posts in this topic

#1 ·  Posted (edited)

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

Global $hGUI2 = 9999, $hButton3 = 9999

gui1()

Func gui1()

#Region ### START Koda GUI section ### Form=c:usersuserdesktopautoitloginlogin.kxf
$Form1_1 = GUICreate("Form1", 317, 160, 354, 197)
$Input1 = GUICtrlCreateInput("", 24, 40, 121, 21)
$Input2 = GUICtrlCreateInput("", 24, 88, 121, 21)
$Login = GUICtrlCreateButton("Login", 128, 128, 75, 25, 0)
$Try = GUICtrlCreateButton("Try", 218, 128, 75, 25, 0)
$Username = GUICtrlCreateLabel("Username", 24, 16, 52, 17)
$Password = GUICtrlCreateLabel("Password", 24, 64, 50, 17)
GUISetState()
#EndRegion ### END Koda GUI section ###

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop

Case $Login

$USERNAME = GUICtrlRead($Input1)
$PASSWORD = GUICtrlRead($Input2)
If $Username = "admin" and $Password = "123" Then

GUICtrlSetState($Login, $GUI_DISABLE)
gui2()
Else
MsgBox (0,"login","erroare")



EndIf
EndSwitch
WEnd

EndFunc ;==>gui1



Func gui2()

$hGUI2 = GUICreate("Gui 2", 200, 200, 350, 350)
$hButton3 = GUICtrlCreateButton("MsgBox 2", 10, 10, 80, 30)
GUISetState()

EndFunc ;==>gui2

Edited by Melba23
Added code tags

Share this post


Link to post
Share on other sites



next time please use 'autoit' tag

now i don't understand your problem...

you want this ?

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

Global $hGUI2 = 9999, $hButton3 = 9999

gui1()

Func gui1()

#Region ### START Koda GUI section ### Form=c:usersuserdesktopautoitloginlogin.kxf
$Form1_1 = GUICreate("Form1", 317, 160, 354, 197)
$Input1 = GUICtrlCreateInput("", 24, 40, 121, 21)
$Input2 = GUICtrlCreateInput("", 24, 88, 121, 21)
$Login = GUICtrlCreateButton("Login", 128, 128, 75, 25, 0)
$Try = GUICtrlCreateButton("Try", 218, 128, 75, 25, 0)
$Username = GUICtrlCreateLabel("Username", 24, 16, 52, 17)
$Password = GUICtrlCreateLabel("Password", 24, 64, 50, 17)
GUISetState()
#EndRegion ### END Koda GUI section ###

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop

Case $Login

$USERNAME = GUICtrlRead($Input1)
$PASSWORD = GUICtrlRead($Input2)
If $Username = "admin" and $Password = "123" Then
GUICtrlSetState($Login, $GUI_DISABLE)
gui2()
Else
MsgBox (0,"login","erroare")
EndIf
Case $Try
MsgBox(0,"$Try","Try button was pressed",0,$Form1_1)

EndSwitch
WEnd

EndFunc ;==>gui1
Func gui2()

$hGUI2 = GUICreate("Gui 2", 200, 200, 350, 350)
$hButton3 = GUICtrlCreateButton("MsgBox 2", 10, 10, 80, 30)
GUISetState()

EndFunc ;==>gui2

Share this post


Link to post
Share on other sites

StuparuIG,

Welcome to the AutoIt forum. :)

Add a Case to your loop to detect the button event: ;)

#include <GUIConstantsEx.au3>

Global $hGUI2 = 9999, $hButton3 = 9999

gui1()

Func gui1()

    $Form1_1 = GUICreate("Form1", 317, 160, 354, 197)
    $Input1 = GUICtrlCreateInput("", 24, 40, 121, 21)
    $Input2 = GUICtrlCreateInput("", 24, 88, 121, 21)
    $Login = GUICtrlCreateButton("Login", 128, 128, 75, 25, 0)
    $Try = GUICtrlCreateButton("Try", 218, 128, 75, 25, 0)
    $Username = GUICtrlCreateLabel("Username", 24, 16, 52, 17)
    $Password = GUICtrlCreateLabel("Password", 24, 64, 50, 17)
    GUISetState()

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop

            Case $Login
                $Username = GUICtrlRead($Input1)
                $Password = GUICtrlRead($Input2)
                If $Username = "admin" And $Password = "123" Then

                    GUICtrlSetState($Login, $GUI_DISABLE)
                    gui2()
                Else
                    MsgBox(0, "login", "erroare")
                EndIf
            Case $hButton3 ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                MsgBox(0, "Hi", "MsgBox 2 at your service")
        EndSwitch
    WEnd

EndFunc   ;==>gui1

Func gui2()

    $hGUI2 = GUICreate("Gui 2", 200, 200, 350, 350)
    $hButton3 = GUICtrlCreateButton("MsgBox 2", 10, 10, 80, 30)
    GUISetState()

EndFunc   ;==>gui2

You might find the Managing Multiple GUIs tutorial in the Wiki of interest. ;)

M23

P.S. When you post code please use Code tags - put [autoit] before and [/autoit] after your posted code. Then you get a scrolling box as you can see above now I have added the tags. ;)


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

thank you

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