Advertisement
Najeebsk

HiddenFiles.ahk

Aug 24th, 2022
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; HiddenFiles.ahk by r0lZ, June 5, 2011
  2. #NoEnv
  3. #SingleInstance ignore
  4. #UseHook off
  5. #Persistent
  6. Menu, tray, noicon
  7.  
  8. ControlGet, hwWindow, HWND,, SysListView321, ahk_class Progman
  9. if hwWindow {
  10.     ; Win XP
  11.     desktopclassname := "Progman"
  12.     explorerlistview := "SysListView321"
  13. } else {
  14.     ; Win 7
  15.     desktopclassname := "WorkerW"
  16.     explorerlistview := "DirectUIHWND3"
  17. }
  18. GroupAdd, ExplorerWindowsGroup, ahk_class CabinetWClass
  19.  
  20. firstarg =
  21. if 0 >= 1
  22. {
  23.     firstarg = %1%
  24.     if (firstarg == "/h")
  25.         ShowHiddenFiles(0)
  26.     else if (firstarg == "/s")
  27.         ShowHiddenFiles(1)
  28.     else if (firstarg == "/sh")
  29.         ShowHiddenFiles(2)
  30.     else if (firstarg == "/swap")
  31.         Gosub, ToggleHiddenFiles
  32.     else
  33.         GoSub, Usage
  34.     ExitApp
  35. }
  36.  
  37. menu, tray, NoStandard
  38. menu, tray, Add, Help, Usage
  39. menu, tray, Add, Exit, CleanExit
  40. menu, tray, Add
  41. menu, tray, Add, Hide Hidden Files, HideHiddenFiles
  42. menu, tray, Add, Show Hidden Files, ShowHiddenFiles
  43. menu, tray, Add, Show Hidden and System Files, ShowSystemFiles
  44. menu, tray, Add
  45. menu, tray, Add, Swap Show/Hide Hidden Files, ToggleHiddenFiles
  46. menu, tray, Default, Swap Show/Hide Hidden Files
  47. menu, tray, Icon
  48.  
  49. ; monitors buttons clicks on tray icon
  50. OnMessage(0x404, "OnWM_BUTTONUPMessage")   ; 0x404 = AHK_NOTIFYICON
  51.  
  52. Return
  53.  
  54. ToggleHiddenFiles:
  55.     RegRead, ValorHidden,     HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden
  56.     if (ValorHidden == 2)
  57.         ShowHiddenFiles(1)
  58.     else
  59.         ShowHiddenFiles(0)
  60. Return
  61. HideHiddenFiles:
  62.     ShowHiddenFiles(0)
  63. Return
  64. ShowHiddenFiles:
  65.     ShowHiddenFiles(1)
  66. Return
  67. ShowSystemFiles:
  68.     ShowHiddenFiles(2)
  69. Return
  70. ShowHiddenFiles(mode) {
  71.     if (mode == 0) {
  72.         RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden, 2
  73.     } else if (mode == 1) {
  74.         RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden, 1
  75.         RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, ShowSuperHidden, 0
  76.     } else {
  77.         RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden, 1
  78.         RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, ShowSuperHidden, 1
  79.     }
  80.     sleep, 10
  81.     RefreshExplorerWindows()
  82.     ; refresh all Explorer windows
  83.     ControlSend, DirectUIHWND3, {F5}, ahk_group ExplorerWindowsGroup
  84.     return
  85. }
  86.  
  87. RefreshExplorerWindows()
  88. {
  89.     global desktopclassname, explorerlistview
  90.  
  91.     ; refresh Desktop
  92.     ControlSend, ahk_parent, {F5}, ahk_class %desktopclassname%
  93.  
  94.     ; refresh all Explorer windows
  95.     ControlSend, %explorerlistview%, {F5}, ahk_group ExplorerWindowsGroup
  96.  
  97.     return
  98. }
  99.  
  100. OnWM_BUTTONUPMessage(wParam, lParam)
  101. {
  102.     Critical
  103.     ; Refresh tray menu if Right button pressed
  104.     if (lParam == 0x204) {
  105.         RegRead, ValorHidden,     HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden
  106.         RegRead, ShowSuperHidden, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, ShowSuperHidden
  107.  
  108.         menu, tray, UnCheck, Hide Hidden Files
  109.         menu, tray, UnCheck, Show Hidden Files
  110.         menu, tray, UnCheck, Show Hidden and System Files
  111.         if (ValorHidden == 2) {
  112.             menu, tray, Check, Hide Hidden Files
  113.         } else {
  114.             if (ShowSuperHidden) {
  115.                 menu, tray, Check, Show Hidden and System Files
  116.             } else {
  117.                 menu, tray, Check, Show Hidden Files
  118.             }
  119.         }
  120.     }
  121.     Critical, off
  122. }
  123.  
  124. Usage:
  125.     MsgBox, 64, HiddenFiles by r0lZ - Freeware, HiddenFiles is an easy way to show or hide the hidden files in all Explorer windows and on the Desktop.`n`nCommand line usage:`nHiddenFiles /h  -> Hide hidden files`nHiddenFiles /s  -> Show hidden files`nHiddenFiles /sh  -> Show hidden and system files`nHiddenFiles /swap  -> Swap Show/Hide hidden files`nHiddenFiles /?  -> Show this help dialogue`nHiddenFiles  -> Without argument, stays resident in the tray
  126. Return
  127.  
  128. CleanExit:
  129. ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement