How to quickly view or hide hidden files in AutoHotkey?


AutoHotkey
2023-07-06T11:21:28+00:00

How to quickly view or hide hidden files in AutoHotkey?

AutoHotkey is a powerful tool that allows you to ⁢automate⁢ tasks and create custom keyboard shortcuts on Windows. One of the useful features it offers is the ability to view or hide hidden files with a simple command. In this article, we will show you how to achieve this quickly and easily.

Create an AutoHotkey script

The first step is create an AutoHotkey script. Open a text editor such as Notepad and copy the following code:


#h::
RegRead, HiddenFiles_Status, HKEY_CURRENT_USER, SoftwareMicrosoftWindowsCurrentVersionExplorerAdvanced, Hidden
If HiddenFiles_Status = 2
RegWrite, REG_DWORD, HKEY_CURRENT_USER, SoftwareMicrosoftWindowsCurrentVersionExplorerAdvanced, Hidden, 1
else
RegWrite, REG_DWORD, HKEY_CURRENT_USER, SoftwareMicrosoftWindowsCurrentVersionExplorerAdvanced, Hidden, 2
WinGetClass, eh_Class,A
If (eh_Class = "#32770" OR A_OSVersion = "WIN_VISTA")
send, {F5}
Else PostMessage, 0x111, 28931,,, A
Return

Save the file with .ahk extension, for example, “show_hide_files.ahk”.

Understand the code

Let's see what each part of the AutoHotkey code:

  • #h:: defines the hotkey. In this case, it will be activated by pressing Win + H.
  • RegRead reads the current value of the registry key that controls the display of hidden files.
  • If HiddenFiles_Status = 2 checks if hidden files are currently visible.
  • RegWrite changes the value of the registry key to show or hide hidden ‌files.
  • WinGetClass y If (eh_Class = "#32770" OR A_OSVersion = "WIN_VISTA") determine whether the Windows Explorer window needs to be updated.
  • send, {F5} ⁢or PostMessage, 0x111, 28931,,, A Updates the Windows Explorer window to reflect the changes.

Run the script

Double-click the .ahk file you created to run the script. You will see an icon in the system tray indicating that AutoHotkey is active. Now, every time you press​ Win + H, the display of Hidden files.

Customize hotkey

If you prefer to use a different key combination, simply modify​ the first line of the script. For example, to use Ctrl+Alt+H, you would change #h:: by ^!h::.

With this simple AutoHotkey script, you can ⁣ toggle display of hidden files with a single keyboard shortcut. This will save you time and effort when working with files and folders in Windows.

Related