Help making script to stop inputs

Ask gaming related questions (AHK v1.1 and older)
sparkle
Posts: 5
Joined: 07 Apr 2021, 20:17

Help making script to stop inputs

19 Apr 2021, 22:18

Just wanted to see if anyone could help me make a script that would stop me from inputting a or d when holding shift. If possible when I am holding a or d and click shift, I want it to stop inputting a or d and when I let go of shift it would go back to normal.
I've tried this and it doesn't work.
(im new to this)

Code: Select all

#if GetKeyState("Shift", "P")
a::
d::return 
#if 
^tried that and it doesnt work
User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Help making script to stop inputs

19 Apr 2021, 22:33

Code: Select all

$a::
$d::
hk := SubStr(A_ThisHotkey, 0)
While GetKeyState(hk, "P") {
 Send % GetKeyState("Shift") ? "" : hk
 Sleep, 25
}
Return
sparkle
Posts: 5
Joined: 07 Apr 2021, 20:17

Re: Help making script to stop inputs

19 Apr 2021, 22:39

mikeyww wrote:
19 Apr 2021, 22:33

Code: Select all

$a::
$d::
hk := SubStr(A_ThisHotkey, 0)
While GetKeyState(hk, "P") {
 Send % GetKeyState("Shift") ? "" : hk
 Sleep, 25
}
Return
tried it but its like its acting as if im not holding down a or d anymore but just inputting a lot of a's and d's.
sometimes when pressing a or d I input like 3 clicks of a or d instead of it being like a normal key being pressed down. If possible, the script should just allow a and d to be pressed normally?
User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Help making script to stop inputs

19 Apr 2021, 22:52

If you increase the sleep to about 120, you can avoid the repeats.
sparkle
Posts: 5
Joined: 07 Apr 2021, 20:17

Re: Help making script to stop inputs

19 Apr 2021, 22:53

mikeyww wrote:
19 Apr 2021, 22:52
If you increase the sleep to about 120, you can avoid the repeats.
is it possible to make it replicate a normal key press not individual key presses. The software i’m testing it on recognizes key holds and not inputs i think.
User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Help making script to stop inputs

20 Apr 2021, 05:15

You can try something like the following, though I do not have a way to test in your program (especially since I don't know what program it is).

Code: Select all

~Shift Up::Send % GetKeyState("a", "P") ? "{a up}{a down}" : ""
Does the first script work in Notepad?
sparkle
Posts: 5
Joined: 07 Apr 2021, 20:17

Re: Help making script to stop inputs

20 Apr 2021, 08:05

mikeyww wrote:
20 Apr 2021, 05:15
You can try something like the following, though I do not have a way to test in your program (especially since I don't know what program it is).

Code: Select all

~Shift Up::Send % GetKeyState("a", "P") ? "{a up}{a down}" : ""
Does the first script work in Notepad?
the first script works in notepad. I'm trying to get this to work for a game where it would help me prevent accidentally move right or left while holding down the shift key.
User avatar
mikeyww
Posts: 26885
Joined: 09 Sep 2014, 18:38

Re: Help making script to stop inputs

20 Apr 2021, 09:38

It sounds like Notepad responds as you expect, but the game does not. I do not have a way to address that, but the tips for games may help you.

https://autohotkey.com/board/topic/111737-how-to-make-ahk-work-in-most-games-the-basics/

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 84 guests