Jump to content

Toggle hidden files and folders on and off?


Recommended Posts

Is there a control or command that will allow us to toggle showing or hiding files, as seen in Windows Explorer folder options where we can tick to hide or show hidden files/folders? I found again just references to doing things reglated to GUIs in the help file and got a whole bunch of other things when searching the forum. Thanks. :)

p.s., my internet has been down since Friday so I'll not be able to read this post and answer again until tomorrow morning when I get back to work. Thanks much!!! <g>

Edited by Diana (Cda)
Link to comment
Share on other sites

Hi,

Check this topic.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Hi,

Check this topic.

Boo I was making one but took too long :P I couldn't figure out a way to refresh the explorer windows! haha, thanks for that post! :)

This is what I came up with:

Func ToggleHiddenFiles($ToggleHidden=1,$ToggleSuperHidden=1,$ToggleFileExt=0)
    $RegKey="HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
    $Hidden=RegRead($RegKey,"Hidden")
    $HideFileExt=RegRead($RegKey,"HideFileExt")
    $ShowSuperHidden=RegRead($RegKey,"ShowSuperHidden")

    If $ToggleHidden=1 Then
        If $Hidden=1 Then
            RegWrite($RegKey,"Hidden","REG_DWORD",2);=2 hide,=1 show
        Else
            RegWrite($RegKey,"Hidden","REG_DWORD",1);=2 hide,=1 show
        EndIf
    EndIf
    If $ToggleSuperHidden=1 Then
        If $ShowSuperHidden=1 Then
            RegWrite($RegKey,"ShowSuperHidden","REG_DWORD",0);=0 hide, 1 show
        Else
            RegWrite($RegKey,"ShowSuperHidden","REG_DWORD",1);=0 hide, 1 show
        EndIf
    EndIf
    If $ToggleFileExt=1 Then
        If $HideFileExt=1 Then
            RegWrite($RegKey,"HideFileExt","REG_DWORD",0);=0 show, 1 hide
        Else
            RegWrite($RegKey,"HideFileExt","REG_DWORD",1);=0 show, 1 hide
        EndIf
    EndIf
    ;Get explorer windows:
    Opt("WinTitleMatchMode", 4)
    $WinList = WinList("classname=CabinetWClass")
    If IsArray($WinList) Then
        Local $WinListArr[$WinList[0][0]+1]
        For $iW = 1 To $WinList[0][0]
            $WinListArr[$iW] = $WinList[$iW][0]
        Next
        $WinListArr[0] = $WinList[0][0]
;~         Return $WinListArr
    Else
;~         Return ""
    EndIf
    ;Update explorers:  
    $WinExpListArr =$WinListArr
    If IsArray($WinExpListArr) Then
        For $iWin = 1 To $WinExpListArr[0]
            $GetWinState = WinGetState($WinExpListArr[$iWin])
            $Hwnd = WinGetHandle($WinExpListArr[$iWin])
            DllCall("user32.dll", "long", "SendMessage", "hwnd", $hWnd, "int", 0x111, "int", 28931, "int", 0)
        Next
    EndIf
    
    $Hwnd = WinGetHandle("classname=Progman")
    DllCall("user32.dll", "long", "SendMessage", "hwnd", $hWnd, "int", 0x111, "int", 28931, "int", 0)
    
    
    
    
EndFunc

This is how you use it:

ToggleHiddenFiles([ToggleHidden=1,[ToggleSuperHidden=1,[ToggleHideFileExtensios=0]]])

The three parameters are optional. Leaving them blank will toggle:

  • *Hidden files
  • *SuperHidden files
For example, let's say you just want to toggle hidden file extensions, then you just use:

ToggleHiddenFiles(0,0,1)

If you just want to toggle hidden system files (superhiddenfiles) then use:

ToggleHiddenFiles(0,1,0)

Thanks MsCreatoR ;)

Edited by Nahuel
Link to comment
Share on other sites

Nice work Nahuel

Now can you figure out how to show the super-super-super hidden files.

I always run with super-hidden enabled but I have at least 2 files that will not show regardless.

I know they exist because I can Run or ShellExecute them an I looked in the registry to check the paths and they are right where I knew they were.

BTW it would be a good idea to make sure that the values are the same for both before you toggle.

t's no good having The value of Hidden = 0 and then the value of SuperHidden = 1

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Nice work Nahuel

Now can you figure out how to show the super-super-super hidden files.

I always run with super-hidden enabled but I have at least 2 files that will not show regardless.

I know they exist because I can Run or ShellExecute them an I looked in the registry to check the paths and they are right where I knew they were.

Well, if you go to folder options, then view and then Hide protected operating system files (Recommended) . You'll see that it modifies the value of ShowSuperHidden in this key:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced

However, there's another valuename in that key called SuperHidden. I tried modifying it but it didn't seem to do anything since I don't know where those super-super-hidden files are... maybe you can try that, cos I didn't find anything else...

BTW it would be a good idea to make sure that the values are the same for both before you toggle.

t's no good having The value of Hidden = 0 and then the value of SuperHidden = 1

I thought of that, which is why I gave the function optional parameters. If I added that to the function and your explorer has hidden=0 and SuperHidden=1 then the function wouldn't do anything... So just make sure you are using the right parameters :)
Link to comment
Share on other sites

Maybe this?

If $ToggleSuperHidden=1 Then
        If $ShowSuperHidden=1 Then
            RegWrite($RegKey,"ShowSuperHidden","REG_DWORD",0);=0 hide, 1 show
        Else
            If $Hidden =2 Then 
               RegWrite($RegKey,"Hidden","REG_DWORD",1)
               $Hidden = 1
            EndIf
            RegWrite($RegKey,"ShowSuperHidden","REG_DWORD",1);=0 hide, 1 show
        EndIf
    EndIf

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

  • 7 months later...

@Nahuel

Nice Script , but the only way this script works for me you must add a few lines.

;in the Update explorers area:  

Local $ah_WinExpListArr2 = WinList("classname=ExploreWClass")
If $ah_WinExpListArr2[0][0] > 0 Then
    For $i = 1 To $ah_WinExpListArr2[0][0] Step 1
        DllCall("user32.dll", "long", "SendMessage", "hwnd", $ah_WinExpListArr2[$i][1], "int", 0x111, "int", 28931, "int", 0)
    Next
EndIf

Patric

Edited by priZma
Link to comment
Share on other sites

FileSetAttrib ( "file pattern", "+-RASHNOT" [, recurse] )

Parameters

file pattern File(s) to change, e.g. C:\*.au3, C:\Dir

+-RASHNOT Attribute(s) to set/clear. e.g. "+A", "+RA-SH"

recurse [optional] If this is set to 1, then directories are recursed into. Default is 0 (no recursion).

Return Value

Success: Returns 1.

Failure: Returns 0 if encountered any errors.

Remarks

The file pattern cannot contain spaces!

The attributes that can be modified with the function are + or -:

"R" = READONLY

"A" = ARCHIVE

"S" = SYSTEM

"H" = HIDDEN

"N" = NORMAL

"O" = OFFLINE

"T" = TEMPORARY

(Note that you cannot set the compressed/directory attributes with this function.)

Link to comment
Share on other sites

The registry sub keys for HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced are:

Hidden

SuperHidden

ShowSuperHidden

HideFileExt

The default values are 2,0,0,1 respectively. To show everything the values would need to be set to 1,1,1,0 respectively.

A more complete function would be:

Func ToggleHiddenFiles($ToggleHidden=1,$ToggleSuperHidden=1,$ToggleShowSuperHidden=1,$ToggleFileExt=0)
    $RegKey="HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
    $Hidden=RegRead($RegKey,"Hidden")
    $SuperHidden=RegRead($RegKey,"SuperHidden")
    $ShowSuperHidden=RegRead($RegKey,"ShowSuperHidden")
    $HideFileExt=RegRead($RegKey,"HideFileExt")

    If $ToggleHidden=1 Then
        If $Hidden=1 Then
            RegWrite($RegKey,"Hidden","REG_DWORD",2);=2 hide,=1 show
        Else
            RegWrite($RegKey,"Hidden","REG_DWORD",1);=2 hide,=1 show
        EndIf
    EndIf
    If $ToggleSuperHidden=1 Then
        If $SuperHidden=1 Then
            RegWrite($RegKey,"SuperHidden","REG_DWORD",0);=0 hide, 1 show
        Else
            RegWrite($RegKey,"SuperHidden","REG_DWORD",1);=0 hide, 1 show
        EndIf
    EndIf
    If $ToggleShowSuperHidden=1 Then
        If $ShowSuperHidden=1 Then
            RegWrite($RegKey,"ShowSuperHidden","REG_DWORD",0);=0 hide, 1 show
        Else
            RegWrite($RegKey,"ShowSuperHidden","REG_DWORD",1);=0 hide, 1 show
        EndIf
    EndIf
    If $ToggleFileExt=1 Then
        If $HideFileExt=1 Then
            RegWrite($RegKey,"HideFileExt","REG_DWORD",0);=0 show, 1 hide
        Else
            RegWrite($RegKey,"HideFileExt","REG_DWORD",1);=0 show, 1 hide
        EndIf
    EndIf
   ;Get explorer windows:
    Opt("WinTitleMatchMode", 4)
    $WinList = WinList("classname=CabinetWClass")
    If IsArray($WinList) Then
        Local $WinListArr[$WinList[0][0]+1]
        For $iW = 1 To $WinList[0][0]
            $WinListArr[$iW] = $WinList[$iW][0]
        Next
        $WinListArr[0] = $WinList[0][0]
;~       Return $WinListArr
    Else
;~       Return ""
    EndIf
   ;Update explorers: 
    $WinExpListArr =$WinListArr
    If IsArray($WinExpListArr) Then
        For $iWin = 1 To $WinExpListArr[0]
            $GetWinState = WinGetState($WinExpListArr[$iWin])
            $Hwnd = WinGetHandle($WinExpListArr[$iWin])
            DllCall("user32.dll", "long", "SendMessage", "hwnd", $hWnd, "int", 0x111, "int", 28931, "int", 0)
        Next
    EndIf
   
    $Hwnd = WinGetHandle("classname=Progman")
    DllCall("user32.dll", "long", "SendMessage", "hwnd", $hWnd, "int", 0x111, "int", 28931, "int", 0)   
EndFunc

Usage:

Toggle Show All:

ToggleHiddenFiles(1,1,1,0)

Toggle Hide All:

ToggleHiddenFiles(2,0,0,1)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...