mymusicmanager Posted April 10, 2014 Share Posted April 10, 2014 Hello Great Internet! So I'm attempting to create a small login program, where once the window opens, it counts down from 20. Once it hits 0, it shuts down the computer. But I still want to press the login button before the counter stops. Any ideas? expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("LoginMeIN v.1.2.0", 355, 349, 192, 124) $MenuItem1 = GUICtrlCreateMenu("File") $MenuItem2 = GUICtrlCreateMenuItem("Exit", $MenuItem1) $MenuItem3 = GUICtrlCreateMenu("Help") $MenuItem4 = GUICtrlCreateMenuItem("About...", $MenuItem3) $input1 = GUICtrlCreateInput("", 120, 80, 137, 21) $Label1 = GUICtrlCreateLabel("Username:", 64, 80, 55, 17) $input2 = GUICtrlCreateInput("", 121, 112, 137, 21) $Label2 = GUICtrlCreateLabel("Password:", 65, 116, 53, 17) $Button1 = GUICtrlCreateButton("Log in", 120, 160, 137, 49) $Button2 = GUICtrlCreateButton("Clear", 264, 144, 65, 17) $Label3 = GUICtrlCreateLabel("Shutdown commencing in", 136, 8, 129, 17) $Label4 = GUICtrlCreateLabel("20 seconds", 272, 8, 16, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $i = 1 for $i = 1 to 20 Step +1 GUICtrlSetData ($label4, $i & "seconds") Sleep (1000) Next While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Exit Case $Button1 Button1() Case $button2 Button2() Case $Form1 EndSwitch WEnd func Button1() Global $read = GUICtrlRead($input1) Global $read2 = GUICtrlRead($input2) if $read == "marfro10" AND $read2 == "frotvedt" Then msgbox (0+16, "", "Login Successfull! Shutdown has stopped") Else MsgBox (0+16, "", "Login unsuccessfull. Please try again") EndIf EndFunc if $i = 20 Then msgbox (0+16, "", "Time's up!") EndIf Func Button2() GUICtrlSetData ($input1, "") GUICtrlSetData ($input2, "") EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 10, 2014 Moderators Share Posted April 10, 2014 mymusicmanager,I would do something like this:expandcollapse popup#include <GUIConstantsEx.au3> $Form1 = GUICreate("LoginMeIN v.1.2.0", 355, 349, 192, 124) $MenuItem1 = GUICtrlCreateMenu("File") $MenuItem2 = GUICtrlCreateMenuItem("Exit", $MenuItem1) $MenuItem3 = GUICtrlCreateMenu("Help") $MenuItem4 = GUICtrlCreateMenuItem("About...", $MenuItem3) $input1 = GUICtrlCreateInput("", 120, 80, 137, 21) $Label1 = GUICtrlCreateLabel("Username:", 64, 80, 55, 17) $input2 = GUICtrlCreateInput("", 121, 112, 137, 21) $Label2 = GUICtrlCreateLabel("Password:", 65, 116, 53, 17) $Button1 = GUICtrlCreateButton("Log in", 120, 160, 137, 49) $Button2 = GUICtrlCreateButton("Clear", 264, 144, 65, 17) $Label3 = GUICtrlCreateLabel("Shutdown commencing in", 136, 8, 129, 17) $Label4 = GUICtrlCreateLabel("20 seconds", 136, 25, 129, 17) GUISetState(@SW_SHOW) Global $i = 1 Global $iSec = @SEC While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Exit Case $Button1 Button1() Case $Button2 Button2() Case $Form1 EndSwitch If @SEC <> $iSec Then $iSec = @SEC $i += 1 GUICtrlSetData($Label4, $i & " seconds") If $i = 20 Then MsgBox(0 + 16, "", "Time's up!") Exit EndIf EndIf WEnd Func Button1() Global $read = GUICtrlRead($input1) Global $read2 = GUICtrlRead($input2) If $read == "marfro10" And $read2 == "frotvedt" Then MsgBox(0 + 16, "", "Login Successfull! Shutdown has stopped") Else MsgBox(0 + 16, "", "Login unsuccessfull. Please try again") EndIf EndFunc ;==>Button1 Func Button2() GUICtrlSetData($input1, "") GUICtrlSetData($input2, "") EndFunc ;==>Button2Please ask if you have any questions. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Unc3nZureD Posted April 10, 2014 Share Posted April 10, 2014 AutoIt can handle only one thing at once, which mean you can't pull 2 functions at the same time. You have to find a small bypass way. In Melba's way, he put the countdown and the GUI check in the same loop, so he will check 2 things after each other Have fun! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now