Controls which key is used to mask Win or Alt keyup events.
A vkNNscNNN sequence identifying the virtual key code (NN) and scan code (NNN), in hexadecimal, or an empty string if masking is disabled.
The script can also assign a key name, vkNN sequence or scNNN sequence, in which case generally either the VK or SC code is left as zero until the key is sent, then determined automatically. Assigning "vk00sc000" disables masking and is equivalent to assigning "".
The returned string is always a vkNNscNNN sequence if enabled or "" if disabled, regardless of how it was assigned. All vkNNscNNN sequences and all non-zero vkNN or scNNN sequences are permitted, but some combinations may fail to suppress the menu. Any other invalid keys cause a ValueError to be thrown.
The mask key is sent automatically to prevent the Start menu or the active window's menu bar from activating at unexpected times.
The default mask key is Ctrl. This variable can be used to change the mask key to a key with fewer side effects.
Good candidates are virtual key codes which generally have no effect, such as vkE8, which Microsoft documents as "unassigned", or vkFF, which is reserved to mean "no mapping" (a key which has no function). Some values, such as zero VK with non-zero SC, may fail to suppress the Start menu. Key codes are not required to match an existing key.
Note: Microsoft can assign an effect to an unassigned key code at any time. For example, vk07 was once undefined and safe to use, but since Windows 10 1909 it is reserved for opening the game bar.
This setting is global, meaning that it needs to be specified only once to affect the behavior of the entire script.
Hotkeys: If a hotkey is implemented using the keyboard hook or mouse hook, the final keypress may be invisible to the active window and the system. If the system was to detect only a Win or Alt keydown and keyup with no intervening keypress, it would usually activate a menu. To prevent this, the keyboard or mouse hook may automatically send the mask key.
Pressing a hook hotkey causes the next Alt or Win keyup to be masked if all of the following conditions are met:
$#a::in combination with
AppsKey::RWincauses masking when Menu+A is pressed, but Menu on its own is able to open the Start Menu.
Mouse hotkeys may send the mask key immediately if the keyboard hook is not installed.
Hotkeys with the tilde modifier are not intended to block the native function of the key, so they do not cause masking. Hotkeys like
~#a:: still suppress the menu, since the system detects that Win has been used in combination with another key. However, mouse hotkeys and both Win themselves (
~RWin::) do not suppress the Start Menu.
The Start Menu (or the active window's menu bar) can be suppressed by sending any keystroke. The following example disables the ability for the left Win to activate the Start Menu, while still allowing its use as a modifier:
Send: Send, ControlSend and related often release modifier keys as part of their normal operation. For example, the hotkey
<#a::SendText Address usually must release the left Win prior to sending the contents of Address, and press the left Win back down afterward (so that other Win key combinations continue working). The mask key may be sent in such cases to prevent a Win or Alt keyup from activating a menu.
See this thread for background information.
A_MenuMaskKey := "vkE8" ; Change the masking key to something unassigned such as vkE8. #Space::Run A_ScriptDir ; An additional Ctrl keystroke is not triggered.