Sign in to follow this  
Followers 0
Cykon

Hotkeys

4 posts in this topic

#1 ·  Posted (edited)

First let me start off that I am writing a simple timer for a game. (Phantasy Star) To increase your stats in the game, you use an item every 3.35 minutes. I have a timer currently going to show up in the top left corner of my screen. I reset the timer by pressing the + sign on my keyboard.

The only problem I have, is I can not use the hotkey while clicked onto the game's window.

ex: Game is on windowed mode, hotkey from auto it does not work, click on my computers start button, press hotkey

That is how I have been getting it to work. Any suggestions to make it so I can be in game and use the hotkey?

Thanks

$Seconds = 201
$on = 0
$paused = "Not Paused"

HotKeySet("{NUMPADADD}", "Timer")
HotKeySet("{NUMPADSUB}", "TimerPause")

While 1
    Sleep(100)
WEnd

Func Timer()
    if($on == 0) Then
        $on = 1
        Local $Count = 0, $begin = TimerInit()
        While $Seconds > $Count
           
            $dif = TimerDiff($begin)
            $dif2 = StringLeft($dif, StringInStr($dif, ".") -1)
            $Count = int($dif/1000)
           
            ToolTip("Seconds Required = " & "201" & @CRLF & "Seconds Count = " & $Count & @CRLF & $paused , 0, 0, "PSO Mag Timer", 1)
           
            Sleep(20)
        WEnd
        
        if($paused == "Not Paused") Then
            MsgBox(64, "Time-Up!!", "Go feed that mag!")
        EndIf
        $on = 0
    EndIf
EndFunc

Func TimerPause()
    if($paused == "Not Paused") Then
        $paused = "Paused"
    Else
        $paused = "Not Paused"
    EndIf
EndFunc
Edited by Cykon

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Most online games try to block keyboard hooks for anticheating.

Test this :

#Include <Misc.au3>
$Seconds = 201
$on = 0
$paused = "Not Paused"

HotKeySet("{NUMPADADD}", "Timer")
;HotKeySet("{NUMPADSUB}", "TimerPause")

While 1
    Sleep(100)
WEnd

Func Timer()
    if($on == 0) Then
        $on = 1
        Local $Count = 0, $begin = TimerInit()
        While $Seconds > $Count
          
            $dif = TimerDiff($begin)
            $dif2 = StringLeft($dif, StringInStr($dif, ".") -1)
            $Count = int($dif/1000)
          
            ToolTip("Seconds Required = " & "201" & @CRLF & "Seconds Count = " & $Count & @CRLF & $paused , 0, 0, "PSO Mag Timer", 1)
            If _IsPressed("24") Then TimerPause()
            Sleep(50)
        WEnd
        
        if($paused == "Not Paused") Then
            MsgBox(64, "Time-Up!!", "Go feed that mag!")
        EndIf
        $on = 0
    EndIf
EndFunc

Func TimerPause()
    if($paused == "Not Paused") Then
        $paused = "Paused"
    Else
        $paused = "Not Paused"
    EndIf
EndFunc

I replaced the second hotkey with an _IsPressed function inside that tooltip loop. Use the Home key to change from paused to not paused etc.

Does it work ?

Edited by Inverted

Share this post


Link to post
Share on other sites

The above method does work in game, thank you very much^^

It just changes extremely rapidly, but that can be fixed with an if statement =]

Share this post


Link to post
Share on other sites

Cool !

I usually just set the sleep a little higher and make sure I press the key quickly, ha !!

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