For a long time I've always had Windows set to show hidden files, I imagine many technical-minded people do. There are a lot of hidden files that I need to get to sometimes, like the Application Data folder. But there are also a lot of files that really should be hidden most of the time, like all those $NtUninstallXXXXXXX$ folders in C:\Windows or all the Desktop.ini files scattered around. They're just unneeded clutter on the screen.
So I wanted to come up with a way to toggle them on and off easier, and also have some way of knowing that there
are hidden files in a given folder without having to see the full list of them.
Here's what I came up with:
Code:
#SingleInstance Force
#NoEnv
#Persistent
SendMode Input
; Hide & See By ManaUser can
;
; * Toggle visibility of hidden files in Windows Explorer.
; * Report existance of hidden files when they are not show.
; * Temportarily show hidden files in current folder.
;
; You must make the address bar visible in Windows Explorer for this to work.
; Right-click icon to access a context menu.
; Double-Click or use Win+S hotkey to see hidden files temportarily.
Ignore = desktop.ini|thumbs.db|Recycled|RECYCLER
GroupAdd Explorer, ahk_class ExploreWClass
GroupAdd Explorer, ahk_class CabinetWClass
Menu TRAY, NoStandard
Menu TRAY, Add, &See Files Now, SeeHiddenFiles
Menu TRAY, Default, &See Files Now
Menu TRAY, Add, &Always Show, AlwaysShow
Menu TRAY, Add, &Quit, Quit
SetTimer Refresh, 250
Refresh:
If (CheckReg() = 1)
{
;Menu TRAY, Icon, icons\Gate-Show.ico
Menu TRAY, Icon, SHELL32.DLL, 127
Menu TRAY, Disable, &See Files Now
Menu TRAY, Check, &Always Show
}
Else
{
;Menu TRAY, Icon, icons\Gate.ico
Menu TRAY, Icon, SHELL32.DLL, 46
Menu TRAY, Enable, &See Files Now
Menu TRAY, UnCheck, &Always Show
}
IfWinActive ahk_group Explorer
{
ID := WinExist("A")
WinGetClass ExplorerWin, A
ControlGetText CurrentPath, Edit1, ahk_class %ExplorerWin% ;Address bar
If (CurrentPath = "My Documents") ;Substitute real path for speciial folders
CurrentPath := A_MyDocuments
Else If (CurrentPath = "Desktop")
CurrentPath := A_Desktop
Else If NOT InStr(CurrentPath, "\")
Return
If (CurrentPath != LastPath)
{
LastPath := CurrentPath
UpdateExp(ID)
HiddenFiles := 0
Loop, %CurrentPath%\*, 0 ;non-folders
{
If InStr(FileExist(A_LoopFileLongPath), "H")
{
If NOT RegExMatch(A_LoopFileName, "i)^(" . Ignore . ")$")
HiddenFiles++
}
}
HiddenFolders := 0
Loop, %CurrentPath%\*, 2 ;folders only
{
If InStr(FileExist(A_LoopFileLongPath), "H")
{
If NOT RegExMatch(A_LoopFileName, "i)^(" . Ignore . ")$")
HiddenFolders++
}
}
If HiddenFolders
{
If HiddenFiles
Message = Files: %HiddenFiles%`r`nFolders: %HiddenFolders%
Else
Message = Folders: %HiddenFolders%
}
Else
{
If HiddenFiles
Message = Files: %HiddenFiles%
Else
Message = No Hidden Files
}
Menu TRAY, Tip, %Message%
If (Message = "No Hidden Files")
SetTimer KillTrayTip, -1
else
{
TrayTip, , %Message%
SetTimer KillTrayTip, -3000
}
}
}
Return
KillTrayTip:
TrayTip
Return
SeeHiddenFiles:
#IfWinActive ahk_group Explorer
#s:: ;WinKey + S Shortcut
#IfWinActive
If CheckReg() = 1
Return
WinActivate ahk_id %ID%
SetReg(1)
UpdateExp(ID)
Sleep 250
SetReg(2)
Return
AlwaysShow:
If CheckReg() = 1
SetReg(2)
Else
SetReg(1)
UpdateExp(ID)
Goto Refresh
Return
Quit:
ExitApp
Return
UpdateExp(ID)
{
If (A_OSType = "WIN32_WINDOWS")
PostMessage, 0x111, 41504,,, ahk_id %ID%
else
PostMessage, 0x111, 28931,,, ahk_id %ID%
}
CheckReg()
{
RegRead, Status, HKCU, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden
Return Status
}
SetReg(Status)
{
RegWrite, REG_DWORD, HKCU, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden, %Status%
}
I already have a few improvements in mind, such as a built-in way to edit the ignore list, and support for alternate methods of checking the current folder. But I'd like to hear what the rest of you think.
Do you like this idea at all? If so how could it be improved? In terms of features, interface or efficiency.