Jump to content

TIMER SCRIPT Help please..


ihenvyr
 Share

Recommended Posts

Hi to all!!

its me again..

i have a plan of making a timer script,

but i have no idea how to begin with..

its a timer script which:

for example, when pressing "T"

time counts down lets say

counts down for 5 minutes..

then.. when time is up

it blocks the keyboard/mouse input.

..and if you keep pressing "T"

it also keep adding 5 minutes

while counting down..

its sound pretty advance

to me as a newbie.. B)

Help please ..thanks!!

Umbrella Member

Link to comment
Share on other sites

Search the forums for timer, you will be amazed at what you find.

Here is one I found that could possibly be modified to do what you want.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Hi to all!!

its me again..

i have a plan of making a timer script,

but i have no idea how to begin with..

its a timer script which:

for example, when pressing "T"

time counts down lets say

counts down for 5 minutes..

then.. when time is up

it blocks the keyboard/mouse input.

..and if you keep pressing "T"

it also keep adding 5 minutes

while counting down..

its sound pretty advance

to me as a newbie.. B)

Help please ..thanks!!

HotKeySet("T", "TIMERADD")
HotKeySet("{F1}", "TIMERSTAR")
$timeon = 0
$time = 0

Func TIMERADD()
    $time = $time + 1
    MsgBox(1, "Time", "1 Min added!", 1)
EndFunc

Func TIMERSTAR()
    If $timeon = 1 Then
    $timeon = 0
    MsgBox(1, "Timer off", "Timer is off!", 1)
ElseIf $timeon = 0 Then
    $timeon = 1
    MsgBox(1, "Timer on", "Timer is on!", 1)
    EndIf
EndFunc

While 1
    If $timeon = 1 Then
        $time = $time - 1
        BlockInput(0)
        Sleep(60000)
        If $time = 0 Then
            MsgBox(1, "Beep", "Timer went off!", 1)
            BlockInput(1)
            $timeon = 0
            SoundSetWaveVolume(100)
            SoundPlay("") 
            #comments-start Put the path and name of sound and extension in soundplay box! 
            #comments-end
        EndIf
    EndIf
WEnd

Timer.au3

Edited by WHRobin566
Witch Hunter Robin
Link to comment
Share on other sites

HotKeySet("T", "TIMERADD")
HotKeySet("{F1}", "TIMERSTAR")
$timeon = 0
$time = 0

Func TIMERADD()
    $time = $time + 1
    MsgBox(1, "Time", "1 Min added!", 1)
EndFunc

Func TIMERSTAR()
    If $timeon = 1 Then
    $timeon = 0
    MsgBox(1, "Timer off", "Timer is off!", 1)
ElseIf $timeon = 0 Then
    $timeon = 1
    MsgBox(1, "Timer on", "Timer is on!", 1)
    EndIf
EndFunc

While 1
    If $timeon = 1 Then
        $time = $time - 1
        BlockInput(0)
        Sleep(60000)
        If $time = 0 Then
            MsgBox(1, "Beep", "Timer went off!", 1)
            BlockInput(1)
            $timeon = 0
            SoundSetWaveVolume(100)
            SoundPlay("") 
            #comments-start Put the path and name of sound and extension in soundplay box! 
            #comments-end
        EndIf
    EndIf
WEnd
thanks but..

time doesn't counts down

and doesn't add..

..its soooooo confusing B)

EXPERTS PLEASE HELP

Umbrella Member

Link to comment
Share on other sites

Did you look at the one that I pointed you to ?

It does a countdown of sorts. I am sure if you studied it to see exactly what it does you could modify it to suit.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Did you look at the one that I pointed you to ?

It does a countdown of sorts. I am sure if you studied it to see exactly what it does you could modify it to suit.

Yes BigDod, but it says:

AutoIt Error

Line 20

tooltip("Timer = " & int($tdif) & " Minutes",0,0,"", 5)

^ERROR

still can't modify because of that.. B)

Umbrella Member

Link to comment
Share on other sites

  • Moderators

Kind of crude, but try this:

HotKeySet("t", "ADD_TO_TIMER")

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


Func ADD_TO_TIMER()
    If Not $ADDTIME <> "" Then
        $ADDTIME = 5
        $TIME_WAS_ADDED = 1
        $TIMER = TimerInit()
    Else
        $ADDTIME = 5 + $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
            BlockInput(1)
            $TIME_WAS_ADDED = 0
            $ADDTIME = ""
            $MY_TIME_LEFT = ""
            MsgBox(0, '', 'BLOCKED AND EXITING', 3)
            Exit
        EndIf
    EndIf
    ToolTip("TIME LEFT = [ " & Round($MY_TIME_LEFT) & " ]" & " minutes left", 0, 0)
    Sleep(100)
WEnd

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Kind of crude, but try this:

HotKeySet("t", "ADD_TO_TIMER")

Dim $ADDTIME = "", $TIME_WAS_ADDED, $TIMER, $MY_TIME_LEFT
Func ADD_TO_TIMER()
    If Not $ADDTIME <> "" Then
        $ADDTIME = 5
        $TIME_WAS_ADDED = 1
        $TIMER = TimerInit()
    Else
        $ADDTIME = 5 + $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
            BlockInput(1)
            $TIME_WAS_ADDED = 0
            $ADDTIME = ""
            $MY_TIME_LEFT = ""
            MsgBox(0, '', 'BLOCKED AND EXITING', 3)
            Exit
        EndIf
    EndIf
    ToolTip("TIME LEFT = [ " & Round($MY_TIME_LEFT) & " ]" & " minutes left", 0, 0)
    Sleep(100)
WEnd
Thank You Very Much ronsrules!! :graduated:

i'll gonna try to modify it according to my needs.. B)

More Power to all!! :o

Umbrella Member

Link to comment
Share on other sites

  • Moderators

Good Deal B)

Were you able to modify it to suit your needs?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Good Deal :)

Were you able to modify it to suit your needs?

:o ..i can't

soo hard for me..

id keep pressing "t" till reaches 30 minutes

but after 10 or 15 minutes passed/deducted

it keeps subtracting 5 minutes if you keep pressing "t"

why is it happening? :graduated:

PS:

about tooltips,

is it possible to see it clearly without flickering during

fullscreen games? or any recommendation other than

tooltips to see the timer details without flickering?

Thanks B)

Umbrella Member

Link to comment
Share on other sites

  • Moderators

The example I gave you doesn't flicker for me... Why don't you post exactly what you did. I tested it last night with an auto shut off, for 90 minutes, and it did it. (Using "t" to add 5 minutes to 90 minutes).

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • 4 months later...

hi i'm back its been a long time since...

here it is my script.. please i need some help :)

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..

there is something wrong about sending "P"..

thanks :mellow:

HotKeySet("t", "ADD_TO_TIMER")

Dim $ADDTIME = "", $TIME_WAS_ADDED, $TIMER, $MY_TIME_LEFT
Func ADD_TO_TIMER()
    If Not $ADDTIME <> "" Then
        Send("p")
        $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
            Send("p")
            $TIME_WAS_ADDED = 0
            $ADDTIME = ""
            $MY_TIME_LEFT = ""
        EndIf
    EndIf
    ToolTip("TIME LEFT = [ " & Round($MY_TIME_LEFT) & " ]" & " minutes left", 0, 0)
    Sleep(100)
WEnd
Edited by ihenvyr

Umbrella Member

Link to comment
Share on other sites

  • Moderators

Are you sure there is something wrong with sending 'p', or is your game just not excepting the send command? (What game is it, maybe someone here can tell you).

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

yes there is something wrong .. it doesnt' send "P".. i use an emulator called M.A.M.E (Multiple Arcade Machine Emulator) the default key for PAUSE is "P"..

..and i test it by opening notepad and it doesn't send neither..

please help.. :)

Edited by ihenvyr

Umbrella Member

Link to comment
Share on other sites

  • Moderators

yes there is something wrong .. it doesnt' send "P".. i use an emulator called M.A.M.E (Multiple Arcade Machine Emulator) the default key for PAUSE is "P"..

..and i test it by opening notepad and it doesn't send neither..

please help.. :)

This worked for me:
HotKeySet("t", "ADD_TO_TIMER")

Dim $ADDTIME = "", $TIME_WAS_ADDED, $TIMER, $MY_TIME_LEFT
Func ADD_TO_TIMER()
    If Not $ADDTIME <> "" Then
        Send("p")
        $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
        $MY_TIME_LEFT = ($ADDTIME * 60) - $DIFF
        If $MY_TIME_LEFT <= 0 Then
            Run('Notepad.exe')
            WinWaitActive('Untitled - Notepad')
            Send("p")
            $TIME_WAS_ADDED = 0
            $ADDTIME = ""
            $MY_TIME_LEFT = ""
        EndIf
    EndIf
    ToolTip('TIME LEFT: ' & StringFormat('%i minute(s) and %i second(s)', $MY_TIME_LEFT / 60 , Mod($MY_TIME_LEFT , 60)), 0, 0)
    Sleep(100)
WEnd
Of course you have to actually click 't' to activate it. It openened notepad, and sent 'p' to notepad.

Edit:

You do realize that you are sending 'p' twice right?

Edit2:

Added an actual count down tracker with Minutes and Seconds.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

:mellow: thank you very much!!!

it work!

..pressing "T" adds 2 minutes, pressing "T" again adds another 2 minutes ..and so on

but when i press "T" twice the time changed to 120+ minutes instead of 4 minutes.. :)

press "T" trice the time changed to 1200+ minutes instead of 12 minutes.

..hoping for you m8 :)

thanks

Umbrella Member

Link to comment
Share on other sites

  • Moderators

:mellow: thank you very much!!!

it work!

..pressing "T" adds 2 minutes, pressing "T" again adds another 2 minutes ..and so on

but when i press "T" twice the time changed to 120+ minutes instead of 4 minutes.. :)

press "T" trice the time changed to 1200+ minutes instead of 12 minutes.

..hoping for you m8 :)

thanks

HotKeySet("t", "ADD_TO_TIMER")

Dim $ADDTIME = "", $TIME_WAS_ADDED, $TIMER, $MY_TIME_LEFT
Func ADD_TO_TIMER()
    If Not $ADDTIME <> "" Then
        Send("p")
        $ADDTIME = 2
        $TIME_WAS_ADDED = 1
        $TIMER = TimerInit()
    Else
        $ADDTIME = 2 + ($MY_TIME_LEFT / 60)
    EndIf
EndFunc;==>ADD_TO_TIMER
While 1
; SCRIPT HERE
    If $TIME_WAS_ADDED = 1 Then
        $DIFF = TimerDiff($TIMER) / 1000
        $MY_TIME_LEFT = ($ADDTIME * 60) - $DIFF
        If $MY_TIME_LEFT <= 0 Then
            Run('Notepad.exe')
            WinWaitActive('Untitled - Notepad')
            Send("p")
            $TIME_WAS_ADDED = 0
            $ADDTIME = ""
            $MY_TIME_LEFT = ""
        EndIf
    EndIf
    ToolTip('TIME LEFT: ' & StringFormat('%i minute(s) and %i second(s)', $MY_TIME_LEFT / 60 , Mod($MY_TIME_LEFT , 60)), 0, 0)
    Sleep(100)
WEnd
Just forgot to fixe the $ADDTIME = 2 + $MY_TIME_LEFT Else statement when I changed the timer settings. Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • 4 weeks later...

as i observed, the countdown timer in "seconds" is decreasing fast when i continually pressing "T" to add time.. IS IT NORMAL? or IS THERE SOMETHING WRONG WITH THIS SCRIPT?

Please help.. :think:

HotKeySet("t", "ADD_TO_TIMER")

Dim $ADDTIME = "", $TIME_WAS_ADDED, $TIMER, $MY_TIME_LEFT
Func ADD_TO_TIMER()
    If Not $ADDTIME <> "" Then
        Send("p")
        $ADDTIME = 4
        $TIME_WAS_ADDED = 1
        $TIMER = TimerInit()
    Else
        $ADDTIME = 4 + ($MY_TIME_LEFT / 60)
    EndIf
EndFunc;==>ADD_TO_TIMER
While 1
; SCRIPT HERE
    If $TIME_WAS_ADDED = 1 Then
        $DIFF = TimerDiff($TIMER) / 1000
        $MY_TIME_LEFT = ($ADDTIME * 60) - $DIFF
        If $MY_TIME_LEFT <= 0 Then
            Send("p")
            $TIME_WAS_ADDED = 0
            $ADDTIME = ""
            $MY_TIME_LEFT = ""
        EndIf
    EndIf
    ToolTip('TIME LEFT: ' & StringFormat('%i minute(s) and %i second(s)', $MY_TIME_LEFT / 60 , Mod($MY_TIME_LEFT , 60)), 0, 0)
    Sleep(100)
WEnd

Please some ideas..

Edited by ihenvyr

Umbrella Member

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...