On Windows 11 and 10, you can create a custom keyboard shortcut to hide or unhide desktop icons quickly. Here’s how.
One of the best ways to keep your desktop minimal and clean is by hiding the desktop icons. This gives you the flexibility to have all your important icons on the desktop while hiding them when not needed. By default, you can hide and unhide desktop icons using the right-click menu. While this method works fine, if you are someone who hides and unhides desktop icons multiple times a session, a more quick and easy way is very helpful. In that case, you can create a custom keyboard shortcut to hide and unhide desktop icons. Once created, pressing the assigned keyboard shortcut does the magic.
In this quick and straightforward tutorial, I will show you how to create your own keyboard shortcut using AutoHotKey to hide or unhide desktop icons. Let’s get started.
Create a Keyboard Shortcut to Show or Hide Desktop Icons
- Get AutoHotKey from here and install it.
- Press the “Windows key” to open the Start menu.
- Search and open “Notepad“.
- Paste the following script in Notepad.
;Press F12 to hide or unhide desktop icons
F12::
{
global
HWND := ControlGetHwnd("SysListView321", "ahk_class Progman")
if (HWND = "")
HWND := ControlGetHwnd("SysListView321", "ahk_class WorkerW")
If DllCall("IsWindowVisible", "UInt", HWND)
WinHide("ahk_id " HWND)
Else
WinShow("ahk_id " HWND)
Return
} - Press “Ctrl + Shift + S“.
- Go to the folder where you want to save the file.
- Type “HideUnhideIcons.ahk” in the “File name” field.
- Select “All files” from the “File type” dropdown menu.
- Click “Save“.
- Find and double-click the “HideUnhideIcons.ahk” file.
- From now on, press
F12
to hide and unhide desktop icons.
Detailed Steps (With Screenshots)
Since we want to use AutoHotKey to create a custom shortcut, we need to install it first. To do that, download the installer from the official website and double-click on it. Follow the on-screen installation instructions to install AutoHotKey.
Once AutoHotKey is installed, we can proceed to creating the script. To do that, press the “Windows key” to open the Start menu, search for “Notepad” and click “Open“.

In the Notepad window, paste the following script.
;Press F12 to hide or unhide desktop icons
F12::
{
global
HWND := ControlGetHwnd("SysListView321", "ahk_class Progman")
if (HWND = "")
HWND := ControlGetHwnd("SysListView321", "ahk_class WorkerW")
If DllCall("IsWindowVisible", "UInt", HWND)
WinHide("ahk_id " HWND)
Else
WinShow("ahk_id " HWND)
Return
}
Next, press “Ctrl + Shift + S” to open the “Save as” dialog. Here, go to the folder where you want to save the script file, type “HideUnhideIcons.ahk” as the file name, select “All files” from the “File type” dropdown menu, and click “Save“.

The above action saves the script file with the same “HideUnhideIcons.ahk“. To run it, double-click the script file.

That is it. As long as the script is running, you can press F12
to hide or unhide the desktop icons.

For those who want to customize the shortcut, you can edit the F12
part of the second line. Here is the list of modifiers and keys you can use to create a custom shortcut.
I hope this tutorial helps you. If you have any questions or need help, comment below. I’ll be happy to assist.
Update: The script has been updated from AutoHotKey v1 to AutoHotKey v2.
Thank you for this. Works great ????
Thanks!
flawless! thank you very much.
Absolotely simple and very useful. Thank you – and do you have any other shortcuts to share using this method?
THANKS Works great!!!!!!!!!!!!!!!!!!!