Hey guys. Need help with makin script that key doesnt need to be held when usin it.

Ask gaming related questions (AHK v1.1 and older)
DSmokE
Posts: 7
Joined: 18 Apr 2021, 11:11

Hey guys. Need help with makin script that key doesnt need to be held when usin it.

Post by DSmokE » 20 Jul 2021, 06:59

Hi guys. I have this script and its really annoyin to me that i need to hold capslock all the time, so if someone can help me would be much appriciated. Need it to be non stop on without holdin a capslocl key.

Code: Select all

mouseXY(x, y)
{
DllCall("mouse_event",uint,1,int,x,int,y,uint,0,int,0)
}

strafe(left)
{
moveCount := 1
sleepInterval = 1
relativeMove := 3000

if (left)
{
key := ""
move := relativeMove
} else
{
key := ""
move := -relativeMove
}
send {Blind}{%key% down}
DllCall("Sleep", "UInt", 5)
Loop, %moveCount%
{
mouseXY(move, -(move/4))
DllCall("Sleep", "UInt", sleepInterval)
}
send {Blind}{%key% up}
}

$CapsLock::
while getkeystate("CapsLock","P")
{
strafe(true)
strafe(false)
}
return
$*F4:: Suspend, Toggle
[Mod edit: [code][/code] tags added.]

Thanks in advance!

User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: Hey guys. Need help with makin script that key doesnt need to be held when usin it.

Post by mikeyww » 20 Jul 2021, 07:52

Would have a look at the documentation for GetKeyState(). CapsLock uses the "T" mode.

DSmokE
Posts: 7
Joined: 18 Apr 2021, 11:11

Re: Hey guys. Need help with makin script that key doesnt need to be held when usin it.

Post by DSmokE » 21 Jul 2021, 03:19

mikeyww wrote:
20 Jul 2021, 07:52
Would have a look at the documentation for GetKeyState(). CapsLock uses the "T" mode.
I have tried a lot of things but it just doesn't work for me. Code

Code: Select all

$Mbutton::
while getkeystate("Mbutton","P")
{
strafe(true)
strafe(false)
}
return
$*F4:: Suspend, Toggle
[Mod edit: [code][/code] tags added.]

Cant get it to get in loop :(

User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: Hey guys. Need help with makin script that key doesnt need to be held when usin it.

Post by mikeyww » 21 Jul 2021, 05:28

The While statement requires you to hold the key, because the routine executes while you do that. If you don't want the While, you can change it to Loop.

Post Reply

Return to “Gaming Help (v1)”