Jump to content

Sleep function question


Recommended Posts

is it possible to have a sleep command on 1 function set and while that is sleeping, run another?

could some one point me in the right direction, or if they have done this plz give an example.

guess what i am wanting is something like :

$next1 = next()

sleep(180000(next1))

would that happen or will it wait out the 3 min and then goto the next func?

ps: looked in help file. not there that i could see. :(

Thanks

Cue

Link to comment
Share on other sites

whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

Sleep (in effect) pauses the execution of your script.

You can not be doing other things in the same process while a Sleep() is executing.

You would need to spawn separate child processes and then monitor them from the parent script.

You can, however, execute multiple concurrent timers from within a single script.

I think you can likely accomplish what you want to do with a few instances of TimerInit() and TimerDiff().

Edited by Spiff59
Link to comment
Share on other sites

it was a question asked to me by a family member. I will suggest the hot keys. But for an easier approach perhaps the timerinit might be the way to go.

I will try all 3 suggestions and post any findings. Thanks

Link to comment
Share on other sites

Here's the concept I was talking about:

#Include <Timers.au3>
$delay1 = 2000 ; milliseconds
$delay2 = 10000 ; milliseconds

$timer1 = _Timer_Init()
$timer2 = $timer1
Tooltip(@HOUR & ":" & @MIN & ":" & @SEC)
While 1 ; Process your mouse-clicks, keystrokes, or other events, in this $msg switch statement
;    $msg = GUIGetMsg()
;    Switch $msg
;        Case $Button_Whatever
;            Do the voodoo that you do here
;        Case $Button_Exit, $GUI_EVENT_CLOSE
;            ExitLoop
;    EndSwitch
    If _Timer_Diff($timer1) > $delay1 Then
        Beep(800,50) ; refresh the auditory nerve
        $timer1= _Timer_Init()
    EndIf
    If _Timer_Diff($timer2) > $delay2 Then
        Tooltip(@HOUR & ":" & @MIN & ":" & @SEC) ; update the tooltip
        $timer2= _Timer_Init()
    EndIf
Wend
Exit

This example maintains two timers. One to beep every 2 seconds, and the other to update a display every 10 seconds.

Enabling the GUIGetMsg() logic would allow you to process user-initiated events in real time.

Is that the sort of functionality you're looking for?

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