Jump to content

Recommended Posts

Posted

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!

Posted

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

Posted (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 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
Posted

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...