How to Create Hotkey to Show/Hide Desktop Icons using AHK Script

How to Create Hotkey to Show/Hide Desktop Icons using AHK Script

Do you have too many icons on your Desktop? You always think of cleaning it up but they’re just TOO many filled all over your desktop. So what would you do? Clean them by sorting out the most used or just press a simple shortcut key (or Hotkey technically) to hide them when not needed and again press the same hotkey to show them up. Obviously, the second one (the lazy man’s hack). Right?

Here, in this guide I’ll show how you can toggle desktop icons on or off, means hide and show on pressing a hotkey. We’ll use a popular windows scripting language AutoHotkey. For those unknown to this language below is a short description

What is AutoHotkey?

Well, as of now you would have known that you can create pretty awesome hotkeys. But, it’s not just about shortcuts. You can actually create a hotkey that on pressing can perform an automated and repetitive task. Tasks that you may be doing everyday. Like, opening a folder or file that you use everyday, opening a website, changing wallpaper, tweeting a tweet,etc. You can just automate anything you want with just a simple hotkey. The language is complex enough to dig deeper into any applications and perform automation at whatever scale you want.

Now, that you know the potential of Autohotkey, let’s get into how you can create hotkey to hide and show desktop icons.

Note: You need not have any prior knowledge of programming. The script is already given and you just have to copy-paste. I’ll show where you can make changes so that you can apply your own modifications. 

How to Show/Hide Desktop Icons using AHK Script

  • Download the AutoHotKey Application from here.
  • Install with Fast Installation and exit.
  • Create a new .ahk file on desktop by right-click -> New -> AutoHotkey Script.

show-hide-desktop-icons-2

  • Don’t double-click on file to open. But right-click and select edit script. It’ll probably open in notepad.

show-hide-desktop-icons-1

  • Now, paste the below given script in the file.

#F11::
ControlGet, HWND, Hwnd,, SysListView321, ahk_class Progman
 If HWND =
 ControlGet, HWND, Hwnd,, SysListView321, ahk_class WorkerW
 If DllCall("IsWindowVisible", UInt, HWND)
 WinHide, ahk_id %HWND%
 Else
 WinShow, ahk_id %HWND%

Return


 

  • Now save the file and close it. Double-click on the .ahk file that you just saved. It’ll run the script.
  • Refresh the screen by pressing F5 and your hotkey window key + F11 is ready to toggle back and forth to show/hide desktop icons. Press win+F11 to show/hide icons.
  • Below I’ve shown how you can change the keys for these hotkey.

Changing the Hotkey

You can form your combination of hotkey by using the below given key labels.

# -> Windows

^ -> Ctrl

! -> Alt

So, now you can create your own hotkey combination by using #,^ and !. To change the hotkey in the above script see the first line. #F11:: which shows win+F11. You can replace it with following as you like.

#C -> win+C

^!D -> ctrl+alt+D

!D -> alt+D

Just don’t forget to add a key letter at the end. The ” :: ” symbols shows that on pressing this hotkey combination following script will be executed. So, don’t forget to add that too while you replace.

Hope, this simple guide will help you to get rid of your clutter of icons and make it visible when needed. Any errors or queries, please mention down in the comments. I’ll feel happy to solve. More tutorials and guides on AHK script will be available on this blog. So be sure to subscribe and share.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.