Jump to content

Multiple Sleep cmds ?


Recommended Posts

Hi.

I made some program that do some task at the time that it's entered: I enter like 2 hrs and 0 min, and this is multiplied by 60, 60, 1000 .... so I get sleep time.

But what if I want to do more tasks? Like one task for 1 hour and other task for 2 hours ... I can use multiple Sleep(xxx) commands?

Or there is another way?

Link to comment
Share on other sites

  • Moderators

DoctorSLO,

Perhaps the best way to do this is to set an initial timestamp using TimerInit and then use TimerDiff to decide when to run. Pseudo-code would look something like this:

Input $time1
Input $time2

$start = TimerInit()

While 1

If TimerDiff($start) = $time1 Then Do Task1

If TimerDiff($start) = $time1 Then Do Task2

WEnd

Try something like that and ask again if you have a problem.

M23

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

... Btw. Input cmd doesn't exist ... xD

That is what Pseudo-code means. The code will not detail certain parts of the code that you were not asking about.

Input $time1 can represent many different lines of code from a GUI input to a regular InputBox --- all of the error checking and any reformatting of the variable.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

OK, thx for explain, herewasplato

I do some script, but its not work, it sleeps forever ..

#Include <Timers.au3>

$ena = 10000
$dve = 6000

$Time1 = Sleep($ena)
$Time2 = Sleep($dve)

$start = TimerInit()

While 1
    Select
    Case TimerDiff($start) = $Time1
        MsgBox(0, "Time one", "Time ONE")
    Case TimerDiff($start) = $Time2
        MsgBox(0, "Time two", "Time TWO")
        EndSelect
    WEnd
Exit

What I do wrong ?

Edited by DoctorSLO
Link to comment
Share on other sites

@DoctorSLO

$init1 = TimerInit()
$init2 = TimerInit()

While 1
$diff1 = TimerDiff($init1)
$diff2 = TimerDiff($init2)
If $init1 >= 1000 then
TrayTip('Sleep', 'Slept 1sec !', 0, 1)
$init1 = TimerInit()
ElseIf $init2 >= 1500 then
TrayTip('Sleep', 'Slept 1,5sec !', 0, 1)
$init2 = TimerInit()
EndIf
WEnd

Not tested.

Cheers, FireFox.

Edited by FireFox
Link to comment
Share on other sites

  • Developers

Not tested.

Cheers, FireFox.

Maybe you should? I expected a TimerDiff() in there :) Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Thx, I added TimerDiff() Now look like this:

#Include <Timers.au3>

$init1 = TimerInit()
$init2 = TimerInit()

While 1
If TimerDiff($init1) >= 1000 then
MsgBox(0, "Time one", "time one")
$init1 = TimerInit()
ElseIf TimerDiff($init2) >= 1500 then
MsgBox(0, "Time two", "Time two")
$init2 = TimerInit()
EndIf
WEnd
Exit

But script doesn't exit ... when it comes to time two it starts again ... mybe I must use some killtimer cmd or what ?

Link to comment
Share on other sites

there ya go.

Hope you can learn from it

$init = TimerInit()

While 1
if int(TimerDiff($init)/1000) = 5 then
toolTip("Ding!!! 5 Seconds")
elseIf int(TimerDiff($init)/1000) = 10 then
toolTip("Ding!!! 10 Seconds")
ElseIf int(TimerDiff($init)/1000) = 15 then
toolTip('Ding!!! 15 seconds')
elseif int(TimerDiff($init)/1000) = 20 Then
toolTip('')
EndIf
sleep(250)
WEnd
Link to comment
Share on other sites

@DoctorSLO

HotKey example :

#Include <Timers.au3>
Global $timer = True
HotKeySet("{F7}", "_TIMERON")
HotKeySet("{F8}", "_TIMEROFF")

$init1 = TimerInit()
$init2 = TimerInit()

While 1
If TimerDiff($init1) >= 1000 and $timer = True then
MsgBox(0, "Time one", "time one")
$init1 = TimerInit()
ElseIf TimerDiff($init2) >= 1500 and $timer = True then
MsgBox(0, "Time two", "Time two")
$init2 = TimerInit()
EndIf
WEnd

Func _TIMERON()
Global $timer = True
EndFunc

Func _TIMEROFF()
Global $timer = False
EndFunc

Not tested

Cheers, FireFox.

Link to comment
Share on other sites

  • Moderators

DoctorSLO,

Apologies for the Pseudo-code misunderstanding. I had to leave for a while - real life gets in the way sometimes!

Are you happy with what you have got so far from the others who kindly responded?

M23

Edit. I see you are!

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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...