totoymola Posted September 28, 2008 Posted September 28, 2008 Hi. I am trying to make a form similar to the InputBox, and I want it to automatically close after 10 seconds. In the InputBox, you can specify the timeout. This is my current test code: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $PW = "test" $Form1_1 = GUICreate("Test InputBox", 217, 109, -1, -1, -1, BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE)) $Input1 = GUICtrlCreateInput("", 16, 40, 185, 21, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL)) $Label1 = GUICtrlCreateLabel("Please enter the password to proceed.", 16, 16, 186, 17) $Button1 = GUICtrlCreateButton("OK", 16, 72, 83, 25, $BS_DEFPUSHBUTTON) $Button2 = GUICtrlCreateButton("Cancel", 120, 72, 83, 25, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $Input1Answer = GUICtrlRead($Input1) If $Input1Answer = $PW Then ExitLoop Else MsgBox(262160, "ERROR", "Wrong password! Please try again.") EndIf Case $Button2 Exit EndSwitch WEnd Is there a way to make this close automatically after a specific number of seconds? Thanks!
BrettF Posted September 28, 2008 Posted September 28, 2008 TimerInit, TimerDiff and polling to see if the TimerDiff is returning a value greater or equal to 10seconds. Thats important because you will almost never get exactly the right value returned from TimerDiff. If you still need more help, have a sift through the code in my _LoginBox function. If I recall it's all in there... and if its not post back here... Hope this helps, Cheers, Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
ChromeFan Posted September 28, 2008 Posted September 28, 2008 (edited) just a example to give you it's idea, $T=TimerInit() If TimerDiff($T) >= 10*1000 then ; time in mili seconds 10x1000 = 10sec GUIDelete($GUI) ;the gui which you want to del ExitLoop EndIf for more information read the help file and do as BrettF said. Edited September 28, 2008 by ChromeFan Website: www.cerescode.comForum: www.forum.cerescode.comIRC: irc.freenode.net , Channel: #Ceres--------------------Autoit Wrappers, Great additions to your script (Must See) (By: Valuater)Read It Befor Asking Question Click Here...--------------------Join Monoceres's Forums http://www.monoceres.se--------------------There are three kinds of people: Those who make things happen, those who watch things happen, and those who ask, What happened? Casey Stengel
BrettF Posted September 28, 2008 Posted September 28, 2008 Another hint, don't put the TimerInit in the Message loop of your GUI... Otherwise it will keep reseting! Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
ChromeFan Posted September 28, 2008 Posted September 28, 2008 try this... it will work fine! #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $PW = "test" $T=TimerInit() $Form1_1 = GUICreate("Test InputBox", 217, 109, -1, -1, -1, BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE)) $Input1 = GUICtrlCreateInput("", 16, 40, 185, 21, BitOR($ES_PASSWORD, $ES_AUTOHSCROLL)) $Label1 = GUICtrlCreateLabel("Please enter the password to proceed.", 16, 16, 186, 17) $Button1 = GUICtrlCreateButton("OK", 16, 72, 83, 25, $BS_DEFPUSHBUTTON) $Button2 = GUICtrlCreateButton("Cancel", 120, 72, 83, 25, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $Input1Answer = GUICtrlRead($Input1) If $Input1Answer = $PW Then ExitLoop Else MsgBox(262160, "ERROR", "Wrong password! Please try again.") EndIf Case $Button2 Exit EndSwitch If TimerDiff($T) >= 10*1000 then ; time in mili seconds 10x1000 = 10sec GUIDelete($Form1_1) ;the gui which you want to del ExitLoop EndIf WEnd Website: www.cerescode.comForum: www.forum.cerescode.comIRC: irc.freenode.net , Channel: #Ceres--------------------Autoit Wrappers, Great additions to your script (Must See) (By: Valuater)Read It Befor Asking Question Click Here...--------------------Join Monoceres's Forums http://www.monoceres.se--------------------There are three kinds of people: Those who make things happen, those who watch things happen, and those who ask, What happened? Casey Stengel
totoymola Posted September 28, 2008 Author Posted September 28, 2008 Thank you guys for all your help. I will try your suggestions. Thanks again!
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