Jump to content
Sign in to follow this  
DoctorSLO

Multiple Sleep cmds ?

Recommended Posts

DoctorSLO

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?

Share this post


Link to post
Share on other sites
Melba23

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

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites
herewasplato

see TimerInit and TimerDiff


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

Share this post


Link to post
Share on other sites
DoctorSLO

Hm ... again something new :)

OK, I will try to do it with this ... Thanks for advice

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

Edited by DoctorSLO

Share this post


Link to post
Share on other sites
herewasplato

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

Share this post


Link to post
Share on other sites
DoctorSLO

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

Share this post


Link to post
Share on other sites
FireFox

@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

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Jos

Not tested.

Cheers, FireFox.

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

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
DoctorSLO

Thx, but this is only showing "Slept 1sec !".

its not working

Share this post


Link to post
Share on other sites
DoctorSLO

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 ?

Share this post


Link to post
Share on other sites
FireFox

@Jos

thanks :lmao: i cant test it because im on my ipod :)

@DoctorSLO

post edited, try again :think:


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
Aceguy

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

Share this post


Link to post
Share on other sites
FireFox

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


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
DoctorSLO

OK, thx all for help I understand now ...:)

Share this post


Link to post
Share on other sites
Melba23

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

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites
DoctorSLO

Melba23,

No problem, actually now I know what is Pseudo-code :)

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  

×