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 missingBpd wrote: ↑25 Mar 2019, 10:15I'm having some issues with using the keys LShift + W/1 + 1/W to suspend and resume scripts. See below;
The code mostly works, where after holding down LShift, whichever order 1/2 or W is pressed, the script will suspend or resume.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 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!
3-key Hotkey Combination and Suspend Toggling Topic is solved
3-key Hotkey Combination and Suspend Toggling
https://www.autohotkey.com/boards/viewtopic.php?f=76&t=63056
-TL
Re: 3-key Hotkey Combination and Suspend Toggling
Thanks for posting this here TL! I'll be keeping an eye on this post.
Re: 3-key Hotkey Combination and Suspend Toggling
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.
Cheers.
Re: 3-key Hotkey Combination and Suspend Toggling
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:
while this doesn't show the surprise toggle effect:
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
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
Code: Select all
1::Suspend, Off
2::Suspend, On
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.
Re: 3-key Hotkey Combination and Suspend Toggling
I'm running AHK v1.1.30.01 32/Unicode.gregster wrote: ↑27 Mar 2019, 16:25I 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:while this doesn't show the surprise toggle effect: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
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 changeCode: Select all
1::Suspend, Off 2::Suspend, On
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.
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
Re: 3-key Hotkey Combination and Suspend Toggling
Thanks for finding!
Does this solution work for everyone else also?
Thanks.
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).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.
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
Thanks.
Re: 3-key Hotkey Combination and Suspend Toggling
Yes, that resolves the issue - nice!Bpd wrote: ↑27 Mar 2019, 22:16Thanks for finding!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).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.
Does this solution work for everyone else also?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
Thanks.
Still curious, why the other param syntax is bugging though..
-TL
Re: 3-key Hotkey Combination and Suspend Toggling
Thank you gregster for narrowing it down. I see the behaviour with,
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.
Code: Select all
1 & w::Suspend, Off
2 & w::Suspend, On
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.
Re: 3-key Hotkey Combination and Suspend Toggling
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:
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.
Code: Select all
1 & w::Suspend, Off
2 & w::Suspend, On
2 & 2::Suspend, Permit
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.
Re: 3-key Hotkey Combination and Suspend Toggling
Thanks for being so quick and awesome lexikos - thanks all for debugging this!
Cheers.
Cheers.
-TL
Re: 3-key Hotkey Combination and Suspend Toggling Topic is solved
This was fixed in v1.1.30.02.
Who is online
Users browsing this forum: No registered users and 57 guests