Shift Key Gets Stuck (Suppressing Other Keystrokes). Help!

Get help with using AutoHotkey and its commands and hotkeys
poetofpiano
Posts: 43
Joined: 25 Jan 2016, 14:26

Shift Key Gets Stuck (Suppressing Other Keystrokes). Help!

29 Jun 2016, 13:22

I have a longstanding problem that happens several times a day with my Autohotkey script. Every so often I believe the shift key gets stuck in a down position even though I am not pressing it. I know this because I use the following hotkey,

Code: Select all

#IfWinActive ahk_class Chrome_WidgetWin_1
~lshift & lbutton::
sendevent {shift up} ; I added this line specifically to try to address my issue above, but it didn't work, nor did sendevent {blind}{shift up}
send ^{home}
return
which jumps to the very top of a webpage, and when the shift key gets stuck in the down position, sometimes I will try to simply left click on a link in a webpage, and suddenly the ~lshift & lbutton hotkey gets executed and ^{home} is sent. My script only starts working normally again when I physically press and release the shift key.

I checked my script’s Keyhistory right after the last time this happened and noticed that the instance of pressing lbutton to click a link was “suppressed” or “blocked,” but I cannot figure out what is causing this to occur:

Code: Select all

20  039	 	u	0.13	Space          	
01  000	 	d	1.97	LButton        	
01  000	 	u	0.06	LButton        	
01  000	 	d	2.78	LButton        	
01  000	 	u	0.09	LButton        	
A4  038	 	d	0.50	LAlt           	
01  000	h	d	0.39	LButton        	
A2  01D	i	d	0.00	LControl       	
A2  01D	i	u	0.00	LControl       	
A4  038	i	u	0.00	LAlt           	
A6  06A	i	d	0.00	Browser_Back   	
A6  06A	i	u	0.01	Browser_Back   	
A2  01D	i	d	0.00	LControl       	
A4  038	i	d	0.00	LAlt           	
A2  01D	i	u	0.00	LControl       	
01  000	s	u	0.06	LButton        	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.05	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.05	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.05	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
41  01E	#	d	0.01	A              	
A2  01D	i	d	0.00	LControl       	
A4  038	i	u	0.00	LAlt           	
09  00F	i	d	0.00	Tab            	
09  00F	i	u	0.00	Tab            	
A4  038	i	d	0.00	LAlt           	
A2  01D	i	u	0.00	LControl       	
41  01E	 	u	0.09	A              	
A4  038	 	u	0.45	LAlt           	
9E  001	#	d	0.38	WheelDown      	
9E  001	#	d	0.05	WheelDown      	
9E  001	#	d	0.05	WheelDown      	
9E  001	#	d	0.06	WheelDown      	
9E  001	#	d	0.11	WheelDown      	
01  000	 	d	6.47	LButton        	
04  000	h	d	0.81	MButton        	
A0  02A	i	u	0.00	LShift         	
A2  01D	i	d	0.02	LControl       	
23  14F	i	d	0.00	End            	
23  14F	i	u	0.00	End            	
A2  01D	i	u	0.00	LControl       	
04  000	s	u	0.17	MButton        	
04  000	h	d	3.80	MButton        	
A0  02A	i	u	0.00	LShift         	
A2  01D	i	d	0.02	LControl       	
23  14F	i	d	0.00	End            	
23  14F	i	u	0.00	End            	
A2  01D	i	u	0.00	LControl       	
04  000	s	u	0.11	MButton        	
01  000	 	u	0.47	LButton        	
01  000	h	d	0.38	LButton        	
A0  02A	i	u	0.00	LShift         	
A2  01D	i	d	0.02	LControl       	
24  147	i	d	0.00	Home           	
24  147	i	u	0.01	Home           	
A2  01D	i	u	0.00	LControl       	
01  000	s	u	0.02	LButton        		
5B  15B	s	d	0.03	LWin           	
30  00B	 	d	0.00	0              	
30  00B	 	u	0.09	0              	
5B  15B	h	u	0.84	LWin           	
A2  01D	i	d	0.00	LControl       	
A2  01D	i	u	0.00	LControl       	
A0  02A	 	d	1.45	LShift         	
A0  02A	 	u	0.08	LShift         	
5B  15B	 	d	0.78	LWin           	
30  00B	h	d	0.42	0
You can see there are several “suppressed” attempted keystrokes (indicated by an “s”) throughout my keyhistory. I only realized that something was wrong towards the end, when I pressed LButton and it triggered the aforementioned lshift & lbutton command (without me even physically pressing shift), sending ^{home}. You can then see that I tried to press #0 (my hotkey to view the script’s keyhistory) and LWin was also suppressed. It was only when I physically pressed and released the shift key that I was able to execute #0 and everything went back to normal.

The suppressing of keystrokes seems especially common after executing my {browser_back} hotkey (set to ~lbutton and rbutton::), but I’m not sure if that’s in any way related.

I have looked at a lot of similar questions in the Autohotkey forums. The most helpful were https://autohotkey.com/board/topic/9409 ... ways-down/ and https://autohotkey.com/board/topic/9858 ... k-propper/ but I am unsure how to implement them to resolve my issues. I also understand that maybe a thread could be still running somewhere else in my script, causing other modifier keys to be suppressed until the thread completes, but I have no idea what that thread might be… I will say that I have more than two scripts running right now that have hotkeys that require the Keyboard Hook, but I don’t know if that has anything to do with my problem.

This is all the keyhistory I recorded, but let me know if I need to increase its length to go back farther the next time it happens.

Any help would be greatly appreciated!
User avatar
evilC
Posts: 4792
Joined: 27 Feb 2014, 12:30

Re: Shift Key Gets Stuck (Suppressing Other Keystrokes). Help!

29 Jun 2016, 13:42

Try send {Blind}^{home}

When you trigger the hotkey with Shift + LButton, you instruct AHK to send Ctrl+Home.

Since LShift is held (By you, in order to trigger the hotkey), AHK releases shift, then holds ctrl, then hits home, then releases ctrl, *then holds shift again*

{Blind} tells Send to ignore the physical state of the modifier keys, so it will stop messing with the shift key.
poetofpiano
Posts: 43
Joined: 25 Jan 2016, 14:26

Re: Shift Key Gets Stuck (Suppressing Other Keystrokes). Help!

30 Jun 2016, 11:31

Thank you for your suggestion. I have implemented that and will report back if I continue to have problems.

Reviewing the keyhistory I posted in my question, I now can see that the real problem actually seemed to start when I pressed lbutton down and then pressed mbutton, trying to execute the following command in my script:

Code: Select all

#IfWinActive ahk_class Chrome_WidgetWin_1
~lbutton & mbutton::
send {lbutton up}
sendevent {shift up}
Send, {Browser_Back}
return
Then you can see what happened next: instead of triggering the ~lbutton & mbutton hotkey, it for some reason triggered the following ~lshift & mbutton hotkey also running in my script:

Code: Select all

#IfWinActive ahk_class Chrome_WidgetWin_1
~lshift & mbutton::
Send {lshift up}
Send ^{end}
return
I’m not sure why ~lbutton & mbutton triggered ~lshift & mbutton. Even though I do send {shift up} in the ~lbutton & mbutton hotkey, that hotkey uses a normal sendlevel/#inputlevel, so I am surprised to see that it can trigger another hotkey in the script. But from that point on, lshift was stuck pressed down until I physically pressed and released it.

Since realizing this and using your suggestion, I have not noticed shift get stuck again. I will let you know if it does.

Thanks again!
User avatar
evilC
Posts: 4792
Joined: 27 Feb 2014, 12:30

Re: Shift Key Gets Stuck (Suppressing Other Keystrokes). Help!

30 Jun 2016, 14:30

I’m not sure why ~lbutton & mbutton triggered ~lshift & mbutton
Possible Scenario?
if lb + mb sends a shifted key, shift goes down, making lshift+mb match ?

Prefix yours hotkeys with $ to stop a send triggering a hotkey
poetofpiano
Posts: 43
Joined: 25 Jan 2016, 14:26

Re: Shift Key Gets Stuck (Suppressing Other Keystrokes). Help!

01 Jul 2016, 12:08

The problem happened again today. I was able to capture a much bigger keyhistory, but I’m not sure if it’s relevant because the same suspect hotkeys caused the problem:

Code: Select all

22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.36	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.02	PgDn           	
9E  001	h	d	0.31	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.56	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.17	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.33	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.01	PgDn           	
9E  001	h	d	0.28	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.30	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.67	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.36	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.25	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.31	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.66	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.31	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.28	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.27	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.38	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.64	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.01	PgDn           	
9E  001	h	d	0.33	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.33	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.02	PgDn           	
9E  001	h	d	0.33	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.36	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.59	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.36	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.30	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.73	WheelDown      	
22  151	i	d	0.02	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	1.08	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.53	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.02	PgDn           	
9E  001	h	d	0.34	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.72	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.42	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.34	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.38	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.75	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
9E  001	h	d	0.88	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
A4  038	 	d	0.98	LAlt           	
45  012	h	d	0.22	E              	
A2  01D	i	d	0.00	LControl       	
A0  02A	i	d	0.00	LShift         	
A4  038	i	u	0.00	LAlt           	
27  14D	i	d	0.00	Right          	
27  14D	i	u	0.00	Right          	
A0  02A	i	u	0.00	LShift         	
A4  038	i	d	0.00	LAlt           	
A2  01D	i	u	0.00	LControl       	
45  012	s	u	0.16	E              	
A4  038	 	u	0.17	LAlt           	
A2  01D	i	d	0.00	LControl       	
A2  01D	i	u	0.00	LControl       	
9E  001	h	d	4.25	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
A4  038	 	d	0.36	LAlt           	
45  012	h	d	0.19	E              	
A2  01D	i	d	0.00	LControl       	
A0  02A	i	d	0.00	LShift         	
A4  038	i	u	0.00	LAlt           	
27  14D	i	d	0.00	Right          	
27  14D	i	u	0.00	Right          	
A0  02A	i	u	0.00	LShift         	
A4  038	i	d	0.00	LAlt           	
A2  01D	i	u	0.00	LControl       	
45  012	s	u	0.14	E              	
A4  038	 	u	0.78	LAlt           	
A2  01D	i	d	0.00	LControl       	
A2  01D	i	u	0.00	LControl       	
A4  038	 	d	0.41	LAlt           	
45  012	h	d	0.22	E              	
A2  01D	i	d	0.00	LControl       	
A0  02A	i	d	0.00	LShift         	
A4  038	i	u	0.00	LAlt           	
27  14D	i	d	0.00	Right          	
27  14D	i	u	0.00	Right          	
A0  02A	i	u	0.00	LShift         	
A4  038	i	d	0.00	LAlt           	
A2  01D	i	u	0.00	LControl       	
45  012	s	u	0.16	E              	
A4  038	 	u	1.06	LAlt           	
A2  01D	i	d	0.00	LControl       	
A2  01D	i	u	0.00	LControl       	
9E  001	h	d	6.50	WheelDown      	
22  151	i	d	0.00	PgDn           	
22  151	i	u	0.00	PgDn           	
A4  038	 	d	0.97	LAlt           	
A4  038	 	d	0.50	LAlt           	
A4  038	 	d	0.05	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
45  012	h	d	0.00	E              	
A2  01D	i	d	0.00	LControl       	
A0  02A	i	d	0.00	LShift         	
A4  038	i	u	0.00	LAlt           	
27  14D	i	d	0.00	Right          	
27  14D	i	u	0.00	Right          	
A0  02A	i	u	0.00	LShift         	
A4  038	i	d	0.00	LAlt           	
A2  01D	i	u	0.00	LControl       	
45  012	s	u	0.16	E              	
A4  038	 	u	0.77	LAlt           	
A2  01D	i	d	0.00	LControl       	
A2  01D	i	u	0.00	LControl       	
A4  038	 	d	0.45	LAlt           	
45  012	h	d	0.22	E              	
A2  01D	i	d	0.00	LControl       	
A0  02A	i	d	0.00	LShift         	
A4  038	i	u	0.00	LAlt           	
27  14D	i	d	0.00	Right          	
27  14D	i	u	0.00	Right          	
A0  02A	i	u	0.01	LShift         	
A4  038	i	d	0.00	LAlt           	
A2  01D	i	u	0.00	LControl       	
45  012	s	u	0.14	E              	
A4  038	 	u	0.64	LAlt           	
A2  01D	i	d	0.00	LControl       	
A2  01D	i	u	0.00	LControl       	
04  000	h	d	13.73	MButton        	
53  01F	h	d	0.28	S              	
53  01F	s	u	0.14	S              	Facebook - Google Chrome
04  000	s	u	0.17	MButton        	
5B  15B	 	d	0.31	LWin           	
4B  025	h	d	0.23	K              	
4B  025	s	u	0.09	K              	
4F  018	h	d	0.38	O              	
4F  018	s	u	0.08	O              	
4F  018	h	d	0.14	O              	
4F  018	s	u	0.05	O              	
20  039	h	d	0.53	Space          	
20  039	s	u	0.11	Space          	
5B  15B	 	u	0.69	LWin           	
A2  01D	i	d	0.00	LControl       	
A2  01D	i	u	0.00	LControl       	
A4  038	 	d	0.19	LAlt           	
50  019	h	d	0.13	P              	
A2  01D	a	d	0.00	LControl       	
A0  02A	a	d	0.00	LShift         	
A4  038	a	u	0.00	LAlt           	
25  14B	a	d	0.02	Left           	
25  14B	a	u	0.00	Left           	
A0  02A	i	u	0.00	LShift         	
A4  038	i	d	0.00	LAlt           	
A2  01D	i	u	0.00	LControl       	
A2  01D	a	d	0.00	LControl       	
A2  01D	a	u	0.00	LControl       	
A4  038	a	u	0.00	LAlt           	
A2  01D	i	d	0.00	LControl       	
A2  01D	i	u	0.00	LControl       	
08  00E	a	d	0.00	Backspace      	
08  00E	a	u	0.00	Backspace      	
A2  01D	i	d	0.00	LControl       	
A4  038	i	d	0.00	LAlt           	
A2  01D	i	u	0.00	LControl       	
50  019	s	u	0.13	P              	
4F  018	h	d	0.84	O              	
A2  01D	a	d	0.00	LControl       	
A2  01D	a	u	0.00	LControl       	
A4  038	a	u	0.00	LAlt           	
A2  01D	i	d	0.00	LControl       	
A2  01D	i	u	0.00	LControl       	
0D  01C	a	d	0.01	Enter          	
0D  01C	a	u	0.00	Enter          	
A2  01D	i	d	0.00	LControl       	
A4  038	i	d	0.00	LAlt           	
A2  01D	i	u	0.00	LControl       	
4F  018	s	u	0.08	O              	
A4  038	 	u	0.52	LAlt           	
A2  01D	i	d	0.00	LControl       	
A2  01D	i	u	0.00	LControl       	
01  000	 	d	4.22	LButton        	
01  000	 	u	0.17	LButton        	
9E  001	#	d	13.73	WheelDown      	
9E  001	#	d	13.77	WheelDown      	
9E  001	#	d	15.66	WheelDown      	
9E  001	#	d	1.26	WheelDown      	
9E  001	#	d	8.52	WheelDown      	
9E  001	#	d	12.36	WheelDown      	
9E  001	#	d	25.14	WheelDown      	
9E  001	#	d	25.48	WheelDown      	
9E  001	#	d	22.22	WheelDown      	
9E  001	#	d	20.34	WheelDown      	
9F  001	#	d	19.69	WheelUp        	
01  000	 	d	101.92	LButton        	
01  000	 	u	0.16	LButton        	
01  000	 	d	3.30	LButton        	
01  000	 	u	0.13	LButton        	
01  000	 	d	6.25	LButton        	
01  000	 	u	0.14	LButton        	
01  000	 	d	271.28	LButton        	
01  000	 	u	0.13	LButton        	
01  000	 	d	2.83	LButton        	
01  000	 	u	0.11	LButton        	
9E  001	#	d	13.97	WheelDown      	
9F  001	#	d	1.08	WheelUp        	
9E  001	#	d	6.05	WheelDown      	
9E  001	#	d	0.70	WheelDown      	
9E  001	#	d	0.70	WheelDown      	
9E  001	#	d	0.81	WheelDown      	
9F  001	#	d	0.77	WheelUp        	
9F  001	#	d	0.03	WheelUp        	
9F  001	#	d	0.05	WheelUp        	
9F  001	#	d	0.05	WheelUp        	
9F  001	#	d	0.09	WheelUp        	
A4  038	 	d	1.72	LAlt           	
02  000	h	d	0.44	RButton        	
A2  01D	i	d	0.00	LControl       	
A4  038	i	u	0.00	LAlt           	
54  014	i	d	0.00	T              	
54  014	i	u	0.00	T              	
A4  038	i	d	0.00	LAlt           	
A2  01D	i	u	0.00	LControl       	
A4  038	 	d	0.06	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
02  000	s	u	0.03	RButton        	
A4  038	 	d	0.00	LAlt           	
A4  038	 	d	0.05	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	d	0.03	LAlt           	
A4  038	 	u	0.03	LAlt           	
A2  01D	i	d	0.00	LControl       	
A2  01D	i	u	0.00	LControl       	
52  013	#	d	0.41	R              	
45  012	#	d	0.13	E              	
52  013	 	u	0.01	R              	
45  012	 	u	0.08	E              	
44  020	#	d	0.11	D              	
44  020	#	u	0.13	D              	
20  039	h	d	0.08	Space          	
57  011	#	d	0.14	W              	
49  017	#	d	0.08	I              	
57  011	 	u	0.01	W              	
20  039	 	u	0.00	Space          	
49  017	 	u	0.09	I              	
4E  031	 	d	0.02	N              	
4E  031	 	u	0.14	N              	
47  022	#	d	0.02	G              	
47  022	 	u	0.08	G              	
53  01F	#	d	0.09	S              	
20  039	h	d	0.08	Space          	
53  01F	 	u	0.06	S              	
20  039	 	u	0.09	Space          	
46  021	#	d	0.03	F              	
46  021	 	u	0.09	F              	
52  013	#	d	0.11	R              	
52  013	 	u	0.11	R              	
41  01E	#	d	0.01	A              	
41  01E	 	u	0.11	A              	
4E  031	 	d	0.03	N              	
4E  031	 	u	0.16	N              	
53  01F	#	d	0.02	S              	
53  01F	 	u	0.08	S              	
20  039	h	d	0.05	Space          	
20  039	 	u	0.16	Space          	
4E  031	 	d	0.33	N              	
4E  031	 	u	0.11	N              	
45  012	#	d	0.06	E              	
45  012	 	u	0.09	E              	
55  016	 	d	0.05	U              	
55  016	 	u	0.08	U              	
BA  027	h	d	0.59	;              	
08  00E	a	d	0.00	Backspace      	
08  00E	a	u	0.00	Backspace      	
BA  027	s	u	0.08	;              	
49  017	#	d	0.06	I              	
49  017	 	u	0.09	I              	
4C  026	#	d	0.19	L              	
4C  026	 	u	0.09	L              	
53  01F	#	d	0.05	S              	
53  01F	 	u	0.09	S              	
45  012	#	d	0.11	E              	
45  012	 	u	0.08	E              	
4E  031	 	d	0.02	N              	
4E  031	 	u	0.08	N              	
0D  01C	 	d	0.17	Enter          	
0D  01C	 	u	0.13	Enter          	
01  000	 	d	5.23	LButton        	
01  000	 	u	2.88	LButton        	
01  000	 	d	5.41	LButton        	
01  000	 	u	0.23	LButton        	
9E  001	#	d	14.73	WheelDown      	
9E  001	#	d	6.64	WheelDown      	
9E  001	#	d	12.11	WheelDown      	
9E  001	#	d	32.67	WheelDown      	
9F  001	#	d	26.02	WheelUp        	
9F  001	#	d	0.42	WheelUp        	
01  000	 	d	2.31	LButton        	
04  000	h	d	0.58	MButton        	
A0  02A	i	u	0.00	LShift         	
A2  01D	i	d	0.02	LControl       	
23  14F	i	d	0.00	End            	
23  14F	i	u	0.00	End            	
A2  01D	i	u	0.00	LControl       	
04  000	s	u	0.17	MButton        	
01  000	 	u	0.55	LButton        	
01  000	h	d	4.69	LButton        	
A0  02A	i	u	0.00	LShift         	
A2  01D	i	d	0.03	LControl       	
24  147	i	d	0.00	Home           	
24  147	i	u	0.00	Home           	
A2  01D	i	u	0.00	LControl       	
04  000	h	d	1.19	MButton        	
A0  02A	i	u	0.00	LShift         	
A2  01D	i	d	0.02	LControl       	
23  14F	i	d	0.00	End            	
23  14F	i	u	0.08	End            	
A2  01D	i	u	0.00	LControl       	
04  000	s	u	0.03	MButton        	
01  000	s	u	0.81	LButton        	
01  000	h	d	2.86	LButton        	
A0  02A	i	u	0.00	LShift         	
A2  01D	i	d	0.02	LControl       	
24  147	i	d	0.00	Home           	
24  147	i	u	0.00	Home           	
A2  01D	i	u	0.00	LControl       	
01  000	s	u	1.33	LButton        	
01  000	h	d	0.78	LButton        	
A0  02A	i	u	0.00	LShift         	
A2  01D	i	d	0.02	LControl       	
24  147	i	d	0.00	Home           	
24  147	i	u	0.00	Home           	
A2  01D	i	u	0.00	LControl       	
04  000	h	d	0.23	MButton        	
A0  02A	i	u	0.00	LShift         	
A2  01D	i	d	0.02	LControl       	
23  14F	i	d	0.00	End            	
23  14F	i	u	0.00	End            	
A2  01D	i	u	0.00	LControl       	
04  000	s	u	0.16	MButton        	
01  000	s	u	0.84	LButton        	
01  000	h	d	0.22	LButton        	
A0  02A	i	u	0.00	LShift         	
A2  01D	i	d	0.02	LControl       	
24  147	i	d	0.00	Home           	
24  147	i	u	0.00	Home           	
A2  01D	i	u	0.00	LControl       	
01  000	s	u	0.19	LButton        	
A0  02A	 	d	6.74	LShift         	
A0  02A	 	u	0.11	LShift         	
5B  15B	 	d	0.94	LWin           	
5B  15B	 	d	0.50	LWin           	
5B  15B	 	d	0.05	LWin           	
5B  15B	 	d	0.03	LWin           	
5B  15B	 	d	0.03	LWin           	
5B  15B	 	d	0.03	LWin           	
30  00B	h	d	0.02	0           
These were the problematic hotkeys I had in operation at the time:

Code: Select all

#IfWinActive ahk_class Chrome_WidgetWin_1
~lshift & lbutton::
sendevent {blind}{lshift up}
send {Blind}^{home}
return

#IfWinActive ahk_class Chrome_WidgetWin_1
~lshift & mbutton::
sendevent {blind}{lshift up}
send {blind}^{end}
return

#IfWinActive ahk_class Chrome_WidgetWin_1
~lbutton & mbutton::
sendlevel, 1
send {lbutton up}
mousegetpos, xpos, ypos
click 11, 39 ; back button
mousemove, %xpos%, %ypos%
return
again I had the problem of trying to execute the ~lbutton & mbutton:: hotkey and instead accidentally triggering the ~lshift & mbutton:: hotkey. By that point, even just clicking down the left mouse button by itself triggered the ~lshift & lbutton:: hotkey. The problem only stopped when I physically pressed lshift down and up.

I still don’t know what is causing the problem…It is all the more puzzling because I removed any {shift down} or {shift up} event from ~lbutton & mbutton::, so your suggestion that maybe ~lbutton & mbutton:: could be sending a {shift} event that could trigger ~lshift & mbutton:: was not the issue…What should I do next?

At https://autohotkey.com/board/topic/9409 ... ways-down/ one experienced user suggested the following to ensure that no unwanted modifiers are pressed down before a hotkey is executed:

Code: Select all

While GetKeyState("Ctrl","P") || GetKeyState("LWin","P") || GetKeyState("RWin","P") || GetKeyState("Shift","P") || GetKeyState("Alt","P")
   Sleep 50
Where exactly should I put this phrase to test it out? At the beginning of every hotkey that wrongly triggers a different hotkey? Or at the top of my script?

Another user at that link suggested:

Code: Select all

ReleaseModifiers(timeout := "") ; timeout in ms
{
	static	aModifiers := ["Ctrl", "Alt", "Shift", "LWin", "RWin"]
	
	startTime := A_Tickcount
	while (isaKeyPhysicallyDown(aModifiers))
	{
		if (timeout && A_Tickcount - startTime >= timeout)
			return 1 ; was taking too long
		sleep, 5
	}
	return
}

isaKeyPhysicallyDown(Keys)
{
  if isobject(Keys)
  {
    for Index, Key in Keys
      if getkeystate(Key, "P")
        return key
  }
  else if getkeystate(Keys, "P")
  	return Keys ;keys!
  return 0
}
With this I assume I just put the variable RelaseModifiers at the beginning of every hotkey that I want to prevent from triggering another, is that right?

I have tried to consider everything that could be causing my problem. I do have more than one script running with keyboard hook installed — could this be confusing Autohotkey?

Should I try removing the tildes from in front of ~lshift & mbutton:: and ~lshift & lbutton::?

Would moving the ~lbutton & mbutton:: hotkey above the other to give precedence to ~lbutton & mbutton?

I know this is a somewhat known issue in Autohotkey, but there must be a definitive answer…

Thank you again for your help!
User avatar
evilC
Posts: 4792
Joined: 27 Feb 2014, 12:30

Re: Shift Key Gets Stuck (Suppressing Other Keystrokes). Help!

01 Jul 2016, 13:31

poetofpiano wrote: At https://autohotkey.com/board/topic/9409 ... ways-down/ one experienced user suggested the following to ensure that no unwanted modifiers are pressed down before a hotkey is executed:

Code: Select all

While GetKeyState("Ctrl","P") || GetKeyState("LWin","P") || GetKeyState("RWin","P") || GetKeyState("Shift","P") || GetKeyState("Alt","P")
   Sleep 50
Where exactly should I put this phrase to test it out? At the beginning of every hotkey that wrongly triggers a different hotkey? Or at the top of my script?
Correct

Code: Select all

F12::
	While GetKeyState("Ctrl","P") || GetKeyState("LWin","P") || GetKeyState("RWin","P") || GetKeyState("Shift","P") || GetKeyState("Alt","P")
		Sleep 50
	Send {something}
	return

poetofpiano wrote: Another user at that link suggested:

Code: Select all

ReleaseModifiers(timeout := "") ; timeout in ms
{
	static	aModifiers := ["Ctrl", "Alt", "Shift", "LWin", "RWin"]
	
	startTime := A_Tickcount
	while (isaKeyPhysicallyDown(aModifiers))
	{
		if (timeout && A_Tickcount - startTime >= timeout)
			return 1 ; was taking too long
		sleep, 5
	}
	return
}

isaKeyPhysicallyDown(Keys)
{
  if isobject(Keys)
  {
    for Index, Key in Keys
      if getkeystate(Key, "P")
        return key
  }
  else if getkeystate(Keys, "P")
  	return Keys ;keys!
  return 0
}
With this I assume I just put the variable RelaseModifiers at the beginning of every hotkey that I want to prevent from triggering another, is that right?
Call ReleaseModifiers() like so:

Code: Select all

F12::
	ReleaseModifiers()
	Send {something}
	return


Return to “Ask For Help”

Who is online

Users browsing this forum: alesyt0h, autohotkeycool, Black-Phoenix, sanmaodo and 63 guests