Need to help with Key hold script

Ask gaming related questions (AHK v1.1 and older)
Jikol
Posts: 1
Joined: 11 Mar 2020, 15:38

Need to help with Key hold script

11 Mar 2020, 16:01

Hello.
I'm quite new in this awesome method how customize your computer keyboard actions by AHK :)
So I decided that I can use it for Minecraft autorun, instead of using some game modifications.
I was trying make some script for it, first tage was this which i also found here by some wonderful helper:

Code: Select all

#SingleInstance, Ignore
#If WinActive("ahk_class GLFW30")
    XButton2::
    KeyDown := !KeyDown
    If KeyDown
	SendInput {w down}
    Else
	SendInput {w up}
    Return
#If

LControl & LShift::ExitApp
But, it's quite unhandy becouse i need to stop autorun by pressing Xbutton2 again or pressing W. So I thought that I can disable it when I press anything else than Xbutton2.
But I can't end up with working solution.
My try is this:

Code: Select all

#SingleInstance, Ignore
#If WinActive("ahk_class GLFW30")
    XButton2::
    Pressed := 1
    
    !XButton2::
    Pressed := 0
    
    If (Pressed)
        SendInput {w down}
    else
        SendInput {w up}
    return
    
    /* C++ reference for what i want to do
    bool pressed;
    if (KeyPressed == XButton2) {
        pressed = true;
    }
    if (KeyPressed != XButton2) {
        pressed = false;
    }
    
    if (pressed) {
        Key('w').MakeItHold();
    } else {
        Key('w').MakeItUnhold();
    }
    */
#If
I maked C++ reference for what I want to do, so If anyone will help me It will be nice.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 29 guests