Blacklisting Keys From AutoHotKey

Ask gaming related questions (AHK v1.1 and older)
suffix
Posts: 8
Joined: 07 Jun 2023, 13:12

Blacklisting Keys From AutoHotKey

Post by suffix » 08 Jun 2023, 03:01

hello, i have made a script/gui that i am very proud of but for some reason it will randomly press a key that i pressed before everytime it tries to do what its supposed to (this doesnt happen every time but it does quite a bit of the time) so i would like to blacklist keys from autohotkey so it isnt able to press/input them. those keys are capslock, q & f if you are able to help me out with this i would greatly appreciate it! :D

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

Re: Blacklisting Keys From AutoHotKey

Post by mikeyww » 08 Jun 2023, 05:25

If you mean something outside the script, like a second script, I wouldn't recommend it, because the software could conflict in unexpected ways. If you mean something inside the script, you are talking about modifying the script itself. I don't know a way, but even if there were one, the better approach would be to debug the script that you have. Find out which line is sending the key, and adjust it. Debugging a script

suffix
Posts: 8
Joined: 07 Jun 2023, 13:12

Re: Blacklisting Keys From AutoHotKey

Post by suffix » 08 Jun 2023, 05:55

hey mikey, in the script there is nothing that tells the script to press the keys that it isnt supposed to so im at a loss as to why it does so. if i have some how missed something and you would take the time to look yourself here is the script:

Code: Select all

#NoEnv
#SingleInstance, Force
#Persistent
#InstallKeybdHook
#UseHook
#KeyHistory, 0
#HotKeyInterval 1
#MaxHotkeysPerInterval 127

TrigColor := 0xA5A528

Gui, Add, Text, x12 y5 w50 h20, Features:
Gui, Add, Text, x278 y5 w50 h20, Colors:
Gui, Add, CheckBox, x12 y49 w100 h30 vNMCheckFR gValueFR , Not Moving Only
Gui, Add, CheckBox, x278 y19 w60 h30 Checked vYCCheckFR gValueFR , Yellow
Gui, Add, CheckBox, x278 y49 w60 h30 vPCCheckFR gValueFR , Purple
Gui, Add, CheckBox, x278 y79 w60 h30 vRCCheckFR gValueFR , Red
Gui, Add, CheckBox, x12 y109 w100 h30 vBHCheckFR gValueFR , Bhop ; not added
Gui, Add, CheckBox, x12 y139 w100 h30 vRFCheckFR gValueFR , RapidFire ; not added
Gui, Add, CheckBox, x12 y79 w200 h30 vKPCheckFR gValueFR , Key Press Only (M5/MouseButton5)
Gui, Add, CheckBox, x12 y19 w100 h30 vTBCheckFR gValueFR , TriggerBot
Gui, Font, S8 CDefault Bold, Poppins
Gui, Font, S8 CDefault Bold Underline, Poppins
Gui, Font, S8 CDefault, Poppins
Gui, Font, S8 CDefault, Poppins
Gui, Font, S8 CDefault, Poppins
Gui, Add, Text, x142 y139 w0 h0 , Text
Gui, Font, S8 CDefault Strike, Poppins
Gui, Add, Text, x172 y69 w-40 h70 , Text
Gui, Font, , 
Gui, Add, Text, x12 y169 w370 h470 +Center, Make sure VALORANT is in windowed fullscreen mode!
Gui, Font, S12, Poppins
Gui, Submit, NoHide
Gui, Show, h191 w402, SnoopyVal | v1.1 | s+p=<3

thing1 := (A_ScreenHeight // 160)
thing2 := (A_ScreenHeight // 128)
ZeroX := (A_ScreenWidth // 2)
ZeroY := (A_ScreenHeight // 2) 
scan1 := ZeroX - thing1
scan2 := ZeroY - thing2
scan3 := ZeroX + thing1
scan4 := ZeroY + thing2

SetKeyDelay,-1, 1
SetControlDelay, -1
SetMouseDelay, -1
SendMode, InputThenPlay
SetBatchLines,-1
SetWinDelay,-1
ListLines, Off
CoordMode, Pixel, Screen, RGB
CoordMode, Mouse, Screen

Loop
{
    if (YCCheckFR=1) {
        PCCheckFR := 0
        RCCheckFR := 0
        TrigColor := 0xA5A528
    }

    if (PCCheckFR=1) {
        YCCheckFR := 0
        RCCheckFR := 0
        TrigColor := 0xA145A3
    }

    if (RCCheckFR=1) {
        PCCheckFR := 0
        YCCheckFR := 0
        TrigColor := 0xB82C29
    }

    if (TBCheckFR=1 && KPCheckFR=0 && NMCheckFR=0) {
        PixelSearch, Px, Py, scan1, scan2, scan3, scan4, TrigColor, 20, Fast RGB
        if (ErrorLevel=0) {
            PixelSearch, Px, Py, scan1, scan2, scan3, scan4, TrigColor, 20, Fast RGB
            Loop, 1 {
                Random, rand, 2, 9
                Sleep, rand
                Send, {LButton Down}
                Sleep, 1
                Send, {LButton Up}
            }
        }
    }

    if (TBCheckFR=1 && KPCheckFR=0 && NMCheckFR=1) {
        if (!GetKeyState("w") && !GetKeyState("a") && !GetKeyState("s") && !GetKeyState("d")) {
            PixelSearch, Px, Py, scan1, scan2, scan3, scan4, TrigColor, 20, Fast RGB
            if (ErrorLevel=0) {
                PixelSearch, Px, Py, scan1, scan2, scan3, scan4, TrigColor, 20, Fast RGB
                Loop, 1 {
                    Random, rand, 2, 9
                    Sleep, rand
                    Send, {LButton Down}
                    Sleep, 1
                    Send, {LButton Up}
                }
            }
        }
    }

    if (TBCheckFR=1 && KPCheckFR=1 && NMCheckFR=0) {
        if GetKeyState("XButton2") {
            PixelSearch, Px, Py, scan1, scan2, scan3, scan4, 0xA5A528, 20, Fast RGB
            if (ErrorLevel=0) {
                PixelSearch, Px, Py, scan1, scan2, scan3, scan4, 0xA5A528, 20, Fast RGB
                Loop, 1 {
                    Random, rand, 2, 9
                    Sleep, rand
                    Send, {LButton Down}
                    Sleep, 1
                    Send, {LButton Up}
                }
            }
        }
    }

    if (TBCheckFR=1 && KPCheckFR=1 && NMCheckFR=1) {
        if GetKeyState("XButton2") {
            if (!GetKeyState("w") && !GetKeyState("a") && !GetKeyState("s") && !GetKeyState("d")) {
                PixelSearch, Px, Py, scan1, scan2, scan3, scan4, 0xA5A528, 20, Fast RGB
                if (ErrorLevel=0) {
                    PixelSearch, Px, Py, scan1, scan2, scan3, scan4, 0xA5A528, 20, Fast RGB
                    Loop, 1 {
                        Random, rand, 2, 9
                        Sleep, rand
                        Send, {LButton Down}
                        Sleep, 1
                        Send, {LButton Up}
                    }
                }
            }
        }
    }
}

ValueFR:
Gui, Submit, NoHide
return

end::
exitapp
return

Quitter:
ExitApp

GuiClose:
ExitApp


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

Re: Blacklisting Keys From AutoHotKey

Post by mikeyww » 08 Jun 2023, 07:22

The script just clicks, but clicking can have various effects, depending on what the click does to the target program.

Tips:
1. Shorten the script so that you can test just one part of it.
2. Check the :arrow: KeyHistory to verify what is happening with the keys.
3. Consider changing the click to a simple message that is displayed. This may help you understand & troubleshoot the script.

suffix
Posts: 8
Joined: 07 Jun 2023, 13:12

Re: Blacklisting Keys From AutoHotKey

Post by suffix » 08 Jun 2023, 11:05

mikeyww wrote:
08 Jun 2023, 07:22
The script just clicks, but clicking can have various effects, depending on what the click does to the target program.

Tips:
1. Shorten the script so that you can test just one part of it.
2. Check the :arrow: KeyHistory to verify what is happening with the keys.
3. Consider changing the click to a simple message that is displayed. This may help you understand & troubleshoot the script.
hey mikey, so i have tried what you said and i just can not figure out why its doing it. if you are able to supply me with any other ideas it would be a great help. im truly at a loss

suffix
Posts: 8
Joined: 07 Jun 2023, 13:12

Re: Blacklisting Keys From AutoHotKey

Post by suffix » 08 Jun 2023, 11:35

mikeyww wrote:
08 Jun 2023, 07:22
The script just clicks, but clicking can have various effects, depending on what the click does to the target program.

Tips:
1. Shorten the script so that you can test just one part of it.
2. Check the :arrow: KeyHistory to verify what is happening with the keys.
3. Consider changing the click to a simple message that is displayed. This may help you understand & troubleshoot the script.
okay i just found something out, its not actually pressing the key (capslock) because when the bug happens the capital state stays the same. this script is for the game VALORANT and my ability 2 is binded to capslock so its just activating my ability 2 not actually pressing capslock. if you have any ideas on how to fix the real issue let me know

suffix
Posts: 8
Joined: 07 Jun 2023, 13:12

Re: Blacklisting Keys From AutoHotKey

Post by suffix » 08 Jun 2023, 13:21

mikeyww wrote:
08 Jun 2023, 07:22
The script just clicks, but clicking can have various effects, depending on what the click does to the target program.

Tips:
1. Shorten the script so that you can test just one part of it.
2. Check the :arrow: KeyHistory to verify what is happening with the keys.
3. Consider changing the click to a simple message that is displayed. This may help you understand & troubleshoot the script.
@mikeyww

so i have actually just found out that when i suspend the script (trigger bot still works which is good) but the bug stops meaning (theoretically) its some sort of hotkey doing it. these are the only hotkeys in my script and i dont see what would be causing them

Code: Select all

~Space::
    while(BHCheckFR=1) {
        GetKeyState,state,space,P
        If state = U
            Break
        Send,{Space}              
        Sleep,20
    }

~LButton::                                                                                                              
    while(RFCheckFR=1) {
        GetKeyState,state,LButton,P
        If state = U
            Break          
        Send, {LButton Down}
        Sleep, 1
        Send, {LButton Up}
        Sleep,76
    }

[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]

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

Re: Blacklisting Keys From AutoHotKey

Post by mikeyww » 08 Jun 2023, 14:14

The ideas that I wrote were the real ideas for debugging your script! If this were my script, I would be following those exact steps. In addition, I would test this in Notepad or some other program so that you are not simply seeing the game's reaction to what you are doing.

Best of luck.

Post Reply

Return to “Gaming Help (v1)”