creating a loop

Ask gaming related questions
fferrulli
Posts: 1
Joined: 21 Feb 2018, 06:09

creating a loop

21 Feb 2018, 06:29

Hi all, this is my first post here and i would like to thank anyone for the answer.

i am in need of a loop:

This is what i am using now:

$1::
Loop
{
if not GetKeyState("1", "P")
break
Send 1
sleep 30
}
return
$2::
Loop
{
if not GetKeyState("2", "P")
break
Send 2
sleep 30
}
return
$3::
Loop
{
if not GetKeyState("3", "P")
break
Send 3
sleep 30
}
return
$4::

I would like to press the key one time and the loop goes on until i press the same key again or an other key, If i press an other key the other loop starts. Is it possible?

Thank you
Rohwedder
Posts: 1290
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: creating a loop

22 Feb 2018, 09:37

Hallo,
try:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

or the same shorter:

Code: [Select all] [Download] GeSHi © Codebox Plus

$1::
$2::
$3::
If (Key = A_ThisHotkey), Key := ""
SetTimer, Key, Off
Else Key := A_ThisHotkey
SetTimer, Key, 30
Return
Key:
Send, % SubStr(Key,0)
Return
or:

Code: [Select all] [Download] GeSHi © Codebox Plus

$1::
$2::
$3::
Key := Key = A_ThisHotkey ? "":A_ThisHotkey
SetTimer Key,% Key ? "30":"Off"
Return
Key:
Send, % SubStr(Key,0)
Return

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 13 guests