Hi, brand new to AHK and was wondering if someone could help me with/write a simple script that can toggle on 'holding down' the 'w' key until it is toggled off. I'd like the toggle to be ^!w (CTRL-ALT-W) unless having the toggle be the same as the held down key would cause problems, in which case ^!q would be just fine, whatever is easiest.
This is to create a basic auto-walk function in minecraft so I can give my middle finger a break from holding down w all the time. I found a few threads doing the same thing in AHK v1 forums but don't know how to translate them to v2.
Simple Toggle 'hold w'
-
- Posts: 3
- Joined: 04 Jan 2024, 14:35
-
- Posts: 3
- Joined: 04 Jan 2024, 14:35
Re: Simple Toggle 'hold w'
Closest thing I've found so far:
But this sends the input "w" over and over again, as if repeatedly pressing the button. I need it to 'hold down' the button.
Code: Select all
F1:: {
static toggled := false
static SendKey := Send.Bind('{w}') ; alternatively: static SendKey := () => Send('{w}')
if toggled := !toggled
SetTimer(SendKey, 20)
else
SetTimer(SendKey, 0)
}
-
- Posts: 3
- Joined: 04 Jan 2024, 14:35
Re: Simple Toggle 'hold w'
Alright, got it (sort of) working. Toggling it on and off does make it stop typing "w" but my character does not stop walking (this is an auto-walker for minecraft) for a good amount of time. I'm not sure what the trigger to stop my character is, but I think it has something to do with hitting F1 then typing then jumping onto a higher block. Not sure how to fix this but it functions sufficiently for now!
Code: Select all
F1:: {
static toggled := false
static SendKey := () => Send('{w down}')
if toggled := !toggled
SetTimer(SendKey, 20)
else
SetTimer(SendKey, 0)
}
Re: Simple Toggle 'hold w'
Code: Select all
^!w:: {
KeyWait('w')
SendEvent('{w ' (GetKeyState('w') ? 'up' : 'down') '}')
}
Who is online
Users browsing this forum: No registered users and 12 guests