Jump to content
Sign in to follow this  
Miranda

Is it possible to have a function run paralell to your script?

Recommended Posts

Miranda

I've thought of this a couple times, in different scripts I wrote, that it would be handy if I could run a certain function, and keep on running the main script at the same time.

The best example would be:

Tooltip("Hello World")
Sleep(50000)
Tooltip()

For this example, another command along the lines of Runin(50000,"Tooltip()") would also work just fine, one that would be a non blocking sleep, that after a given time runs a certain command...

However, for other stuff it would be very, very handy if I could be running a function concurrently to the rest of my script.

I know I could "simply" Run(...) a different compiled .au3 script, but how can the two share variables?

My guess though is that I'm not the first to think about something along these lines, and a much more professional coder than myself already has a

ParalellFunc _wee()
...
EndParalellFunc
sort of thing :)

At any rate, anyone have some insight for me?

Kind regards,

Miranda

Share this post


Link to post
Share on other sites
Vadersapien

Try using timers instead of the Sleep() function


Try Pacfox, my Firefox theme.Try Power Eject, my windows gadget that allows you to eject most drives.Using AutoIt 3.3.4.0, Windows 7 Premium, Intel Core 2 Quad CPU @ 2.66ghz, 4gb RAM, Nvidia GeForce 9500GT Graphics Card & Samsung 22" Monitor.

Share this post


Link to post
Share on other sites
jvanegmond

I usually split my big sleep up in smaller sleep steps. That makes it non-blocking, and you can still call certain functions in a loop, while your main script is waiting for the sleep to finish.

Func Sleepy($timeMs, $stepMs = 100)
    If ($stepMs < $timeMs) Then
        _Sleepy($timeMs, $stepMs)
    Else
        Sleep($timeMs)
    EndIf
EndFunc

Func _Sleepy($timeMs, $stepMs)
    $start = TimerInit()
    While (TimerDiff($start) < $timeMs)
        Sleep($stepMs)
    WEnd
EndFunc

Share this post


Link to post
Share on other sites
JohnOne

Browsing another forum yesterday I came across a thread in which the poster claimed it was possible in a scripting language not disimilar to autoit.

Way over my head, but "criticalsection()" was mentioned. and a link to MDSN http://msdn.microsoft.com/en-us/library/ms682530.aspx

I'm not suggesting it is possible, just passing on info which might be relevant.

edit link

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
martin

Browsing another forum yesterday I came across a thread in which the poster claimed it was possible in a scripting language not disimilar to autoit.

Way over my head, but "criticalsection()" was mentioned. and a link to MDSN http://msdn.microsoft.com/en-us/library/ms682530.aspx

I'm not suggesting it is possible, just passing on info which might be relevant.

edit link

The example you gave could be done with AlibEnable (or AdLibRegister in the Beta version).


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
Miranda

Try using timers instead of the Sleep() function

I usually split my big sleep up in smaller sleep steps. That makes it non-blocking, and you can still call certain functions in a loop, while your main script is waiting for the sleep to finish.

Func Sleepy($timeMs, $stepMs = 100)
    If ($stepMs < $timeMs) Then
        _Sleepy($timeMs, $stepMs)
    Else
        Sleep($timeMs)
    EndIf
EndFunc

Func _Sleepy($timeMs, $stepMs)
    $start = TimerInit()
    While (TimerDiff($start) < $timeMs)
        Sleep($stepMs)
    WEnd
EndFunc

I've thought of this, and while it does work, the coding effort is too great for my tastes and purposes, but thanks a lot for the input :)

Browsing another forum yesterday I came across a thread in which the poster claimed it was possible in a scripting language not disimilar to autoit.

Way over my head, but "criticalsection()" was mentioned. and a link to MDSN http://msdn.microsoft.com/en-us/library/ms682530.aspx

I'm not suggesting it is possible, just passing on info which might be relevant.

edit link

The example you gave could be done with AlibEnable (or AdLibRegister in the Beta version).

Thanks, I guess what I'm looking for, however, I fear it is a bit too advanced for me...

Edit: All things considered, where critically essential, I'll employ timers, and wait until some genius mind comes up with with a ready to use Function that will run in parallel to the rest of the script, for lesser mortals, such as myself ;)

Edited by Miranda

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.