Jump to content

Recommended Posts

Posted

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

Posted (edited)

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
Posted

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

Posted

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?

Posted

It sounds like you're looking to do multi-threaded application, but AFAIK, this can't be done from within one AutoIt program, that you have to instead use the suggestions given above.

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
×
×
  • Create New...