Page 1 of 1

Prevent Win from opening the Start menu [Any Version]

Posted: 21 Mar 2022, 17:26
by Saiapatsu
~LWin::vkE8

Now pressing the Win key by itself will not show the Start menu, yet you may use any Win key hotkey.
With the Win key thus disabled, the Start menu can also be opened by pressing Ctrl+Esc.

The Start menu will only appear if the Win key was pressed and released without any other key being pressed inbetween.
This script will press an unassigned key any time you press Win. Because of this, the Start menu will not appear.
(Menu bars work similarly, but with Alt.)

The other Win key can be disabled in the same way, but with RWin instead of LWin.

vkE8 is an "unassigned" key. The vk07 key was commonly used for this purpose before Windows 10, in which it opens the Game Bar.

For more details, see:
Blocking the keyboard Windows key
#MenuMaskKey

This does not work on elevated windows unless the script is elevated (run as admin) because unelevated processes cannot send keystrokes to elevated windows.

———

Alternatively:
~LWin::Send "{Blind}{vkE8}"

The former command will hold down the "vkE8" key while LWin is pressed and release it when Win is released, whereas this command will simply send vkE8 up+down when LWin is pressed.
It may have side effects on older versions.

———

I have posted this in the tutorials section because there is no tutorial for this yet — only dozens of threads all across the internet asking for this and either getting shrugs, horrible black magic or LWin::return.

This is the traditional and right way to block the Start menu without preventing its use in hotkeys.

Well, other than patching explorer.exe or using another shell. :geek:

Re: Prevent Win from opening the Start menu [Any Version]

Posted: 21 Mar 2022, 17:37
by gregster
Saiapatsu wrote:
21 Mar 2022, 17:26
I have posted this in the tutorials section because there is no tutorial for this yet — only dozens of threads all across the internet asking for this and either getting shrugs, horrible black magic or LWin::return.
Afaics, you posted this in 'Scripts and Functions' - I have moved it now to 'Tutorials > Tips and Tricks' which seems to be the most appropriate subforum.

Re: Prevent Win from opening the Start menu [Any Version]

Posted: 30 Apr 2022, 16:59
by lexikos
The code shown is only valid for AutoHotkey v2, due to quote marks. In fact, this exact code is already in the documentation for A_MenuMaskKey. The v1 version is under #MenuMaskKey.

Both links in the post are for AutoHotkey v1.

There is also a way to trigger the Start menu without sending any keys (add quotes for v2):

Code: Select all

SendMessage WM_SYSCOMMAND:=0x112, SC_TASKLIST:=0xF130,,, ahk_class Progman
or even without actually sending the message (for v1/v2):

Code: Select all

DllCall("DefWindowProc", "ptr", A_ScriptHwnd, "uint", 0x112, "ptr", 0xF130, "ptr", 0)

Re: Prevent Win from opening the Start menu [Any Version]

Posted: 23 Feb 2023, 17:24
by Ape
I can't get this to work.

I want my leftwin key to remap to ALT+z but it didn't work.

~LWin::vkE8 still opens the start menu.

Re: Prevent Win from opening the Start menu [Any Version]

Posted: 13 Mar 2023, 08:52
by Jessica
The code ~LWin::vkE8 is a game-changer for me as it actually works.

I've been fed up with the Start menu popping up every time I hit LWin for years. However, the code below would disable other LWIN hotkeys and left me frustrated:
LWin::
Return

If ~LWin::vkE8 doesn't work for you, try this recent method I found below, it may just solve your problem:

LWin::
LWin & vkE8::
Return

This simply adds a hotkey to LWin::, and miraculously, it works for everything. It won't interfere with other LWIN hotkeys, and it doesn't perform any unnecessary processing as it doesn't send any keys.
Give it a try if you'd like.

Re: Prevent Win from opening the Start menu [Any Version]

Posted: 22 Jan 2024, 22:40
by jwj0319
"I'm planning to post a comment, and I find that

LWin::
LWin & vkE8::
Return

works well. But I'm curious why LWin & vkE8:: is added. Is there a problem with just using

LWin::
Return

like this?"

Re: Prevent Win from opening the Start menu [Any Version]

Posted: 15 Feb 2024, 20:14
by lexikos
@jwj0319 The presence of the custom combination hotkey prevents LWin:: from fully suppressing the LWin key, which would prevent it from working in combination with any other hotkeys, whether implemented by the script, the OS or other applications.