Newbie question

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
thorejordan94
Posts: 4
Joined: 24 Jul 2023, 12:19

Newbie question

Post by thorejordan94 » 04 Dec 2023, 16:31

Hi
I want a script, that:
When I press down LShift and R at the same time, send G ("G1/2") one time. When I release R nothing special should happen and I want to keep press R while Shift down. When I release LShift, send G (G2/2) again.

So far my code does this if I press very carefully, but as soon as keys overlap, it gets stuck in the G1/2 state.
Is it possible to make "LShift up" always send G- no matter what?
Ty

Code: Select all

~LShift::

keyWait, r, "d"

send, g


KeyWait, LShift, "U"

sleep, 250
send, g
sleep, 250
[Mod edit: [code][/code] tags added. Please use them yourself when posting code!]
[Mod edit: Moved topic from AHk v2 help to v1 help, since this is not v2 code.]

User avatar
mikeyww
Posts: 27198
Joined: 09 Sep 2014, 18:38

Re: Newbie question

Post by mikeyww » 04 Dec 2023, 17:32

Welcome to this AutoHotkey forum!

Where did you find the "U" option for KeyWait?

Is the script from ChatGPT?

thorejordan94
Posts: 4
Joined: 24 Jul 2023, 12:19

Re: Newbie question

Post by thorejordan94 » 04 Dec 2023, 17:58

no i gave up on chat gpt very quickly it always gave out crap (even more than I can come up with haha.)

i read in official AHK wiki, that U is the state of a Key beeing UP.... thats why i thought i can write it like that... "wait until shift is up"

thorejordan94
Posts: 4
Joined: 24 Jul 2023, 12:19

Re: Newbie question

Post by thorejordan94 » 04 Dec 2023, 18:03

thorejordan94 wrote:
04 Dec 2023, 17:58
no i gave up on chat gpt very quickly it always gave out crap (even more than I can come up with haha.)

i read in official AHK wiki, that U is the state of a Key beeing UP.... thats why i thought i can write it like that... "wait until shift is up"
i also tried a similar script with while/if getKeyState("LShift", "U")

User avatar
mikeyww
Posts: 27198
Joined: 09 Sep 2014, 18:38

Re: Newbie question

Post by mikeyww » 04 Dec 2023, 18:13

There is only one official set of documentation for AHK. It is a useful resource that I recommend consulting.

https://www.autohotkey.com/docs/v1/

(Or the v2 docs at the same Web site)

thorejordan94
Posts: 4
Joined: 24 Jul 2023, 12:19

Re: Newbie question

Post by thorejordan94 » 04 Dec 2023, 18:41

this is what I have been using. Is my question/problem unclear? I have been trying to make it work the last 6 hours.... pls no cynism anymore.

User avatar
boiler
Posts: 17219
Joined: 21 Dec 2014, 02:44

Re: Newbie question

Post by boiler » 04 Dec 2023, 19:56

How is it cynicism and not anything but helpful to point you to the source of correct information and away from whatever site was giving you faulty direction?

It’s also incorrect to put quotation marks around the D in the Keywait Options parameter in AHK v1.

User avatar
mikeyww
Posts: 27198
Joined: 09 Sep 2014, 18:38

Re: Newbie question

Post by mikeyww » 04 Dec 2023, 20:08

That's right, I was not being cynical, and I really do strongly recommend that you consult the documentation. It will speed both your coding and your understanding. Instead of consulting incorrect third-party information, you can quickly get to the source.

A potential script for your need is below.

Code: Select all

#Requires AutoHotkey v1.1.33

<+r::          ; When I press LShift and r at the same time,
Send g         ;  send "g"
KeyWait LShift ; When I release LShift,
Send g         ;  send "g"
Return
More: Return

Post Reply

Return to “Ask for Help (v1)”