1
votes

So I was making a AFK stopper with AHK but I need it to only run in one program so I used #If WinActive but to no avail.

#If WinActive("ahk_class WINDOWSCLIENT")
while( 1 = 1 ) {
    Send, {W down}
    sleep 240
    Send, {W up}
    sleep 240
    Send, {A down}
    sleep 240
    Send, {A up}
    sleep 240
    Send, {S down}
    sleep 240
    Send, {S up}
    sleep 240
    Send, {D down}
    sleep 240
    Send, {D up}
}
1

1 Answers

0
votes

The #IfWin directives are only for creating context-sensitive hotkeys and hotstrings. Try using a loop or SetTimer with IfWinActive:

Loop 
{
    If WinActive("ahk_class WINDOWSCLIENT")
    {
        while( 1 = 1 ) 
        {
            ; do something
        }
    }
}