Sign in to follow this  
Followers 0
jokke

Help: script counter.

8 posts in this topic

#1 ·  Posted (edited)

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.

Share this post


Link to post
Share on other sites



i think that you are trying to make a countdown timer

try something like this

$timer1 = 120
$timer2 = 60
$timeup1 = no
$timeup2 = no


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

do
$timer1 = $timer1 -1
sleep 1000
untill
$timer1 = 0
timeup1 = yes

   EndIf
FuncEnd

;repeat this for second countdown
;not tested, not sure if this is wat u want

"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

i just copyed his funcend


"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
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.

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  
Followers 0