Beginner Question About Keywait(?) Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
flumee
Posts: 13
Joined: 17 Nov 2021, 17:35

Beginner Question About Keywait(?)

Post by flumee » 05 Dec 2021, 07:20

I've been really satisfied with the basic hotkeys I made, but I'm trying to do more complicated stuff. They should still be really basic stuff for you guys. I'm not sure if it is possible to do this.

when I press ` key (This is just an example, it can be other keys),
Press {C}
{Shift Down}
Wait for my left click, and when I left click,
{Shift Up}
Press {P}

I am having a hard time figuring out the wait for my left click part.
I would appreciate your help. Thanks!

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

Re: Beginner Question About Keywait(?)

Post by boiler » 05 Dec 2021, 08:57

You have to use the D option for it to wait for it to pressed down, otherwise it only waits for its release, which is its normal (non-pressed) state:

Code: Select all

KeyWait, LButton, D
Last edited by boiler on 05 Dec 2021, 08:57, edited 1 time in total.

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

Re: Beginner Question About Keywait(?)

Post by mikeyww » 05 Dec 2021, 08:57

Code: Select all

`::
on := True
Send c{Shift down}
KeyWait, ``
SoundBeep, 1000
Return

#If on
+LButton Up::
SoundBeep, 1500
Send {Shift up}p
on := False
~::
Return
#If

flumee
Posts: 13
Joined: 17 Nov 2021, 17:35

Re: Beginner Question About Keywait(?)

Post by flumee » 05 Dec 2021, 10:57

mikeyww wrote:
05 Dec 2021, 08:57

Code: Select all

`::
on := True
Send c{Shift down}
KeyWait, ``
SoundBeep, 1000
Return

#If on
+LButton Up::
SoundBeep, 1500
Send {Shift up}p
on := False
~::
Return
#If
Thank you so much for the help!

flumee
Posts: 13
Joined: 17 Nov 2021, 17:35

Re: Beginner Question About Keywait(?)

Post by flumee » 05 Dec 2021, 11:06

boiler wrote:
05 Dec 2021, 08:57
You have to use the D option for it to wait for it to pressed down, otherwise it only waits for its release, which is its normal (non-pressed) state:

Code: Select all

KeyWait, LButton, D
Thank you so much for the help!
That "D" made it works perfectly, but I have to ask two more questions.

Code: Select all

`::
Send c{Shift down}
KeyWait, Lbutton, D
Send, p{Shift Up}
Return
This is what I wrote. It does everything as expected, but it doesn't input "p" after Lbutton is pressed. It does {shift up} as expected.
And, how would I put Lbutton, D "or" Rbutton, D? I forgot to mention that I could press left-click or right-click in the first question.
Thanks again!

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

Re: Beginner Question About Keywait(?)  Topic is solved

Post by boiler » 05 Dec 2021, 12:09

flumee wrote: This is what I wrote. It does everything as expected, but it doesn't input "p" after Lbutton is pressed. It does {shift up} as expected.
Maybe it’s a timing issue of being too close after the click or something. See if adding something like Sleep, 100 in between helps.

flumee wrote: And, how would I put Lbutton, D "or" Rbutton, D? I forgot to mention that I could press left-click or right-click in the first question.
Thanks again!
That requires a very different solution. Perhaps this post will help.

flumee
Posts: 13
Joined: 17 Nov 2021, 17:35

Re: Beginner Question About Keywait(?)

Post by flumee » 05 Dec 2021, 12:21

boiler wrote:
05 Dec 2021, 12:09
flumee wrote: This is what I wrote. It does everything as expected, but it doesn't input "p" after Lbutton is pressed. It does {shift up} as expected.
Maybe it’s a timing issue of being too close after the click or something. See if adding something like Sleep, 100 in between helps.

flumee wrote: And, how would I put Lbutton, D "or" Rbutton, D? I forgot to mention that I could press left-click or right-click in the first question.
Thanks again!
That requires a very different solution. Perhaps this post will help.
Yes, it was a timing issue. I didn't release the left click quick enough, so the "sleep" made everything work well.
Thank you!

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

Re: Beginner Question About Keywait(?)

Post by boiler » 05 Dec 2021, 13:15

Actually, this is even better than a Sleep because it waits for the button to pressed and released before sending the p:

Code: Select all

`::
Send c{Shift down}
KeyWait, Lbutton, D
KeyWait, Lbutton
Send, p{Shift Up}
Return

flumee
Posts: 13
Joined: 17 Nov 2021, 17:35

Re: Beginner Question About Keywait(?)

Post by flumee » 06 Dec 2021, 12:20

boiler wrote:
05 Dec 2021, 13:15
Actually, this is even better than a Sleep because it waits for the button to pressed and released before sending the p:

Code: Select all

`::
Send c{Shift down}
KeyWait, Lbutton, D
KeyWait, Lbutton
Send, p{Shift Up}
Return
Wow, that's amazing! That works very clean. Thanks!

Post Reply

Return to “Ask for Help (v1)”