Modified Remapping broken by 2.0.14 Topic is solved

Report problems with documented functionality
riyah96662
Posts: 7
Joined: 17 Mar 2024, 14:04

Modified Remapping broken by 2.0.14

Post by riyah96662 » 06 May 2024, 10:31

I have been using Modified Remapping to suppress Alt menu for a while.

Code: Select all

*LAlt::SetKeyDelay(-1), Send("{LAlt down}{Shift}"), KeyWait("LAlt")
~*LAlt up::SetKeyDelay(-1), Send("{Blind}{LAlt up}")

*RAlt::SetKeyDelay(-1), Send("{RAlt down}{Shift}"), KeyWait("RAlt")
~*RAlt up::SetKeyDelay(-1), Send("{Blind}{RAlt up}")

<!w::Send "^w"
<!t::Send "^t"
It worked well and I can still use LAlt and RAlt as modifier keys normally.
For example, LAlt + W to close current tab and LAlt + T to open a new tab in browsers.

But with 2.0.14, I can no longer use them as modifier keys.

BTW, the well-known way to suppress Alt menu is just buggy and unreliable.

Code: Select all

*~LAlt::Send "{Blind}{vkE8}"

lexikos
Posts: 9635
Joined: 30 Sep 2013, 04:07
Contact:

Re: Modified Remapping broken by 2.0.14  Topic is solved

Post by lexikos » 07 May 2024, 05:31

Your script was relying on a bug. The behaviour of your script was incorrect. Now it is correct (pressing <!w produces !^w).
Fixed Send to leave any prior {modifier Down} in effect even if the key happens to be physically held down.
Source: Changes & New Features | AutoHotkey v2
{Alt down} Holds Alt down until {Alt up} is sent.
Source: Send - Syntax & Usage | AutoHotkey v2
Remappings use DownR, not Down.
By default, Send will not automatically release a modifier key (Control, Shift, Alt, and Win) if that modifier key was "pressed down" by sending it. For example, Send "a" may behave similar to Send "{Blind}{Ctrl up}a{Ctrl down}" if the user is physically holding Ctrl, but Send "{Ctrl Down}" followed by Send "a" will produce Ctrl+A. DownTemp and DownR can be used to override this behavior. DownTemp and DownR have the same effect as Down except for the modifier keys (Control, Shift, Alt, and Win).
Source: Send - Syntax & Usage | AutoHotkey v2
BTW, the well-known way to suppress Alt menu is just buggy and unreliable.
What does buggy mean? Sometimes doesn't work? So it is unreliable and unreliable?

The default mechanism for suppressing the menu is to send Ctrl (the default A_MenuMaskKey). When Send has to release modifiers to change states, it does so in a specific order so that Ctrl modifies Alt and suppresses the menu (e.g. if it is pressing Ctrl and releasing Alt, it uses the sequence {Alt down}{Ctrl up}). This is reliable for the standard window menu implemented by the OS.

Sending Alt+Shift triggers the language switching hotkey on many systems.

riyah96662
Posts: 7
Joined: 17 Mar 2024, 14:04

Re: Modified Remapping broken by 2.0.14

Post by riyah96662 » 08 May 2024, 07:42

Now it is correct (pressing <!w produces !^w).
Ah, thank you for the clarification.
I got it working in 2.0.14 like this.

Code: Select all

<!w::Send "{Blind!}^w"
<!t::Send "{Blind!}^t"
Remappings use DownR, not Down.
It says in the document that DownR make it pressed down again.
DownR (where "R" stands for remapping, which is its main use) tells subsequent sends that if the key is automatically released, it should be pressed down again when send is finished.
But I do not want Alt to be pressed down again.

This is reliable for the standard window menu implemented by the OS.
Sending Alt+Shift triggers the language switching hotkey on many systems.
But not reliable for some third-party implementation such as Gecko/Firefox.
I did use {Alt down}{Ctrl up} but there are some other issues.
As shown in the gist, this method can be combined with single-key language switching.
That is why I disabled the system hotkey for language switching and use {LAlt down}{Shift} now.
In fact, it has less side effects because third-party applications should already have avoided conflicts with Alt+Shift.

lexikos
Posts: 9635
Joined: 30 Sep 2013, 04:07
Contact:

Re: Modified Remapping broken by 2.0.14

Post by lexikos » 12 May 2024, 07:23

But I do not want Alt to be pressed down again.
Why not? If you press LAlt+w twice in a row without releasing LAlt, it will not work the second time if LAlt has been released by Send and not "pressed down again". This is what Send does with physical keys when you do not use Blind, or when you exclude the Alt key with {Blind!}. If you are physically holding LAlt and do not have it remapped, Send "^w" will release LAlt in order to send Ctrl+W and then "press it down again" afterward if you are still holding it so that the LAlt key will continue to work as expected, until you actually release it. This is explained in the documentation.

The point is that DownR behaves more like a physical key, which is generally what you want when you remap keys.

Post Reply

Return to “Bug Reports”