6

I would like to make use of a hotkey to toggle the Show hidden files and folders setting. I want to use it on both windowsXp and Windows7.

Here is what I got so far:

#h::
RegRead, Showall_Status, HKEY_LOCAL_MACHINE, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\Hidden\SHOWALL, CheckedValue, 
If Showall_Status = 0
RegWrite, REG_DWORD, HKEY_LOCAL_MACHINE, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\Hidden\SHOWALL, CheckedValue, 1 
Else
RegWrite, REG_DWORD, HKEY_LOCAL_MACHINE, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\Hidden\SHOWALL, CheckedValue, 0
Return

Problem is when I run the script it simply does nothing. Not sure what I am missing.

Kenster
  • 7,483
  • 2
  • 32
  • 44
Oq.
  • 121
  • 1
  • 7
  • Do you want to toggle the **Show hidden files and folders** setting, or toggle the hidden bit of a file/folder? – John T Mar 11 '10 at 06:28
  • I want to toggle the Show hidden files and folders setting. – Oq. Mar 11 '10 at 06:34
  • 1
    does it require some kind of refresh to the folder view (like f5)? – Matthew Lock Mar 11 '10 at 06:51
  • Never hurts to include it in the script would it? Goo point though @Matthew – Ivo Flipse Mar 11 '10 at 06:53
  • I suppose it does. I just tried adding- Send, {F5} - at the end. Yet it still just does nothing. I am on WinXP at the moment. – Oq. Mar 11 '10 at 07:04
  • Usually when you make a change in the registry like that you have to terminate and restart explorer.exe and it will re-read the registry values. Perhaps there is some way to send a signal to explorer to get it to re-read? – Zoredache Mar 11 '10 at 08:38
  • See (http://www.autoitscript.com/forum/index.php?showtopic=20695) – Zoredache Mar 11 '10 at 08:42
  • I use StExBar for quickly toggling hidden/not hidden status: http://tools.tortoisesvn.net/StExBar – mindless.panda Mar 11 '10 at 14:01

2 Answers2

4

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
Oq.
  • 121
  • 1
  • 7
3

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
Ajith Antony
  • 195
  • 3
  • thanks will test it. For Win7 I used "Send {F5}", and it worked. For XP I used "PostMessage, 0x111, 28931,,, A" – Oq. Jan 04 '11 at 06:29