Sign in to follow this  
Followers 0
ihenvyr

Timer Script Edited

2 posts in this topic

#1 ·  Posted (edited)

The scenario is like this:

The game started as PAUSE, you have to press hotkey "T" to send "P" in order to resume game -at the same time, it starts to count down from 2 minutes

......and while continue to press hotkey "T" it adds another 2 minutes and another 2 minutes ..and so on..

note: no sending "P" while adding time..

on the other side, if timer reaches ZERO "0" it will send "P" again to PAUSE the game..

:) Please help me about this guys.. or some recommendations..

thanks :mellow:

HotKeySet("t", "ADD_TO_TIMER")

Dim $ADDTIME = "", $TIME_WAS_ADDED, $TIMER, $MY_TIME_LEFT
Func ADD_TO_TIMER()
    If Not $ADDTIME <> "" Then
        $ADDTIME = 2
        $TIME_WAS_ADDED = 1
        $TIMER = TimerInit()
    Else
        $ADDTIME = 2 + $MY_TIME_LEFT
    EndIf
EndFunc ;==>ADD_TO_TIMER
While 1
; SCRIPT HERE
    If $TIME_WAS_ADDED = 1 Then
        $DIFF = TimerDiff($TIMER) / 1000 / 60
        $MY_TIME_LEFT = $ADDTIME - $DIFF
        If $MY_TIME_LEFT = 0 Then
            $TIME_WAS_ADDED = 0
            $ADDTIME = ""
            $MY_TIME_LEFT = ""
            Send("p")
        EndIf
    EndIf
    ToolTip("TIME LEFT = [ " & Round($MY_TIME_LEFT) & " ]" & " minutes left", 0, 0)
    Sleep(100)
WEnd
Edited by ihenvyr

Umbrella Member

Share this post


Link to post
Share on other sites



The scenario is like this:

The game started as PAUSE, you have to press hotkey "T" to send "P" in order to resume game -at the same time, it starts to count down from 2 minutes

......and while continue to press hotkey "T" it adds another 2 minutes and another 2 minutes ..and so on..

note: no sending "P" while adding time..

on the other side, if timer reaches ZERO "0" it will send "P" again to PAUSE the game..

:) Please help me about this guys.. or some recommendations..

thanks :mellow:

HotKeySet("t", "ADD_TO_TIMER")

Dim $ADDTIME = "", $TIME_WAS_ADDED, $TIMER, $MY_TIME_LEFT

Func ADD_TO_TIMER()

If Not $ADDTIME <> "" Then

$ADDTIME = 2

$TIME_WAS_ADDED = 1

$TIMER = TimerInit()

Else

$ADDTIME = 2 + $MY_TIME_LEFT

EndIf

EndFunc ;==>ADD_TO_TIMER

While 1

; SCRIPT HERE

If $TIME_WAS_ADDED = 1 Then

$DIFF = TimerDiff($TIMER) / 1000 / 60

$MY_TIME_LEFT = $ADDTIME - $DIFF

If $MY_TIME_LEFT = 0 Then

$TIME_WAS_ADDED = 0

$ADDTIME = ""

$MY_TIME_LEFT = ""

Send("p")

EndIf

EndIf

ToolTip("TIME LEFT = [ " & Round($MY_TIME_LEFT) & " ]" & " minutes left", 0, 0)

Sleep(100)

WEnd

I don't know if this will help you or not, I really haven't used any of the send keys functions with the exception of HotKeySet in one script I am working on to reload the data into the GUI.

What I have found is tha trying to use a regular character key like "t" to a function does not work in my script. If I use a key like {HOME} or {F10}, it works fine. I hav tried using ASCII values, etc but the regular character keys just won't work for me in this instance. Try usin a function key instead of t and see what happens.

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