Sign in to follow this  
Followers 0
inferno123

Change Folders View by script

11 posts in this topic

Greetings Everyone

I would like to share a script that I have written recently.

Scrtips applies view to allfolders in Windows XP Shell. View is chosen by running script with paramter. Parameter is a name of the view e.g Details, Icons

It works on Windows XP fine. I have not tested it on Vista.

Here is the code

Region;**** Directives created by AutoIt3Wrapper_GUI ****

#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
$oWshShell = ObjCreate("WScript.Shell")
Const $conAllFolders = "HKCU\Software\Microsoft\Windows\ShellNoRoam\Bags\AllFolders" 
Const $ThumbView = "{8BEBB290-52D0-11D0-B7F4-00C04FD706EC}" 
Const $TileView = "{65F125E5-7BE1-4810-BA9D-D271C8432CE3}" 
Const $IconsView = "{0057D0E0-3573-11CF-AE69-08002B2E1262}" 
Const $ListView = "{0E1FA5E0-3573-11CF-AE69-08002B2E1262}" 
Const $DetailsView = "{137E7700-3573-11CF-AE69-08002B2E1262}" 
Const $FilmstripView = "{8EEFA624-D1E9-445B-94B7-74FBCE2EA11A}" 
Global $sPrefix, $sPrefix1, $sPrefix2


If $CMDLINE[0] = 1 Then
    
    If $CMDLINE[1] = "Thumbnails"  Then
        $VID_ID = $ThumbView
    ElseIf $CMDLINE[1] = "Tiles"  Then
        $VID_ID = $TileView
    ElseIf $CMDLINE[1] = "Icons"  Then
        $VID_ID = $IconsView
    ElseIf $CMDLINE[1] = "List"  Then
        $VID_ID = $ListView
    ElseIf $CMDLINE[1] = "Details"  Then
        $VID_ID = $DetailsView
    ElseIf $CMDLINE[1] = "Filmstrip"  Then
        $VID_ID = $FilmstripView
    EndIf

    RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\Bags")
    RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Windows\ShellNoRoam\BagMRU")
    SetTinyOpen()
    Sleep(1000)
    Restore_normal_size()
Else
    Exit 2
EndIf


Func SetTinyOpen()

    $object = ObjCreate("htmlfile")
    With $object.Parentwindow.Screen
        $sPrefix = "WinPos" & .width & "x" & .height & "(1)." 
    EndWith
    $object = ObjCreate("htmlfile")
    With $object.Parentwindow.Screen
        $sPrefix1 = "MaxPos" & .width & "x" & .height & "(1)." 
    EndWith
    With $object.Parentwindow.Screen
        $sPrefix2 = "MinPos" & .width & "x" & .height & "(1)." 
    EndWith
    
    $oWshShell.RegWrite($conAllFolders & "\Shell\Address", 0xffffffff, "REG_DWORD")
    $oWshShell.RegWrite($conAllFolders & "\Shell\Buttons", 0xffffffff, "REG_DWORD")
    $oWshShell.RegWrite($conAllFolders & "\Shell\Col", 0xffffffff, "REG_DWORD")
    $oWshShell.RegWrite($conAllFolders & "\Shell\FFlags", 1, "REG_DWORD")
    $oWshShell.RegWrite($conAllFolders & "\Shell\FolderType", "MyDocuments", "REG_SZ")
    $oWshShell.RegWrite($conAllFolders & "\Shell\HotKey", 0, "REG_DWORD")
    $oWshShell.RegWrite($conAllFolders & "\Shell\Links", 0, "REG_DWORD")
    $oWshShell.RegWrite($conAllFolders & "\Shell\" & $sPrefix1 & "x", 0xffffffff, "REG_DWORD")
    $oWshShell.RegWrite($conAllFolders & "\Shell\" & $sPrefix1 & "y", 0xffffffff, "REG_DWORD")
    $oWshShell.RegWrite($conAllFolders & "\Shell\" & $sPrefix2 & "x", 0xffffffff, "REG_DWORD")
    $oWshShell.RegWrite($conAllFolders & "\Shell\" & $sPrefix2 & "y", 0xffffffff, "REG_DWORD")
    $oWshShell.RegWrite($conAllFolders & "\Shell\Mode", 6, "REG_DWORD")
    $oWshShell.RegWrite($conAllFolders & "\Shell\ShowCmd", 1, "REG_DWORD")
    $oWshShell.RegWrite($conAllFolders & "\Shell\Sort", 0, "REG_DWORD")
    $oWshShell.RegWrite($conAllFolders & "\Shell\SortDir", 1, "REG_DWORD")
    $oWshShell.RegWrite($conAllFolders & "\Shell\Vid", $VID_ID, "REG_SZ")
    $oWshShell.RegWrite($conAllFolders & "\Shell\WFlags", 0, "REG_DWORD")
    $oWshShell.RegWrite($conAllFolders & "\Shell\" & $sPrefix & "bottom", 5, "REG_DWORD")
    $oWshShell.RegWrite($conAllFolders & "\Shell\" & $sPrefix & "left", 0, "REG_DWORD")
    $oWshShell.RegWrite($conAllFolders & "\Shell\" & $sPrefix & "right", 5, "REG_DWORD")
    $oWshShell.RegWrite($conAllFolders & "\Shell\" & $sPrefix & "top", 0, "REG_DWORD")
    
        
EndFunc  ;==>SetTinyOpen


Func Restore_normal_size()

    $oWshShell.RegWrite($conAllFolders & "\Shell\" & $sPrefix & "bottom", 570, "REG_DWORD")
    $oWshShell.RegWrite($conAllFolders & "\Shell\" & $sPrefix & "left", 0, "REG_DWORD")
    $oWshShell.RegWrite($conAllFolders & "\Shell\" & $sPrefix & "right", 798, "REG_DWORD")
    $oWshShell.RegWrite($conAllFolders & "\Shell\" & $sPrefix & "top", 2, "REG_DWORD")

EndFunc  ;==>Restore_normal_size

Share this post


Link to post
Share on other sites



so maybe you explain how to use your code? An example please.

Lets say I want to list only all folders & subfolders on "D:\myfolder\" .


My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

This script does not list folders.

It does the same as if you changed the view to e.g. Details and then went to Tools>Folder options>View>Apply to Allfolders.

I searched the web for similar script for almost a week and found nothing. That is why I decided publish it so that someone can benfit from it.

Edited by inferno123

Share this post


Link to post
Share on other sites

your script does not have a single comment. I dont know what will happen if I run your script ( I see that it writes something to registry & now im even more afraid to run it )

So How can i change only D:\myfolder\folder1\ to list wiew?


My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites

your script does not have a single comment. I dont know what will happen if I run your script ( I see that it writes something to registry & now im even more afraid to run it )

So How can i change only D:\myfolder\folder1\ to list wiew?

its a global option... as it states.. "Tools>Folder options>View>Apply to Allfolders"

If your afraid to use it or unfamiliar with changing pc settings, dont use it.


Who needs puzzles when we have AutoIt!!

Share this post


Link to post
Share on other sites

ok i installed new WinXP on my virtual machine & after i run the script, nothing happens.

I still dont understand how to use this thing, what should happen after i run this code?

Should I put the compiled exe inside a folder & run it from a folder or from desktop? (I tried both & nothing happens)

Note: if I open a folder change it to list wiew , go to Tools>Folder options>View> & click on Apply to Allfolders the changes do take place.


My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites

This script requires one command line parameter to run

Paramter represents a view that you want to apply to all folders

You compile the script and run it from Start>RUn>ScriptName <VIEW TYPE> E.G APPLYVIEW.EXE DETAILS

As far as applying view to a single folder is concerned is a bit more complex. The folder identifier is written in BAGMRU key.

Please find example code with comments that applies view to Printers and faxes.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****

#AutoIt3Wrapper_icon=..\..\..\..\Documents and Settings\ypx8157\My Documents\Icons\config.ico

#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

Const $conFolder = "HKCU\Software\Microsoft\Windows\ShellNoRoam\Bags\1"

Const $conFolderType = "HKCU\Software\Microsoft\Windows\ShellNoRoam\BagMRU"

Const $ThumbView = "{8BEBB290-52D0-11D0-B7F4-00C04FD706EC}"

Const $TileView = "{65F125E5-7BE1-4810-BA9D-D271C8432CE3}"

Const $IconsView = "{0057D0E0-3573-11CF-AE69-08002B2E1262}"

Const $ListView = "{0E1FA5E0-3573-11CF-AE69-08002B2E1262}"

Const $DetailsView = "{137E7700-3573-11CF-AE69-08002B2E1262}"

Const $FilmstripView = "{8EEFA624-D1E9-445B-94B7-74FBCE2EA11A}"

Global $sPrefix, $sPrefix1, $sPrefix2

;Executable part

If $CMDLINE[0] = 1 Then

If $CMDLINE[1] = "Thumbnails" Then

$VID_ID = $ThumbView

ElseIf $CMDLINE[1] = "Tiles" Then

$VID_ID = $TileView

ElseIf $CMDLINE[1] = "Icons" Then

$VID_ID = $IconsView

ElseIf $CMDLINE[1] = "List" Then

$VID_ID = $ListView

ElseIf $CMDLINE[1] = "Details" Then

$VID_ID = $DetailsView

ElseIf $CMDLINE[1] = "Filmstrip" Then

$VID_ID = $FilmstripView

EndIf

SetTinyOpen()

Sleep(1000)

Restore_normal_size()

Else

Exit 2 ; 2 is returned if no parameter is given

EndIf

;======================================================

Func SetTinyOpen()

$oWshShell = ObjCreate("WScript.Shell")

$object = ObjCreate("htmlfile")

With $object.Parentwindow.Screen

$sPrefix = "WinPos" & .width & "x" & .height & "(1)."

EndWith

$object = ObjCreate("htmlfile")

With $object.Parentwindow.Screen

$sPrefix1 = "MaxPos" & .width & "x" & .height & "(1)."

EndWith

With $object.Parentwindow.Screen

$sPrefix2 = "MinPos" & .width & "x" & .height & "(1)."

EndWith

;BagMRU Specific to "Printers and Faxes". These reg keys actually make Printer and Faxes the target folder for view change

RegWrite($conFolderType & "\0" ,"0","REG_BINARY","14002e002020ec21ea3a6910a2dd08002b30309d0000")

RegWrite($conFolderType & "\0" ,"MRUListEx","REG_BINARY","00000000ffffffff")

RegWrite($conFolderType & "\0\0" ,"0","REG_BINARY","1400700080a22722ea3a6910a2de08002b30309d0000")

RegWrite($conFolderType & "\0\0" ,"MRUListEx","REG_BINARY","00000000ffffffff")

RegWrite($conFolderType & "\0\0\0" ,"MRUListEx","REG_BINARY","ffffffff")

RegWrite($conFolderType & "\0\0\0" ,"NodeSlot","REG_DWORD","00000001")

;===================================================================================================

===================

;General info required to save the folder view

$oWshShell.RegWrite($conFolder & "\Shell\Address", 0xffffffff, "REG_DWORD")

$oWshShell.RegWrite($conFolder & "\Shell\Buttons", 0xffffffff, "REG_DWORD")

$oWshShell.RegWrite($conFolder & "\Shell\Col", 0xffffffff, "REG_DWORD")

$oWshShell.RegWrite($conFolder & "\Shell\FFlags", 1, "REG_DWORD")

$oWshShell.RegWrite($conFolder & "\Shell\FolderType", "MyDocuments", "REG_SZ")

$oWshShell.RegWrite($conFolder & "\Shell\HotKey", 0, "REG_DWORD")

$oWshShell.RegWrite($conFolder & "\Shell\Links", 0, "REG_DWORD")

$oWshShell.RegWrite($conFolder & "\Shell\" & $sPrefix1 & "x", 0xffffffff, "REG_DWORD")

$oWshShell.RegWrite($conFolder & "\Shell\" & $sPrefix1 & "y", 0xffffffff, "REG_DWORD")

$oWshShell.RegWrite($conFolder & "\Shell\" & $sPrefix2 & "x", 0xffffffff, "REG_DWORD")

$oWshShell.RegWrite($conFolder & "\Shell\" & $sPrefix2 & "y", 0xffffffff, "REG_DWORD")

$oWshShell.RegWrite($conFolder & "\Shell\Mode", 6, "REG_DWORD")

$oWshShell.RegWrite($conFolder & "\Shell\ShowCmd", 1, "REG_DWORD")

$oWshShell.RegWrite($conFolder & "\Shell\Sort", 0, "REG_DWORD")

$oWshShell.RegWrite($conFolder & "\Shell\SortDir", 1, "REG_DWORD")

$oWshShell.RegWrite($conFolder & "\Shell\Vid", $VID_ID, "REG_SZ")

$oWshShell.RegWrite($conFolder & "\Shell\WFlags", 0, "REG_DWORD")

$oWshShell.RegWrite($conFolder & "\Shell\" & $sPrefix & "bottom", 5, "REG_DWORD")

$oWshShell.RegWrite($conFolder & "\Shell\" & $sPrefix & "left", 0, "REG_DWORD")

$oWshShell.RegWrite($conFolder & "\Shell\" & $sPrefix & "right", 5, "REG_DWORD")

$oWshShell.RegWrite($conFolder & "\Shell\" & $sPrefix & "top", 0, "REG_DWORD")

;===================================================================================================

=====================

EndFunc ;==>SetTinyOpen

Func Restore_normal_size()

$oWshShell = ObjCreate("WScript.Shell")

$oWshShell.RegWrite($conFolder & "\Shell\" & $sPrefix & "bottom", 570, "REG_DWORD")

$oWshShell.RegWrite($conFolder & "\Shell\" & $sPrefix & "left", 0, "REG_DWORD")

$oWshShell.RegWrite($conFolder & "\Shell\" & $sPrefix & "right", 798, "REG_DWORD")

$oWshShell.RegWrite($conFolder & "\Shell\" & $sPrefix & "top", 2, "REG_DWORD")

EndFunc ;==>Restore_normal_size

So if you would like to apply a view to a different folder you would need to extract information from registry about this folder for the following keys

RegWrite($conFolderType & "\0" ,"0","REG_BINARY","14002e002020ec21ea3a6910a2dd08002b30309d0000")

RegWrite($conFolderType & "\0" ,"MRUListEx","REG_BINARY","00000000ffffffff")

RegWrite($conFolderType & "\0\0" ,"0","REG_BINARY","1400700080a22722ea3a6910a2de08002b30309d0000")

RegWrite($conFolderType & "\0\0" ,"MRUListEx","REG_BINARY","00000000ffffffff")

RegWrite($conFolderType & "\0\0\0" ,"MRUListEx","REG_BINARY","ffffffff")

Share this post


Link to post
Share on other sites

well thank you for ur reply, but I still dont get what should I replace with what to list my D:\myfolder\folder1\ & I also have no idea, how to find my folder in registry(but this is not autoit mater anymore soo I give up on this. Just too complicated. :)


My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites

Inferno,

I think your script is a great idea. Came across it trying to figure out how to use the $CmdLine in AutoIT.

I have tried to package an app to do that with little success.

I copied your script into AdminScriptEditor, saved it and compiled it but I get this when I run:

Line -1

Cannot Assign Values to Constants.

Any Ideas. My tests also got me the same errors.

Thanks for any help.

Mike

Share this post


Link to post
Share on other sites

I have looked at this problem before, but din't get it right, I will try if it works on Win 2000 as well

Share this post


Link to post
Share on other sites

Seems to work in a different way in Windows 2000, but that is typical Microsoft

Share this post


Link to post
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
Sign in to follow this  
Followers 0