Hey guys.
I am a newbie, and couldn't gather enough information to make it work. My desire is to make a double key + hold action, so that combination would also hold another key, until i release it.
This is what i have accomplished so far, that works only just the half way:
~d::
KeyWait, d
KeyWait, d, D T.3
If (!ErrorLevel)
Send {e down}
While GetKeyState(d, "p")
Sleep 10
Send {e up}
Return
The idea is to double tap D, and hold it, so it will trigger E and hold it as well. Release both when released.
Thank you.
Help with Double tap and hold script
Re: Help with Double tap and hold script
I think what you're missing is a block around the commands after the If statement.
(I would use a second KeyWait, d instead of that While loop myself, but either should work.)
Without the block, only the Send {e down} is affected -- just like how the While loop only repeats the Sleep 10 command. And while you didn't provide a description of what doesn't work, my guess is your program is responding to the artificial Send {e up}.
If there is still something wrong, please let us know what isn't working -- whether it's not doing what you expect or doing something unexpected.
Code: Select all
If (!ErrorLevel)
{
Send {e down}
While GetKeyState(d, "p")
Sleep 10
Send {e up}
}
Return
Without the block, only the Send {e down} is affected -- just like how the While loop only repeats the Sleep 10 command. And while you didn't provide a description of what doesn't work, my guess is your program is responding to the artificial Send {e up}.
If there is still something wrong, please let us know what isn't working -- whether it's not doing what you expect or doing something unexpected.
Re: Help with Double tap and hold script
Well, it's probably working fine. It's just missing some part, that my lack of knowledge doesn't let me to add. Or maybe it's completely different from what I want.Exaskryz wrote:I think what you're missing is a block around the commands after the If statement.
(I would use a second KeyWait, d instead of that While loop myself, but either should work.)Code: Select all
If (!ErrorLevel) { Send {e down} While GetKeyState(d, "p") Sleep 10 Send {e up} } Return
Without the block, only the Send {e down} is affected -- just like how the While loop only repeats the Sleep 10 command. And while you didn't provide a description of what doesn't work, my guess is your program is responding to the artificial Send {e up}.
If there is still something wrong, please let us know what isn't working -- whether it's not doing what you expect or doing something unexpected.
So once again, I want fast double-tap (with holding the key afterwards) to execute repeating of the two buttons, until I release. I want to press twice the "D" button, hold it, and get "dedede..." typed, as long as i hold the button. What I get now, is: "dedddd...." the "E" button getting typed one time, and ignored afterwards. It really feels to be missing something, or has to be written other way.
Thank you for the help, really appreciate that.
Re: Help with Double tap and hold script
Ooooooh, yeah, OK. What you need is to repeat Send de.
I also noticed I made a mistake with the GetKeyState in my code above, the "d" needs quotation marks too.
(Brackets unnecessary because each conditional execution involves only the line right below it.
However, one last change you need to make is the hotkey probably needs the $ modifier. This prevents the Send d part from activating your hotkey again. So use a $d:: hotkey. And of course, have your KeyWaits like you originally had.
---
The reason the AHK hold down doesn't work is because your Keyboard Driver is responsible for deciding that a hold down really means you want the key repeated which is a process of Key Down -> Key Up -> Key Down -> Key Up. AHK doesn't invoke the keyboard driver with its Send command, thus the driver doesn't create its own artificial up and down strokes while AHK puts the key into a down state.
I also noticed I made a mistake with the GetKeyState in my code above, the "d" needs quotation marks too.
Code: Select all
If (!ErrorLevel)
While GetKeyState("d","p")
Send de ; or ed because you might start off with two d's in a row with de, from the second press and hold d counting as a sent character
return
However, one last change you need to make is the hotkey probably needs the $ modifier. This prevents the Send d part from activating your hotkey again. So use a $d:: hotkey. And of course, have your KeyWaits like you originally had.
---
The reason the AHK hold down doesn't work is because your Keyboard Driver is responsible for deciding that a hold down really means you want the key repeated which is a process of Key Down -> Key Up -> Key Down -> Key Up. AHK doesn't invoke the keyboard driver with its Send command, thus the driver doesn't create its own artificial up and down strokes while AHK puts the key into a down state.
Re: Help with Double tap and hold script
Wow, thank you very much! It does work indeed!Exaskryz wrote:Ooooooh, yeah, OK. What you need is to repeat Send de.
I also noticed I made a mistake with the GetKeyState in my code above, the "d" needs quotation marks too.
(Brackets unnecessary because each conditional execution involves only the line right below it.Code: Select all
If (!ErrorLevel) While GetKeyState("d","p") Send de ; or ed because you might start off with two d's in a row with de, from the second press and hold d counting as a sent character return
However, one last change you need to make is the hotkey probably needs the $ modifier. This prevents the Send d part from activating your hotkey again. So use a $d:: hotkey. And of course, have your KeyWaits like you originally had.
---
The reason the AHK hold down doesn't work is because your Keyboard Driver is responsible for deciding that a hold down really means you want the key repeated which is a process of Key Down -> Key Up -> Key Down -> Key Up. AHK doesn't invoke the keyboard driver with its Send command, thus the driver doesn't create its own artificial up and down strokes while AHK puts the key into a down state.
However, it send repeats too fast, is there a way to slow that down? Also, is it possible to make timeout lower than 1 second? I was trying 0,5 for example, but it didn't work, seems like everything lower than 1 sec doesn't work.
Though, I can work with that anyway, thank you once again!
Re: Help with Double tap and hold script
Use a Block for the While loop and include a Sleep command.
The Timeout in KeyWait needs to use a period (Americanized numbers). So T0.5 should work. I imagine it's a bit annoying for many people around the world, but it's done because commas already separate parameters in all the commands and functions.
The Timeout in KeyWait needs to use a period (Americanized numbers). So T0.5 should work. I imagine it's a bit annoying for many people around the world, but it's done because commas already separate parameters in all the commands and functions.
Who is online
Users browsing this forum: mikeyww and 143 guests