Key becomes sticky after update, need help.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
AndrewKun
Posts: 24
Joined: 03 Jun 2015, 12:03

Key becomes sticky after update, need help.

03 Jun 2015, 12:24

Hi!

I've been using the following script to change the system volume quite successfully for some time:

Code: Select all

#vk21::send {volume_up 2}
#vk22::Send {volume_down 2}
#vk23::send {volume_mute}
This changes volume by pressing Win+PgUp and Win+PgDn, which I already got used to. It worked perfectly for about a year, but after one of the updates a month or two ago it started to behave irratically in the following ways (it may be hard to explain for me, sorry):

1. If I press Win and hold down PgUp/PgDn, or press them somewhat quickly a few times, the combination of Ctrl+PgUp/PgDn (Yes, CTRL, even though it's not included in the script) is send to the application that currently in focus. For example, if I have browser opened, it scrolls between my tabs. If I look in the history of the key-presses, here's what I see (for example, for Win+PgUp):

Code: Select all

5C  15C	 	d	1.16	RWin           	
21  149	 	d	0.25	PgUp           	
A2  01D	i	d	0.01	LControl       	
A2  01D	i	u	0.00	LControl       	
5C  15C	i	u	0.02	RWin           	
AF  030	i	d	0.01	Volume_Up      	
AF  030	i	u	0.02	Volume_Up      	
21  149	 	u	0.02	PgUp           	
AF  030	i	d	0.01	Volume_Up      	
AF  030	i	u	0.00	Volume_Up      	
A2  01D	i	d	0.02	LControl       	
5C  15C	i	d	0.02	RWin           	
A2  01D	i	u	0.00	LControl       	
5C  15C	 	u	0.16	RWin    
As you can see, LControl is send for some reason and I suspect it is the fault. But I can live with that if I press Win+PgUp/PgDn really slowly.

2. And the second problem - sometimes after I press Win+PgUp/PgDn, the "Win" key becomes virtually stuck. That is, it's physically in unpressed state, but the system thinks it's pressed down. After I press "Win" key again, it's fixed. When I close the script, the issue is not reproduced, so it's definetely AHK's fault.

Please, if you know how I can modify the script to solve those issues, help me, I'll be very grateful. By the way, other combinations involing "Win" key in the same sctipt works perfectly. For example - #vk47::run http://www.google.ru

Code: Select all

5B  15B	 	d	2.66	LWin           	C:\scripts_autohotkey\desktop1.ahk - AutoHotkey v1.1.22.02
47  022	 	d	0.20	g              	
47  022	 	u	0.06	g              	
5B  15B	 	u	0.16	LWin           	Untitled - Google Chrome
No CTRL presses, works perfectly. I'm confused.
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: Key becomes sticky after update, need help.

03 Jun 2015, 18:32

The Windows key normally invokes the start menu on release. When you use a Windows hotkey you don't want the menu popping up so an artificial Control key event is sent so it registers as a (non start menu invoking) Control-Windows-up event. That's the control key event you're seeing.

When your hotkey also Sends some keys, Windows (or any modifier key) key needs to be artificially released and pressed again after completion. That's the difference between the misbehaving and behaving hotkey.

It it strange that the PgUp event of the key isn't suppressed and two pairs of {Volume_Up} are sent. Do you also have a PgUp up::/c] hotkey?

As for the cause (or solution) to the problem, I'm not really sure yet.
User avatar
jethrow
Posts: 188
Joined: 30 Sep 2013, 19:52
Location: Iowa

Re: Key becomes sticky after update, need help.

04 Jun 2015, 00:24

Try using KeyWait to make sure the modifier key (win key) is released before the send statement occurs.
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: Key becomes sticky after update, need help.

04 Jun 2015, 02:43

You can replace the Ctrl key with something else, such as the unused vk07, using #MenuMaskKey.

If you Send {Blind}{Volume_Up 2}, Send is not required to release the Win key and therefore does not send the Ctrl key either.

If you don't send any keys, the Win key won't be released and Ctrl won't be sent (unless the hotkeys use either "hook" method, in which cause generally the mask key is sent when you physically release the Win key).

Code: Select all

#vk21::SoundSet +4
#vk22::SoundSet -4
#vk23::SoundSet -1,, Mute
AndrewKun
Posts: 24
Joined: 03 Jun 2015, 12:03

Re: Key becomes sticky after update, need help.

04 Jun 2015, 13:40

Thank you so much everyone who tried to help! Particularly, lexikos's solutions did the trick.

Both of these solutions works perfectly:

Code: Select all

#vk21::send {blind}{volume_up 2}
#vk22::send {blind}{volume_down 2}
#vk23::send {blind}{volume_mute}
and

Code: Select all

#vk21::SoundSet +4
#vk22::SoundSet -4
#vk23::SoundSet -1,, Mute
Except, the second one doesn't display floating volume bar, which is a con. And, by the way, I don't experience any problems with Win key not being suppresed.

Thank you again! I really love the always helpful AHK community ;)
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: Key becomes sticky after update, need help.

04 Jun 2015, 17:06

Neither one displays a floating volume bar on a stock-standard Windows system. That must be the work of third-party software. (Laptop manufacturers often pre-install that sort of thing.)

There are a few volume OSD scripts on the other forum, if you ever have a need.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Lamron750 and 375 guests