how do i make code for a down key press to immediately go up before i release my finger. Topic is solved

Ask gaming related questions
User avatar
mikeyww
Posts: 27216
Joined: 09 Sep 2014, 18:38

Re: how do i make code for a down key press to immediately go up before i release my finger.  Topic is solved

28 Jan 2024, 08:11

A variation is below.

Code: Select all

#Requires AutoHotkey v2.0
$a::Send('a'), KeyWait('a')
User avatar
kunkel321
Posts: 1149
Joined: 30 Nov 2015, 21:19

Re: how do i make code for a down key press to immediately go up before i release my finger.

28 Jan 2024, 12:01

mikeyww wrote:
28 Jan 2024, 08:11
A variation is below.

Code: Select all

#Requires AutoHotkey v2.0
$a::Send('a'), KeyWait('a')
Just curous.... Mike, can you (or someone) explain how/why your version works? I tried it, and it does work (holding down the a key only types a single a, suggesting that it is working.)

I see that KeyWait
Waits for a key or mouse/controller button to be released or pressed down.
But how does that cause it to immediately release the a key?
ste(phen|ve) kunkel
User avatar
mikeyww
Posts: 27216
Joined: 09 Sep 2014, 18:38

Re: how do i make code for a down key press to immediately go up before i release my finger.

28 Jan 2024, 12:09

When you use AHK to call the Send function with a key (or key sequence) as your parameter, by default, two things happen. First, the key is sent down. Second, the key is sent up. You can try that and examine the KeyHistory.
ruinoftheshadows
Posts: 3
Joined: 28 Jan 2024, 02:28

Re: how do i make code for a down key press to immediately go up before i release my finger.

28 Jan 2024, 19:07

@mikeyww
This worked well however what I'm trying to do with this is a little more complicated. I'm not quite sure how auto hotkey configures these settings but for the game I'm playing when i use this it does not work. It works when i hold the shift key down however then the button doesn't go up immediately. Is there any workaround for this?
User avatar
mikeyww
Posts: 27216
Joined: 09 Sep 2014, 18:38

Re: how do i make code for a down key press to immediately go up before i release my finger.

28 Jan 2024, 21:31

I read your description a few times, but I have no idea what it means or what you are trying to accomplish. Does the KeyHistory show what you expect, or something unexpected? Does it work in Notepad but just not in your game? What do you press? What happens? What should happen instead?
ruinoftheshadows
Posts: 3
Joined: 28 Jan 2024, 02:28

Re: how do i make code for a down key press to immediately go up before i release my finger.

29 Jan 2024, 00:38

@mikeyww

i seem to have figured out the issue (At least probably). The issue is the application i am running is causing auto hotkey to make weird errors and malfunction. I am playing a steam version of Tetris and my goal is to quickly press up to 3 keys almost (but not quite) simultaneously and each of these buttons will move the termino either left or right. The goal is to increase the speed and make an upgrade to the normal left and right movement in the game. it actually works perfectly but only on a web browser version of tetris, not my steam game. is this a common problem with steam games? Any more insight you could give?


[Mod action: Moved topic to the “Gaming” section.]
niCode
Posts: 315
Joined: 17 Oct 2022, 22:09

Re: how do i make code for a down key press to immediately go up before i release my finger.

29 Jan 2024, 03:15

It's a common "problem" with games in general. Although you still haven't said how exactly it is or isn't working, I suspect the issue is with Send. Send is often too fast for games. They don't check for input fast enough. I would try using SendEvent. If that doesn't work, please give us more information about what your script is or isn't doing.

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 6 guests