Keywait for multiple keys? (Beginner Question) 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

Keywait for multiple keys? (Beginner Question)

06 Dec 2021, 13:00

Hello,

I have this for audio editing software hotkey, and it works well. I'm trying to get it more convenient to use. How could I have it to wait for Lbutton "or" Rbutton? Is there a way to do it with Keywait?

Code: Select all

`::
Send c{Shift down}
KeyWait, Lbutton, D
KeyWait, Lbutton
Send, {shift up}
sleep, 30
send, {p}
Return
[Mod edit: [code][/code] tags added.]

I would appreciate your help. Thanks!
User avatar
boiler
Posts: 16913
Joined: 21 Dec 2014, 02:44

Re: Keywait for multiple keys? (Beginner Question)  Topic is solved

06 Dec 2021, 13:19

You could try looping until it detects either is pressed with GetKeyState() then use KeyWait until both are released before sending p:

Code: Select all

`::
Send, c{Shift down}
loop 
	Sleep, 10
until GetKeyState("LButton") || GetKeyState("RButton")
KeyWait, LButton
KeyWait, RButton
Send, {Shift up}
Sleep, 30
Send, p
Return
(note that { } are not required around p)
flumee
Posts: 13
Joined: 17 Nov 2021, 17:35

Re: Keywait for multiple keys? (Beginner Question)

06 Dec 2021, 13:53

boiler wrote:
06 Dec 2021, 13:19
You could try looping until it detects either is pressed with GetKeyState() then use KeyWait until both are released before sending p:

Code: Select all

`::
Send, c{Shift down}
loop 
	Sleep, 10
until GetKeyState("LButton") || GetKeyState("RButton")
KeyWait, LButton
KeyWait, RButton
Send, {Shift up}
Sleep, 30
Send, p
Return
(note that { } are not required around p)
It works perfectly. It is so amazing that it makes me wanna learn to script. And, I think I will!
Thanks for your help again!!
User avatar
boiler
Posts: 16913
Joined: 21 Dec 2014, 02:44

Re: Keywait for multiple keys? (Beginner Question)

06 Dec 2021, 14:33

flumee wrote: It is so amazing that it makes me wanna learn to script. And, I think I will!
Glad to hear that! That is always my hope when helping someone that is new to coding.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, doodles333, Google [Bot] and 345 guests