Sign in to follow this  
Followers 0
Physical

Help with putting timer on a function

5 posts in this topic

#1 ·  Posted (edited)

I have the following Function:

Func Automate()
    Do
        Send ("{1}")
        Sleep (2000)
        $Count = $Count + 1
        $Time = $Time + 2000
        If $Time >= 900000 Then
            Send ("{4}") 
            $Time = 0
        EndIf
        If $Count = 7 Then
            Send ("{5}")
            Sleep (10000)
            $Time = $Time + 10000
            $Count = 0
        EndIf
    Until $Count = 10
EndFunc

Basically i want this function to loop forever (i use hotkey to terminate it) but every 15 mins i want it to press a different key (i got 900,000 miliseconds by doing 15*60 = 900 * 1000 = 900000) Is this the best way to go about this? Any suggestions would be greatly appreciated.

Edited by Physical

Share this post


Link to post
Share on other sites



I have the following Function:

Func Automate()
     Do
         Send ("{1}")
         Sleep (2000)
         $Count = $Count + 1
         $Time = $Time + 2000
         If $Time >= 900000 Then
             Send ("{4}") 
             $Time = 0
         EndIf
         If $Count = 7 Then
             Send ("{5}")
             Sleep (10000)
             $Time = $Time + 10000
             $Count = 0
         EndIf
     Until $Count = 10
 EndFunc

Basically i want this function to loop forever (i use hotkey to terminate it) but every 15 mins i want it to press a different key (i got 900,000 miliseconds by doing 15*60 = 900 * 1000 = 900000) Is this the best way to go about this? Any suggestions would be greatly appreciated.

Check out AdlibEnable() :)

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

Check out AdlibEnable() :)

Func Automate()
    AdlibEnable("TimeFunc", 900000)
    Do
        Send ("{F1}")
        Sleep (2000)
        $Count = $Count + 1
        If $Count = 7 Then
            Send ("{F5}")
            Sleep (10000)
            $Count = 0
        EndIf
    Until $Count = 10
EndFunc

Func TimeFunc()
    Send ("{4}")
EndFunc

Is this correct?

Share this post


Link to post
Share on other sites

Func Automate()
     AdlibEnable("TimeFunc", 900000)
     Do
         Send ("{F1}")
         Sleep (2000)
         $Count = $Count + 1
         If $Count = 7 Then
             Send ("{F5}")
             Sleep (10000)
             $Count = 0
         EndIf
     Until $Count = 10
 EndFunc
 
 Func TimeFunc()
     Send ("{4}")
 EndFunc

Is this correct?

No, not quite if you want it to send 4 all the time. best way is to store the key in a global variable and then change it in your timefunc:

Global $key="{F5}"
Func Automate()
     AdlibEnable("TimeFunc", 900000)
     Do
         Send ("{F1}")
         Sleep (2000)
         $Count = $Count + 1
         If $Count = 7 Then
             Send ($key) ; assuming it's this one that changes.
             Sleep (10000)
             $Count = 0
         EndIf
     Until $Count = 10
 EndFunc
 
 Func TimeFunc()
     $key="4"
 EndFunc

:)


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

No, not quite if you want it to send 4 all the time. best way is to store the key in a global variable and then change it in your timefunc:

Global $key="{F5}"
Func Automate()
     AdlibEnable("TimeFunc", 900000)
     Do
         Send ("{F1}")
         Sleep (2000)
         $Count = $Count + 1
         If $Count = 7 Then
             Send ($key) ; assuming it's this one that changes.
             Sleep (10000)
             $Count = 0
         EndIf
     Until $Count = 10
 EndFunc
 
 Func TimeFunc()
     $key="4"
 EndFunc

:)

i didnt want to replace it sending 7, i wanted to send 4 in addition to it. Sorry i wasnt very clear with that. I tried editing it a bit to test and send the keys to a open note pad window and it seems to work. Thanks very much for your idea it helps me a great deal.

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