How to write an autohotkey script to toggle the Show hidden files and folders setting?
Solution 1:
Ok, the problem was the regkey, this one works.
;------------------------------------------------------------------------
; Show hidden folders and files in Windows XP
;------------------------------------------------------------------------
; User Key: [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
; Value Name: Hidden
; Data Type: REG_DWORD (DWORD Value)
; Value Data: (1 = show hidden, 2 = do not show)
#h::
RegRead, ShowHidden_Status, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden
if ShowHidden_Status = 2
RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden, 1
Else
RegWrite, REG_DWORD, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, Hidden, 2
WinGetClass, CabinetWClass
PostMessage, 0x111, 28931,,, A
Return
Solution 2:
I don't have enough points to reply, so I'm posting this as another answer...
The explorer won't refresh with the above PostMessage
in win7. So you'll want both of these to work in XP and win7.
http://www.autohotkey.com/forum/topic1204.html
PostMessage, 0x111, 28931,,, A
PostMessage, 0x111, 41504,,, A