3-key Hotkey Combination and Suspend Toggling Topic is solved

Report problems with documented functionality
User avatar
Tigerlily
Posts: 283
Joined: 04 Oct 2018, 22:31

3-key Hotkey Combination and Suspend Toggling

25 Mar 2019, 20:57

https://www.autohotkey.com/boards/viewtopic.php?f=76&t=63056
Bpd wrote:
25 Mar 2019, 10:15
I'm having some issues with using the keys LShift + W/1 + 1/W to suspend and resume scripts. See below;

Code: Select all

#if getkeystate("LShift","P")
1 & W::Suspend, Off
W & 1::Suspend, Off
#if

#if getkeystate("LShift","P")
2 & W::Suspend, On
W & 2::Suspend, On
#if
The code mostly works, where after holding down LShift, whichever order 1/2 or W is pressed, the script will suspend or resume.

The situation in which it doesn't work is when you press LShift, then press 1, then press W. It begins to flick between suspend and resume over and over again. This doesn't happen when 2 is pressed or in the reversed orders.

Does this script behave like this for anyone else?
What changes have to be made to have LShift + 1/W + W/1 suspend, but not resume over and over again?
Is there an easier way to have multiple key combinations suspend and resume scripts, if so, how?

Any insight would be greatly appreciated thank you!
LShift + 1 & W::Suspend, Off toggles suspend on AND off. I tried around with LShift + 3 & W, LShift + 5 & W and more similar combos and replicated the same results. I feel this is a bug, maybe something I am missing
-TL
Bpd
Posts: 7
Joined: 25 Mar 2019, 09:59

Re: 3-key Hotkey Combination and Suspend Toggling

25 Mar 2019, 22:55

Thanks for posting this here TL! I'll be keeping an eye on this post.
Helgef
Posts: 3776
Joined: 17 Jul 2016, 01:02
Contact:

Re: 3-key Hotkey Combination and Suspend Toggling

27 Mar 2019, 14:49

I don't see any problem on 1.1.30.01 32/64 unicode. 1 & w only sets suspend off, never on, 2 & w only sets suspend on, never off, as to be expected.

Cheers.
gregster
Posts: 2494
Joined: 30 Sep 2013, 06:48

Re: 3-key Hotkey Combination and Suspend Toggling

27 Mar 2019, 16:25

I can reproduce the behaviour on 1.1.29.01 (64bit). Once the hotkeys were suspended at least one time, I can toggle the suspension via 1 & W::Suspend, Off while LShift is pressed.

Edit: This surprise toggle is not working, if hotkeys were suspended strictly via the script's context menu (in the systray). Then, the suspension will just be turned off, like expected.

Edit2:
The same behaviour can be observed with this simplified setup:

Code: Select all

1 & w::Suspend, Off
2 & w::Suspend, On

; the same with
2 & w::Suspend, Off		; now this key combo toggles after the first suspension (which was not done via context menu)
1 & w::Suspend, On
while this doesn't show the surprise toggle effect:

Code: Select all

1::Suspend, Off
2::Suspend, On
It seems to be caused by key combos only. If this really doesn't show on [v1.1.30+] it might have somehow to do with the implementation of this change
https://autohotkey.com/docs/commands/Suspend.htm wrote:[v1.1.30+]: The decimal values 1, 0 and -1 may be used in place of On, Off and Toggle, respectively.
User avatar
Tigerlily
Posts: 283
Joined: 04 Oct 2018, 22:31

Re: 3-key Hotkey Combination and Suspend Toggling

27 Mar 2019, 20:17

gregster wrote:
27 Mar 2019, 16:25
I can reproduce the behaviour on 1.1.29.01 (64bit). Once the hotkeys were suspended at least one time, I can toggle the suspension via 1 & W::Suspend, Off while LShift is pressed.

Edit: This surprise toggle is not working, if hotkeys were suspended strictly via the script's context menu (in the systray). Then, the suspension will just be turned off, like expected.

Edit2:
The same behaviour can be observed with this simplified setup:

Code: Select all

1 & w::Suspend, Off
2 & w::Suspend, On

; the same with
2 & w::Suspend, Off		; now this key combo toggles after the first suspension (which was not done via context menu)
1 & w::Suspend, On
while this doesn't show the surprise toggle effect:

Code: Select all

1::Suspend, Off
2::Suspend, On
It seems to be caused by key combos only. If this really doesn't show on [v1.1.30+] it might have somehow to do with the implementation of this change
https://autohotkey.com/docs/commands/Suspend.htm wrote:[v1.1.30+]: The decimal values 1, 0 and -1 may be used in place of On, Off and Toggle, respectively.
I'm running AHK v1.1.30.01 32/Unicode.
Helgef wrote:
27 Mar 2019, 14:49
I don't see any problem on 1.1.30.01 32/64 unicode. 1 & w only sets suspend off, never on, 2 & w only sets suspend on, never off, as to be expected.

Cheers.


And yes, I forgot to mention that intially the script works, but then after activating Suspend ON with SHIFT+2+w or SHIFT+W+2 (W & 2 or 2 & W) : SHIFT+1+W (1 & W) toggles, while SHIFT+w+1 (W & 1) only turns Suspend OFF
-TL
Bpd
Posts: 7
Joined: 25 Mar 2019, 09:59

Re: 3-key Hotkey Combination and Suspend Toggling

27 Mar 2019, 22:16

Thanks for finding!
https://autohotkey.com/docs/commands/Suspend.htm wrote:
[v1.1.30+]: The decimal values 1, 0 and -1 may be used in place of On, Off and Toggle, respectively.
By swapping out 'On' for 1 and 'Off' for 0, it seems to work (on the work PC anyways, will check personal when I'm home).

Code: Select all

#if getkeystate("LShift","P")
1 & W::Suspend, 0
W & 1::Suspend, 0
#if

#if getkeystate("LShift","P")
2 & W::Suspend, 1
W & 2::Suspend, 1
#if
Does this solution work for everyone else also?

Thanks.
User avatar
Tigerlily
Posts: 283
Joined: 04 Oct 2018, 22:31

Re: 3-key Hotkey Combination and Suspend Toggling

28 Mar 2019, 00:21

Bpd wrote:
27 Mar 2019, 22:16
Thanks for finding!
https://autohotkey.com/docs/commands/Suspend.htm wrote:
[v1.1.30+]: The decimal values 1, 0 and -1 may be used in place of On, Off and Toggle, respectively.
By swapping out 'On' for 1 and 'Off' for 0, it seems to work (on the work PC anyways, will check personal when I'm home).

Code: Select all

#if getkeystate("LShift","P")
1 & W::Suspend, 0
W & 1::Suspend, 0
#if

#if getkeystate("LShift","P")
2 & W::Suspend, 1
W & 2::Suspend, 1
#if
Does this solution work for everyone else also?

Thanks.
Yes, that resolves the issue - nice!

Still curious, why the other param syntax is bugging though..
-TL
Helgef
Posts: 3776
Joined: 17 Jul 2016, 01:02
Contact:

Re: 3-key Hotkey Combination and Suspend Toggling

28 Mar 2019, 01:44

Thank you gregster for narrowing it down. I see the behaviour with,

Code: Select all

1 & w::Suspend, Off
2 & w::Suspend, On
on 1.1.30.01.

If you check listlines, you will see that 1 & w actually triggers the 2 & w hotkey when the unexpected behaviour occurs. So clearly there is a bug here.

Cheers.
lexikos
Posts: 6397
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: 3-key Hotkey Combination and Suspend Toggling

29 Mar 2019, 17:00

This affects all AutoHotkey versions - I tested as far back as v1.0.48.05. It will be fixed. The problem is that we stop tracking the "2" key when it is no longer a prefix key in an active custom combination; i.e. we stop tracking it while it is in the pressed state, and do not reset the state. The workaround is to ensure that the key is always a prefix or suffix key:

Code: Select all

1 & w::Suspend, Off
2 & w::Suspend, On
2 & 2::Suspend, Permit
The hotkey 2 & 2 probably can't ever trigger, but marks the key as both prefix and suffix. 2 & vk07 or ~2 would also work.

Bpd's workaround only appears to work because all of the hotkeys are exempt from Suspend. Any use of Suspend as the first line except Suspend, On (where "On" is literal, not a variable) causes a hotkey to be exempt. This only applies to v1, not v2. So Suspend, 1 is effectively the same as Suspend, Permit followed by Suspend, On.
User avatar
Tigerlily
Posts: 283
Joined: 04 Oct 2018, 22:31

Re: 3-key Hotkey Combination and Suspend Toggling

30 Mar 2019, 04:34

Thanks for being so quick and awesome lexikos - thanks all for debugging this!

Cheers.
-TL
lexikos
Posts: 6397
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: 3-key Hotkey Combination and Suspend Toggling  Topic is solved

21 Apr 2019, 17:48

This was fixed in v1.1.30.02.

Return to “Bug Reports”

Who is online

Users browsing this forum: Bing [Bot] and 4 guests