Jump to content

Help: script counter.


jokke
 Share

Recommended Posts

Hi,

I have 2 scripts, one witch i need to trigger every 120 sec, and one to trigger every 60 secounds.

For now i have currently used a looping "While" as my counter witch works great for 1 script at the time,

but when i try to mix both my scripts together, all the timings get wrong after a few minutes.

You can see how my code almost looks like under:

;Settings
$script1_wait =0
$script1_wait2 = 60

$script2_wait =0
$script2_wait2 = 120

$test = 1
$test = 2


;Functions
Func _script1()
    If $test = 1 Then
    "My script goes here."

        $script1_wait = 0
        While $script1_wait2 > $script1_wait
            $script1_wait = $script1_wait +1
            Sleep(1000)
        WEnd
    EndIf
EndFunc

Func _script2()
    If $test2 = 1 Then

    "My 2nd script goes here"


        $script2_wait = 0
        While $script2_wait2 > $script2_wait
            $script2_wait = $script2_wait +1
            Sleep(1000)
        WEnd
    EndIf
EndFunc

;Script
While 1 = 1

    _script1()

    _script2()


WEnd

Anyone have any good idea on how i can make counters on both the scripts so main script can wend over and over until one of the scripts are runnable.

All help appreciated :lmao:

Edit: I wrote this code on free hand but wrote EndFunc wrong on the sithe. My actual code is EndFunc.

Edited by jokke
UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.
Link to comment
Share on other sites

maybe cuz your using Funcend instead of Endfunc when i get home ill come rewrite this for you so it looks alot cleaner, could you please provide a more concrete example with your program cuz its kinda hard to write a script that just sits in a loop adding 1 to a variable then just exits the function and if anything i would recomend looking at a For Loop in the help file

Edited by thatsgreat2345
Link to comment
Share on other sites

Try this.

;Settings
$script1_wait = 0
$script1_wait2 = 60

$script2_wait = 0
$script2_wait2 = 120

$test = 1
$test2 = 1

;Functions
Func _script1()
    If $test = 1 Then
        ;"My script goes here."
    EndIf
EndFunc   ;==>_script1

Func _script2()
    If $test2 = 1 Then
        ; "My 2nd script goes here"
    EndIf
EndFunc   ;==>_script2

;Script
While 1
    $script1_wait = $script1_wait + 1
    $script2_wait = $script2_wait + 1
    Sleep(1000)
    If $script1_wait = $script1_wait2 Then
        $script1_wait = 0
        _script1()
    EndIf
    If $script2_wait = $script2_wait2 Then
        $script2_wait = 0
        _script2()
    EndIf
WEnd
Edited by lcgreenwald
Link to comment
Share on other sites

Hi,

or have a look at TimerInit and TimerDiff.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Thanks alot for all the input on this :lmao:

lcgreenwald's code worked like a charm for me. Thanks alot!

UDF:Crypter a file encrypt / decrypt tool with no need to remember a password again. Based on Caesar cipher using entire ASCII Table.Script's: PixelSearch Helper, quick and simple way to create a PixelSeach.Chatserver - simplified, not so complicated multi-socket server.AutoIT - Firewall, simple example on howto create a firewall with AutoIt.
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...