Before you say anything, I know I can use win+d to go to desktop. I would like to be able to just use the windows key instead of win+d because I'm trying to replace the start menu and taskbar with rainmeter plugins, but I use the windows key for many tasks that I can now only use when on the desktop.

LWin up::
If (A_PriorKey = "LWin") ; LWin was pressed alone
    Send, #d             ; go to desktop

; In this case it's necessary to define a custom combination by using "&" or "<#" 
; to avoid that LWin loses its original function as a modifier key:

<#a:: Send, #a  ; <# means LWin

The following AutoHotkey script will intercept the Left-Win key, minimize all windows and activate the desktop, then set the Left-Win key to down. It will wait for the Left-Win key to be released to set it to the up state so it will work with future pressed keys in combination until the Win key is released:

LWin::                           ; intercept the Left-Win key
WinMinimizeAll                   ; minimize all windows
WinActivate, Program Manager     ; activate the desktop
Send {LWin down}                 ; send Left-Win down
KeyWait, LWin                    ; wait for Left-Win key up
Send {LWin up}                   ; set Left-Win key up

You may do the same with the right-Win key (RWin).

After installing AutoHotKey, put the above text in a .ahk file and double-click it to test. You may stop the script by right-click on the green H icon in the traybar and choosing Exit. To have it run on login, place it in the Startup group at:
C:\Users\USER-NAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.