Jump to content
JScript

_AdlibEnhance.au3 (UDF) - Call functions with parameters, pause and resume!

Recommended Posts

19 hours ago, Acanis said:

I hope to find some help or a "newer" UDF :)

; may be ugly but if you can use it ...
Func MyAdlibFunc($var1 = "", $var2 = "")
    Local Static $_var1 = ""
    If Eval("var1") <> "" Then $_var1 = Eval("var1")
    Local Static $_var2 = ""
    If Eval("var2") <> "" Then $_var2 = Eval("var2")
    If Eval("var1") or Eval("var2") Then Return

    ConsoleWrite('+ Func MyAdlibFunc("' & Eval("var1") & '", "' & Eval("var2") & '") = $_var1 = ' & $_var1 & ' - $_var2 = ' & $_var2 & @CRLF)
EndFunc

AdlibRegister("MyAdlibFunc", 2000)

While 1
    MyAdlibFunc(@MIN, @SEC)
    Sleep(1000)
WEnd

 

Share this post


Link to post
Share on other sites
Posted (edited)

Thank you, but that wont work for me :)

I need it like a queue, but with the Adlib force (dont wait for other stuff, besides other Adlib-started things ^^). I have one function, that is processing the main work for me and it has three different "triggers" (one param, that can come in 3 different expressions, lets say "1, 2 and 3):

If its "1", the data from source "1" gets used, "2" triggers the usage of the data from "2" and "3" calling the function to use a third data source. If the function for example processed the data from source "1" by calling the "$iParam" with "1", it calculates the next Adlib-Time overwrite the time for the next time, the function has to use the "1". 

I didnt find other solutions for a "queue" like that.

Currently I'm thinking about using the "Execute()" function and continue using the "Adlib Helper Functions", but then create them dynamically.

This should be the best way to tell a function to run in x seconds with the parameter y, right?

 

*edit*

Oh, and I fund "_Timer_SetTimer()"... That looks promising, too... Thats the function this UDF is based on, ahhhh... I will take a deeper look into this :D 

 

*edit2*

Not that simple... Would be nice to find the UDF, to re-use it. Link is dead.

Edited by Acanis

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Bilgus
      Apparently you can't use a function with variables for AdlibRegister
      Like you declare it with a variable even an optional one and it throws an error if you try and call it
      Thats ok though I figured out a hack using eval to get a better result
      Registered_Funct(250);Register Sleep(10000) Registered_Funct(-1);UnRegister Func Registered_Funct($iTime = -1) Local $i_Time = Eval("iTime") If $i_Time > 0 Then AdlibRegister("Registered_Funct", $i_Time) ElseIf $i_Time < 0 Then AdlibUnRegister("Registered_Funct") Else ConsoleWrite("Do Stuff") EndIf EndFunc
      Surely it has an impact on efficiency though...
    • By Miliardsto
      Is there any difference in timers and AdlibRegister ?
      in :
      performance usage reliability or any kind of difference I want use few timers at once so it will make difference.
      I have problem with timers and I saw AdlibRegister behaves similar like:
      wont stop crashing slowing program so much maybe is there any trick to make it better?
    • By badcoder123
      Hey everyone,
      I've been messing around with some new things and adlibs look extremely useful/interesting, however, I can't seem to get it to work.. Here's what I have
      HotKeySet("{F1}", "_Exit") $qCount = 1 Global $_Timer AdlibRegister($_Timer, 1000) AdlibUnRegister($_Timer) While 1 SoundPlay(@WindowsDir & "\media\tada.wav", 1) $qCount += 1 ToolTip('"Tada" has been played ' & $qCount & " times",200,200) WEnd Func _Timer() Local Static $iCount += 1 ConsoleWrite($iCount) If $iCount = 20 Then ConsoleWrite("iCount is at " & $iCount) EndFunc Func _Exit() Exit EndFunc Basically I want it to call the _Timer function but it doesn't seem to work :/ any ideas?
    • By timmy2
      I'm writing a small prog that will run in the background and sound an alarm if a certain Gmail message arrives in an otherwise unused account.
      My inclination is to use a simple While/WEnd loop with a 5 minute Sleep between checking for messages, but I've seen examples here of somewhat similar background tasks that employ AdlibRegister so I'm curious which method is the most reliable and least impactful on the CPU.  Below are two simple scripts that begin to do what I want and represent how I think this could be handled.
      While/WEnd with Sleep
      #include <CheckMail.au3> Global $aReturn Global $iEmails While 1 $aReturn = CheckMail("username", "password") $iEmails = @extended If $iEmails > 0 ExitLoop Sleep(300000) ; check for new messages every 5 minutes WEnd ;work with contents of $aReturn array that contains the new message(s) found  
      While/WEnd with Sleep and AdlibRegister
      #include <CheckMail.au3> Global $aReturn Global $iEmails = 0 AdlibRegister('_CallCheckMail',300000) ; check for new messages every 5 minutes While 1 Sleep(500000) ; I had to put something here. Does higher the value = less CPU demand? If $iEmails > 0 ExitLoop WEnd ;work with contents of $aReturn array that contains the new message(s) found Func _CallCheckMail $aReturn = CheckMail("username", "password") $iEmails = @extended Return EndFunc  
    • By TheDcoder
      AdlibRegister("ScriptBreaker", 1000 * 10) FileMove($large_10GB_file, $relocated_large_10GB_file) Func ScriptBreaker() Sleep(1000 * 10) EndFunc ; Will adlib break the file or pause the transfer??
×
×
  • Create New...