3-key combination suspend not working as intended

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Bpd
Posts: 17
Joined: 25 Mar 2019, 09:59

3-key combination suspend not working as intended

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!
User avatar
Tigerlily
Posts: 377
Joined: 04 Oct 2018, 22:31

Re: 3-key combination suspend not working as intended

25 Mar 2019, 12:34

Try this:

Code: Select all

#if getkeystate("LShift","P")
1 & W::Suspend, Toggle
W & 1::Suspend, Toggle
#if
I typically use something like this:

Code: Select all

<+^s::Suspend		;	Left-Shift+Ctrl+s to toggle Suspend on and off
return
-TL
Bpd
Posts: 17
Joined: 25 Mar 2019, 09:59

Re: 3-key combination suspend not working as intended

25 Mar 2019, 16:21

Thanks for your reply Tigerlily,

However in the example above I've got one combination of keys to suspend (Lshift+w+2) and one to enable (Lshift+1+w). The Lshift+1+w in this script, when held down will cycle between suspension and I'm unsure why.
User avatar
Tigerlily
Posts: 377
Joined: 04 Oct 2018, 22:31

Re: 3-key combination suspend not working as intended

25 Mar 2019, 16:59

Bpd wrote:
25 Mar 2019, 16:21
Thanks for your reply Tigerlily,

However in the example above I've got one combination of keys to suspend (Lshift+w+2) and one to enable (Lshift+1+w). The Lshift+1+w in this script, when held down will cycle between suspension and I'm unsure why.
Yes, that is very interesting. I cannot seem to figure out why (Lshift+1+w) is acting as a toggle. It is sending this within the code, even though that is not what it is being told.. I beleive this is a bug - hopefully someone else on the forum can shed some light.

As a workaround for now, just take out (Lshift+1+w)

Code: Select all

#if getkeystate("LShift","P")
W & 1::Suspend, Off
2 & W::Suspend, On
W & 2::Suspend, On
#if
-TL
Bpd
Posts: 17
Joined: 25 Mar 2019, 09:59

Re: 3-key combination suspend not working as intended

25 Mar 2019, 17:45

I can always remove it, but I would prefer an alternative method (if there is any) to still achieve the intended result.
User avatar
Tigerlily
Posts: 377
Joined: 04 Oct 2018, 22:31

Re: 3-key combination suspend not working as intended

29 Mar 2019, 21:28

Bpd wrote:
25 Mar 2019, 17:45
I can always remove it, but I would prefer an alternative method (if there is any) to still achieve the intended result.
Hi Bpd - check this out.

https://www.autohotkey.com/boards/viewtopic.php?f=14&t=63071&p=270398#p270330

This was resolved very fast. That's awesome - thanks lexikos!

https://github.com/Lexikos/AutoHotkey_L/commit/108a8d4e36197eb741f37c23849f94b7a543146c

Code: Select all

@@ -709,6 +709,10 @@ LRESULT LowLevelCommon(const HHOOK aHook, int aCode, WPARAM wParam, LPARAM lPara
	//if (!vk && !sc)
	//	return AllowKeyToGoToSystem;

	// Fix for v1.1.31.02: This is done before the used_as check to ensure it doesn't get "stuck down"
	// when a custom combination hotkey Suspends itself, thereby causing used_as to be reset to false.
	this_key.is_down = !aKeyUp;

	if (!this_key.used_as_prefix && !this_key.used_as_suffix)
		return AllowKeyToGoToSystem;

@@ -733,7 +737,6 @@ LRESULT LowLevelCommon(const HHOOK aHook, int aCode, WPARAM wParam, LPARAM lPara
			this_key.hotkey_to_fire_upon_release = HOTKEY_ID_INVALID;
		}
	}
	this_key.is_down = !aKeyUp;
	bool modifiers_were_corrected = false;

	if (aHook == g_KeybdHook)
Thanks for your contribution Bpd!
-TL
Bpd
Posts: 17
Joined: 25 Mar 2019, 09:59

Re: 3-key combination suspend not working as intended

01 Apr 2019, 08:46

Thanks for everyones help on this!
User avatar
Tigerlily
Posts: 377
Joined: 04 Oct 2018, 22:31

Re: 3-key combination suspend not working as intended

01 Apr 2019, 13:31

Bpd wrote:
01 Apr 2019, 08:46
Thanks for everyones help on this!
AHK v1.1.30.02 was released today with this bug fix - problem solved :D

AHK Download Page
-TL

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 122 guests