Jump to content
Sign in to follow this  
EhJay

Enter Time To Wait

Recommended Posts

Hi. I have a point in my script where I would like a msg box or something to pop up and ask me how long I would like to make the script pause for.

ex.

How long would you like the script to wait? ___5___

OK

The script would then wait for 5 seconds or minutes or whatever unit I can use.

Thanks for the help.

Share this post


Link to post
Share on other sites

Hi. I have a point in my script where I would like a msg box or something to pop up and ask me how long I would like to make the script pause for.

ex.

How long would you like the script to wait? ___5___

OK

The script would then wait for 5 seconds or minutes or whatever unit I can use.

Thanks for the help.

This does not sound hard. What have you got already? Is your InputBox() working?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Hi again. That's been working great but how do I get the script to abort when I click cancel on the imput box? I press cancel and it just waits the time that's in the imput box before continuing on in the script. I want to put an "Exit" when someone presses the cancel button.

Thanks.

Share this post


Link to post
Share on other sites

Assign InputBox to variable, and look at help:

Return Value

Success: Returns the string that was entered.

Failure: Returns an empty string and sets @error as follows:

@Error 0 = The string returned is valid.

1 = The Cancel button was pushed.

2 = The Timeout time was reached.

And use sinple If... EndIf.

Share this post


Link to post
Share on other sites

Ok. I understand what you mean by that, but how would I make the ImputBox a variable when it is like this?:

Sleep(1000*Number(InputBox("Wait 'x' seconds","Enter Time To Wait")))

With the "Sleep" at the beginning where would I but the $variable ?

Share this post


Link to post
Share on other sites

Don't use this for accurate time taking thougt :D

$timeout = InputBox("TIMOUT IN","Give ms to timout")
; DO check for cancel see the help file
$timeinit = TimerInit()
While (TimerDiff($timeinit) < $timeout)
   TrayTip("","",0)
   TrayTip("Timout in: ", $timeout - TimerDiff($timeinit),0)
   sleep(100)
Wend
Edited by Uten

Share this post


Link to post
Share on other sites

Don't use this for accurate time taking thougt :D

$timeout = InputBox("TIMOUT IN","Give ms to timout")
; DO check for cancel see the help file
$timeinit = TimerInit()
While (TimerDiff($timeinit) < $timeout)
   TrayTip("","",0)
   TrayTip("Timout in: ", $timeout - TimerDiff($timeinit),0)
   sleep(100)
Wend

Errr... ok thank you. Your thing works like I want it to but when you click cancel it does not exit the script, it just continues what's after the "WEnd". Also, I need to do this silently.

Thank you though.

Share this post


Link to post
Share on other sites

:D , Am I employed by you or somthing? hmm, no I have not seen any checks yet, so I don't think so.

; DO check for cancel SEE THE HELP FILE!!!!!

$timeout = InputBox("TIMOUT IN","Give ms to timout")
; DO check for cancel see the help file
$timeinit = TimerInit()
While (TimerDiff($timeinit) < $timeout)
   sleep(100)
Wend

Share this post


Link to post
Share on other sites

:D , Am I employed by you or somthing? hmm, no I have not seen any checks yet, so I don't think so.

; DO check for cancel SEE THE HELP FILE!!!!!

$timeout = InputBox("TIMOUT IN","Give ms to timout")
; DO check for cancel see the help file
$timeinit = TimerInit()
While (TimerDiff($timeinit) < $timeout)
   sleep(100)
Wend

LOL... Ok I didn't understand what that ment before. Sorry. And I didn't ask you to write me all of that ya know... you chose to. I just asked how to make the ImputBox in

Sleep(1000*Number(InputBox("Wait 'x' seconds","Enter Time To Wait")))
a variable.

But thank you, this should work.

Share this post


Link to post
Share on other sites

Umm... Ok I still can't get it to work. Would I put

If $timeout = 1 then
    exit
endif

into it because the return value of the ImputBox when cancel is presses is 1? I'm sorry I've never used this many variables or "values" in a program before. Thanks again for your help.

Edited by EhJay

Share this post


Link to post
Share on other sites

I don't know how to do it properly either but try:

$variable = InputBox("Wait 'x' seconds","Enter Time To Wait")
If @error Then
    Exit 0
EndIf
If IsInt($variable) And $variable <> "" Then
        Sleep(1000*Number($variable))
EndIf
Is a contradiction (or a bot to mutch if you like :D ). Obviously $variable <> "" if $variable is a int (number), or did I miss something ?

Share this post


Link to post
Share on other sites

To tell you the truth I don't understand the whole line.

If IsInt($variable) And $variable <> "" Then

Share this post


Link to post
Share on other sites

If IsInt($variable) And $variable <> "" Then

Lets look at it then :D

If ... Then should be known

IsInt( $variable ) :

Int ( INTeger) is a number like 2 or 3 or - 1.

1.124 and 1234.124 are not a integers!

IsInt(..) returns 1 if the variable is an integer and 0 if the variable is no integer

$variable <> ""

This is just a check if the variable is defined. When its not defined its "". Then you cant check anything with it :D

And

this combines both (isint() $variable <> "") and the if ... then will only be done when BOTH are true!

Do you understand it now?


--------------------------------------------------------------------------------------------------------------------------------Scripts : _Encrypt UDF_UniquePCCode UDF MS like calculatorInstall programm *UPDATED* --------------------------------------------------------------------------------------------------------------------------------[quote name='Helge' post='213117' date='Jul 26 2006, 10:22 AM']Have you ever tried surfing the internet with a milk-carton ?This is similar to what you're trying to do.[/quote]

Share this post


Link to post
Share on other sites

hmm what means "jerryriged"?

Google translate says nothing and my english wordbook doesn't have it. Sorry


--------------------------------------------------------------------------------------------------------------------------------Scripts : _Encrypt UDF_UniquePCCode UDF MS like calculatorInstall programm *UPDATED* --------------------------------------------------------------------------------------------------------------------------------[quote name='Helge' post='213117' date='Jul 26 2006, 10:22 AM']Have you ever tried surfing the internet with a milk-carton ?This is similar to what you're trying to do.[/quote]

Share this post


Link to post
Share on other sites

Maybe that works:

$wait=InputBox("How long","Enter time to wait.")
If @error Then Exit 1
Sleep($wait)
TrayTip("Wait","Wait end")
Sleep(5000)
;or you can replace TrayTip with this
MsgBox(0,"Wait", "Wait end")

I can do signature me.

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...