Noobie asking for help Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
F_B
Posts: 9
Joined: 15 Jun 2021, 14:29

Noobie asking for help

15 Jun 2021, 14:39

So I've recently stumped upon this software and its community, I've got to say, both are really useful; back to my question, I'm wanting to create a simple script but I'm having a difficult time getting it to work.
Essentially all I want is for the "X" key on my keyboard to activate once when held down, and again when I release the key; I don't want it repeatedly spamming "X", just once when held down, and once again when I let go.
This is what I've come up with, it works but only for a very short time.

Code: Select all

x::
send {x down}
KeyWait x
return
Thank you again in advance!
User avatar
boiler
Posts: 17093
Joined: 21 Dec 2014, 02:44

Re: Noobie asking for help  Topic is solved

15 Jun 2021, 15:22

If I understand you correctly:

Code: Select all

$x::
Send, x
KeyWait, x
Send, x
return
F_B
Posts: 9
Joined: 15 Jun 2021, 14:29

Re: Noobie asking for help

15 Jun 2021, 15:30

Not quite what I'm looking for, but it's progress, maybe I should try and reword my request better; I am wanting help to create a script that will activate once as soon as I hold down the key, and active again as soon as I let go; your script works, but it closes too fast if that makes any sense; as in I'm still holding the key down but it actives regardless, and does so again the moment I release the key.
User avatar
boiler
Posts: 17093
Joined: 21 Dec 2014, 02:44

Re: Noobie asking for help

15 Jun 2021, 15:39

Then do you mean this?:

Code: Select all

$x::
Send, {x down}
KeyWait, x
Send, {x up}
return
But then it just sends x down when you press it and releases it when you release it, so I’m not sure what it’s accomplishing. Maybe you can try to explain in more detail exactly what you expect when you press it down and exactly what you expect when you release it.
F_B
Posts: 9
Joined: 15 Jun 2021, 14:29

Re: Noobie asking for help

15 Jun 2021, 15:59

boiler wrote: Then do you mean this?:

Code: Select all

$x::
Send, {x down}
KeyWait, x
Send, {x up}
return
But then it just sends x down when you press it and releases it when you release it, so I’m not sure what it’s accomplishing. Maybe you can try to explain in more detail exactly what you expect when you press it down and exactly what you expect when you release it.
This new one doesn't seem to have much effect. Hmm... maybe I could try and use video games as an example, in some video games, you have a map, by pressing a hotkey you open said map, the map is togglable, meaning you have to press the hotkey again to close it.

What I'm looking for is something that disables that "toggle", so that I don't have to press the hotkey again, I can just release the hotkey and the map would close as soon as I do.

I hope this example will give you a better understanding of what I'm requesting, if not, just say so.

Sorry for the delayed response, my last message didn't send apparently.
User avatar
boiler
Posts: 17093
Joined: 21 Dec 2014, 02:44

Re: Noobie asking for help

15 Jun 2021, 17:16

Then it seems like the first version of the script should do that. If you test it with Notepad as the active window, you should see that when you press and hold down x, it will send an x, then when you release that key, it will send another x. It works like that for me. It would be interesting to see if it works like that for you in Notepad. Then the question would be why it doesn’t work in the game that way.
F_B
Posts: 9
Joined: 15 Jun 2021, 14:29

Re: Noobie asking for help

15 Jun 2021, 17:49

boiler wrote:
15 Jun 2021, 17:16
Then it seems like the first version of the script should do that. If you test it with Notepad as the active window, you should see that when you press and hold down x, it will send an x, then when you release that key, it will send another x. It works like that for me. It would be interesting to see if it works like that for you in Notepad. Then the question would be why it doesn’t work in the game that way.
Hmm, that's odd, NOW it's wanting to work; sorry for the hassle! Thank you for helping me!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], haomingchen1998 and 137 guests