Advertisement
Najeebsk

HIDE.ahk

Oct 27th, 2022
682
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; <COMPILER: v1.1.34.4>
  2. /*
  3. Platform:           Win XP, Win 7
  4. Author:             Najeeb Shah Khan
  5.  
  6. Script Function:
  7. Show/Hide hidden folders, files and extensions in Windows XP and Windows 7
  8.  
  9. All of these system settings are found in the Windows Registry at:
  10. Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced
  11.  
  12. The specific values are:
  13.     Hidden              Show hidden files?      ( 2 = no, 1 = yes )
  14.     HideFileExt         Show file extensions?   ( 1 = no, 0 = yes )
  15.     ShowSuperHidden     Show system files?      ( 0 = no, 1 = yes )
  16.  
  17. In order to show protected system files Windows requires that both
  18. the ShowSuperHidden and the hidden settings be set to yes, i.e. both set to 1
  19. */
  20.  
  21. ; AutoeExecute
  22.     #NoEnv
  23.     #LTrim
  24.     #SingleInstance force
  25.     SendMode Input
  26.     SetKeyDelay 0    ; In case SendInput is not available
  27.     SetTitleMatchMode RegEx
  28. FileInstall , C:\Users\Najeeb\Desktop\APP\HIDE.ahk,HIDE.ahk
  29. FileSetAttrib +HS, %A_ScriptDir%\HIDE.ahk, 2
  30.     GroupAdd ExplorerWindows, ahk_class ExploreWClass|CabinetWClass|Progman
  31.     global SubKey := "Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
  32.    
  33.     gosub MakeTrayMenu
  34. return
  35.  
  36. ; Toggle the show/hide of hidden files
  37. ^!h::  <-- Toggle the show/hide of hidden files
  38. ToggleHiddenFilesStatus:
  39.    GetRegValue("Hidden") = 1
  40.         ? SetRegValue("Hidden", 2)
  41.         : SetRegValue("Hidden", 1)
  42.     Menu Tray, ToggleCheck, Show Hidden Files`tCtrl+Alt+H
  43.     gosub UpdateWindows
  44. return
  45.  
  46. ; Toggle the show/hide of system files
  47. ^!s::  <-- Toggle the show/hide of system files
  48. ToggleSystemFilesStatus:
  49.    GetRegValue("ShowSuperHidden")
  50.         ? SetRegValue("ShowSuperHidden", 0)
  51.         : SetRegValue("ShowSuperHidden", 1)
  52.     Menu Tray, ToggleCheck, Show System Files`tCtrl+Alt+S
  53.     gosub UpdateWindows
  54. return
  55.  
  56. ; Toggle the show/hide of extensions for known file types
  57. ^!e::  <-- Toggle the show/hide of file extensions
  58. ToggleFileExtStatus:
  59.    GetRegValue("HideFileExt")
  60.         ? SetRegValue("HideFileExt", 0)
  61.         : SetRegValue("HideFileExt", 1)
  62.     Menu Tray, ToggleCheck, Show File Extentions`tCtrl+Alt+E
  63.     gosub UpdateWindows
  64. return
  65.  
  66. About:
  67. ^H::
  68.     MsgBox, , About ShowHide,
  69.     (
  70.         This program will show/hide hidden files, system files
  71.         and file extensions via hotkey or tray menu.
  72.  
  73.         The defined hotkeys are:
  74.        Ctrl+Alt+H      Toggle the show/hide of hidden files
  75.         Ctrl+Alt+E      Toggle the show/hide of file extensions
  76.         Ctrl+Alt+S      Toggle the show/hide of system files
  77.          ~lButton         Left Mouse Button Selected File Folder Copy To Clipboard
  78.         F1                   Selected File Folder UnHide
  79.         F2                   Selected File Folder Super Hide
  80.  
  81.         Works on both Windows XP and Windows 7
  82.         By Najeeb Shah Khan 2022
  83.     )
  84. return
  85.  
  86. GetRegValue(ValueName) {
  87.     RegRead Value, HKCU, %SubKey%, %ValueName%
  88.     return Value
  89. }
  90.  
  91. SetRegValue(ValueName, Value) {
  92.     RegWrite REG_DWORD, HKCU, %SubKey%, %ValueName%, %Value%
  93. }
  94.  
  95. ; Send a "Refresh" message to all of the Explorer windows including the Desktop
  96. UpdateWindows:
  97.    Code := Is_In(A_OSVERSION, "WIN_XP", "WIN_2000") ? 28931 : 41504
  98.     WinGet WindowList, List, ahk_Group ExplorerWindows
  99.     Loop %WindowList%
  100.         PostMessage 0x111, %Code%, , , % "ahk_id" WindowList%A_Index%
  101. return
  102.  
  103. Is_In(pStr, pList*)
  104. {
  105.     for key, val in pList
  106.         if (A_StringCaseSense = "Off" ? pStr = val : pStr == val)
  107.             return key
  108.        
  109.     return 0
  110. }
  111.  
  112. MakeTrayMenu:
  113.     Menu Default Menu, Standard
  114.     Menu Tray, NoStandard
  115.     Menu Tray, Add, About, About
  116.     Menu Tray, Add
  117.     Menu Tray, Add, Default Menu, :Default Menu
  118.     Menu Tray, Add
  119.     Menu Tray, Add, Show System Files`tCtrl+Alt+S, ToggleSystemFilesStatus
  120.     Menu Tray, Add, Show File Extentions`tCtrl+Alt+E, ToggleFileExtStatus
  121.     Menu Tray, Add, Show Hidden Files`tCtrl+Alt+H, ToggleHiddenFilesStatus
  122.     Menu Tray, Default, Show Hidden Files`tCtrl+Alt+H
  123.  
  124.     ; If any of the menu items need to start off checked, take care of it here
  125.     if GetRegValue("Hidden") = 1
  126.         Menu Tray, Check, Show Hidden Files`tCtrl+Alt+H
  127.     if GetRegValue("ShowSuperHidden") = 1
  128.         Menu Tray, Check, Show System Files`tCtrl+Alt+S
  129.     if GetRegValue("HideFileExt") = 0
  130.         Menu Tray, Check, Show File Extentions`tCtrl+Alt+E
  131. Return
  132. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  133. cos_mousedrag_treshold := 20 ; pixels
  134. #IfWinNotActive ahk_class ConsoleWindowClass
  135. ~lButton::  ;<--   Left Mouse Button Selected File Folder Copy To Clipboard
  136.   MouseGetPos, cos_mousedrag_x, cos_mousedrag_y
  137.   keywait lbutton
  138.   mousegetpos, cos_mousedrag_x2, cos_mousedrag_y2
  139.   if (abs(cos_mousedrag_x2 - cos_mousedrag_x) > cos_mousedrag_treshold
  140.     or abs(cos_mousedrag_y2 - cos_mousedrag_y) > cos_mousedrag_treshold)
  141.   {
  142.     wingetclass cos_class, A
  143.     if (cos_class == "Emacs")
  144.       sendinput !w
  145.     else
  146.       sendinput ^c
  147.   }
  148.   return
  149.  #IfWinNotActive
  150. ;; clipx
  151. F1:: FileSetAttrib -HS, %Clipboard%  ;<-- F1 = Selected File Folder UnHide
  152. F2:: FileSetAttrib +HS, %Clipboard%  ;<-- F2 = Selected File Folder Super Hide
  153.  
  154. ;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  155. #R::Reload  ;<--  ~ Reload Script ~
  156. #S::Suspend ;<--  ~ Suspend Script ~
  157. #P::Pause   ;<--  ~ Pause Script ~
  158. #M::WinMinimize, ;<--  ~ Minimize Script ~
  159. ESC::ExitApp     ;<--  ~ Exit Script ~
  160.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement