Jump to content

sleep for one hour


Recommended Posts

I'm writing an application that prompts the user to install an application and it gives the user the option of postponing the installation for one hour. Until now, I've just used the sleep(3600000) function whenever the user presses the postpone button. However, I'm looking to add additional functionality where say a user hit the postpone button but 15 minutes goes by and he/she thinks that now would be a good time to run the installation. Rather than forcing them to wait the entire hour, I want to give them the ability to run it manually. I was thinking a tray icon and when the icon is clicked, they can choose "Run now" or something to that effect. If I do this, I wouldn't be able to use the sleep function because if the application is sleeping, it wont be accepting input from the tray icon (am I wrong on that?). So I was thinking of creating my own custom sleep function that would basically countdown 60 minutes but still have the ability to receive input from the tray icon. Is there a built in function to do that or would I need to create my own? Does anyone have some sample code of a way to do this?

Link to comment
Share on other sites

See TimerInit()/TimerDiff() in the help file. For example:

$iTimer = TimerInit()
While 1
     If TimerDiff($iTimer) >= 60 * 60 * 1000 Then
          ; What to do on timeout
          ;
     Else
          ; What do check while waiting
          ;
     EndIf
     Sleep(10)
WEnd

:mellow:

Edit: Added short Sleep() to avoid sucking up all CPU cycles.

Edited by PsaltyDS
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
Link to comment
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
 Share

  • Recently Browsing   0 members

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