keywait for multiple keys bug Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
weaking1
Posts: 4
Joined: 06 Jul 2022, 13:28

keywait for multiple keys bug

Post by weaking1 » 06 Jul 2022, 15:35

Hi everyone, i hope you can help me

I'll start from the very beginning. My main tool for creating hotkeys is luamacro, but it unfortunately does not support mouse clicks.

I needed a third action to be triggered by pressing and holding two buttons on a hid-compatible keyboard. The buttons themselves had to remain functional.

An example is
pressing button [ I got "["
pressing button ] I got "]"

when i press (and hold) buttons [ and ] simultaneously luamacro presses (and holds) button f7

for f7 in autohotkey, I created the necessary shortcut using the right mouse button (alt + shift + right button). And it is important for me that it was not just a click, but a press and hold. But unfortunately the combination I need, stops working when I add the shift key to it. If the combination uses only alt + right mouse button, then everything works, but when I add a shift to the combination, the pressed keys simply do not release.

I'm new to autohotkey and unfortunately I don't know how to write a script with modifier keys correctly, so my scripts look something like this
(this one does work properly and calls brush controls in photoshop properly)

Code: Select all

F7::
KeyWait F7, D

Sendevent, {alt down}{Rbutton Down}


KeyWait F7, U

Sendevent, {alt up}{Rbutton Up}
return
But when i add shift to this combo, action on press is correct (it opens the palette in photoshop), but the buttons keep being pressed after the release of the combination.

Code: Select all

F7::
KeyWait F7, D

Sendevent, {shift down}{alt down}{Rbutton Down}


KeyWait F7, U

Sendevent, {shift up}{alt up}{Rbutton Up}
return
I think by this code, despite its incorrectness, you can see what result I want to achieve

it doesn't matter to me whether luamacro will be used in the process of implementing this solution.

If you can refuse it, I will gladly do it.

but since it is quite difficult for me to understand even the basic functionality of autohotkey, it seems that it will be difficult to write a script that will do exactly what I need in autohotkey.

but if it is possible to make buttons "[" and "]" work, and by pressing and holding them - they press and hold the alt-shift-right mouse button combination, and release it correctly, then I will be happy with such a solution
Attachments
works.gif
works.gif (372.47 KiB) Viewed 869 times

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

Re: keywait for multiple keys bug

Post by mikeyww » 06 Jul 2022, 20:48

Welcome to this AutoHotkey forum!

I wonder how you came across the "U" option for :arrow: KeyWait. I did not see it in the documentation.
The buttons keep being pressed after the release of the combination.
Which buttons? Which combination is released?

Test in Notepad first. Examine the :arrow: KeyHistory.

Code: Select all

F7::!+RButton

weaking1
Posts: 4
Joined: 06 Jul 2022, 13:28

Re: keywait for multiple keys bug

Post by weaking1 » 07 Jul 2022, 03:24

hi, sorry for the inaccuracies, and thank you for your reply!

When i use the

Code: Select all

Sendevent, {shift down}{alt down}{Rbutton Down}
buttons that are pressed in this combination, are not released, when i release the f7 button (shift, alt, rbutton are keep being pressed, even taking into account the fact that I have a line that is responsible for the buttons to be released )

when i use only two button combination

Code: Select all

Sendevent, {alt down}{Rbutton Down}
everything works, alt button and right button are released after my virtual f7 button is released, too.

the problem

The script you are provided sends short presses of aforementioned combination, and window with colorpicker does not appear at all. The combination should be pressed and held

Rohwedder
Posts: 7569
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: keywait for multiple keys bug

Post by Rohwedder » 07 Jul 2022, 03:53

Hallo,
if buttons "[" and "]" work means that they should keep there native functions, try:

Code: Select all

~[ & ~]::Send, {Blind}{alt down}{Rbutton Down}
~*[ Up::
~*] Up::Send, {Blind}{alt up}{Rbutton Up}

weaking1
Posts: 4
Joined: 06 Jul 2022, 13:28

Re: keywait for multiple keys bug

Post by weaking1 » 07 Jul 2022, 05:46

Hi it almost works (for simplicity i'm already testing it only on main keyboard)

but results are strange, looks like the keycombination doesnt stay pressed as i keep "[" and "]" pressed, you can see it on a gif - window appears, holds for a second and after that it starts blinking.

(sorry that the code on gif differs from what you provided, i've tested it too - same result)
Attachments
Photoshop_IezZZVijzt.gif
Photoshop_IezZZVijzt.gif (1.5 MiB) Viewed 581 times

Rohwedder
Posts: 7569
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: keywait for multiple keys bug  Topic is solved

Post by Rohwedder » 07 Jul 2022, 06:55

Run this as a second script to see the states of the Keys := "[ ] alt shift RButton"

Code: Select all

#Persistent
;KeyStateTimer shows the logical State of Keys
SetTimer,State,200, Keys := "[ ] alt shift RButton"
State: ;Keys separated with space or tab
For all,Key in StrSplit(Keys,[A_Space,A_Tab])
	Text.=Trim(Key)>""?"`n" Key "`t" (GetKeyState(Key)?"down":"up"):
MouseGetPos, MX, MY ;separated from another ToolTip
ToolTip,% SubStr(Text,2),MX+16,MY+32,4,Text:=""
Return

weaking1
Posts: 4
Joined: 06 Jul 2022, 13:28

Re: keywait for multiple keys bug

Post by weaking1 » 07 Jul 2022, 11:25

something really strange is going on - all shortcuts that are uses numpad physical buttons and {shift}, seems to be "stuck". If i avoid use of numpad buttons - everything works... i think i'l close this topic for future investigation.

Thanks everyone for the replies!

i didn't understand the solution, but it seems that theres some sort of compkicated stuff going on with numpad numbers and shift keys according to this post

https://www.autohotkey.com/board/topic/16459-how-can-i-use-shiftnumpad/

Post Reply

Return to “Ask for Help (v1)”