I've had a chance to test the script on Windows 7.
To be able to browse system folders e.g. the Control Panel on Windows 7 you have to run the script, EnumDesktopGUI.au3, in the proper way. If you are using Windows 7 64 bit you have to run the script as a 64 bit program to be able to browse the system folders.
On Windows XP the generel look and appearance of the GUI is OK. There are problems on Windows 7: The menu bar doesn't look good. Disabled icons are looking very bad. The drop down menu of some of the buttons can erase parts of other controls. The grouping in the ListView of the items in Computer folder is looking very clumsy and the items seems to be mixed up in some way. Also for the Control Panel some items are mixed up and some items appears both as folders and files. I will try to find a solution to these issues.
Update #2: 2012-08-20
See first post dated 2012-04-19 below.
zip-files are attached to the bottom of the post.
Fixed an error which could lead to a crash immediately before GUI was closed down.
Data for the TreeView was deleted and memory freed while the TreeView still had focus.
_GUICtrlListView_RegisterSortCallBack() and related functions are used for sorting. The functions are modified to group files and folders, and to properly sort by size, by type and by time. The functions are provided in the file SortListView.au3.
It can be time consuming to sort a large number of files and folders. To prevent using time on both updating and sorting the ListView when a new folder is selected in the TreeView, the sorting mechanism is reset to default when a new folder is selected. The default sorting is the order of files and folders as provided in the "While $IEnumIDList.Next() ... WEnd" loops.
It can be a lengthy process to expand a large number of subfolders in the TreeView. To avoid this multiple subfolders can be grouped into a number of virtual folders with a specific number of subfolders in each virtual folder. The virtual folders are only created in the TreeView and ListView. Not on the disk.
Virtual folders will be used when the number of subfolders exceeds 300. The number of subfolders in each virtual folder is set to 100. These limits can be changed in the options. And the functionality can be disabled completely.
This is testet in a folder with 4000 subfolders and 100 pictures in each subfolder. Expanding the subfolders is much much faster when using virtual folders. In this example there will be created 40 virtual folders named "1 - 100", "101 - 200", ..., "3901 - 4000". Each virtual folder will contain 100 subfolders. But the 100 subfolders will not be expanded until you click a virtual folder. That means that in stead of creating 4000 subfolders at one time (which is extremely time consuming) there will be created 40 virtual folders, and when you click a virtual folder there will be created 100 subfolders at a time.
Right click menu in TreeView: Refresh
Added a SplitterBar control between the TreeView and ListView
Added grouping information to the ListView for My Computer folder
If an icon file EnumDesktopGUI.ico exists, this icon will be used for the GUI
Option to save GUI position and size on exit
Option to set TreeView startup folder
More info to the Details View
Fixed some minor issues
Update #1: 2012-04-25
In post #3 wraithdu pointed out that the built-in function ObjCreateInterface could be used in stead of AutoItObject.
An advantage in using ObjCreateInterface is that according to the helpfile you can use a struct as a parameter in the description string for the methods of the interface. It works in this example. No need for a lot of calls to DllStructGetPtr().
With ObjCreateInterface enumeration of a folder looks like this:
; The address that receives an IShellFolder Interface pointer $pParentFolder = GetParentFolder( ... ) ; Create an IDispatch-Object for the IShellFolder Interface $IShellFolder = ObjCreateInterface( $pParentFolder, $sIID_IShellFolder, $dtagIShellFolder ) ; $pIEnumIDList is the address that receives an IEnumIDList interface pointer of the enumeration object If $IShellFolder.EnumObjects( $NULL, BitOR( $SHCONTF_FOLDERS, $SHCONTF_INCLUDEHIDDEN ), $pIEnumIDList ) = $S_OK Then ; Create an IDispatch-Object for the IEnumIDList Interface $IEnumIDList = ObjCreateInterface( $pIEnumIDList, $sIID_IEnumIDList, $dtagIEnumIDList ) ; Enumerate the folders ; Param 1 [in] : Step value as in a For-loop While $IEnumIDList.Next( 1, $pidlRel, $iFetched ) = $S_OK ; Param 2 [out]: PIDL relative to parent folder $iFolders += 1 ; Param 3 [out]: 0 if no more PIDLs, 1 else ... ... ... WEnd EndIf
The zipfile below is updated with new au3-files (the 3 EnumDesktop-files) that uses ObjCreateInterface. This version is not depending on AutoItObject and AutoItObject.au3 is not included.
In this example ObjCreateInterface seems to be working flawlessly.
I've been looking at AutoItObject for some time. I've got inspiration for this example from a similar C++ example and from this thread http://www.autoitscript.com/forum/index.php?showtopic=123365.
The GUI in the example is a Windows Explorer Viewer with a TreeView and a ListView. The root of the TreeView is the Desktop. You can browse the Desktop by expanding the folders in the TreeView. Select a folder to show the subfolders and files in the ListView. Right click on an item in the ListView to get file properties. Right click in the free area of the ListView to print a list of item names. Double click or press Enter on an item in the ListView to open a file or execute a program.
With AutoItObject a folder doesn't have to be a file system folder. It can be any folder in the Desktop e.g. the Control Panel. The Desktop in this case means the root of the Shell's namespace.
To enumerate a folder using AutoItObject you use code like this:
; The address that receives an IShellFolder Interface pointer $pParentFolder = GetParentFolder( ... ) ; Create an IDispatch-Object for the IShellFolder Interface $IShellFolder = _AutoItObject_WrapperCreate( $pParentFolder, $dtagIShellFolder ) ; The address that receives an IEnumIDList interface pointer of the enumeration object $aRet = $IShellFolder.EnumObjects( $NULL, BitOR( $SHCONTF_FOLDERS, $SHCONTF_INCLUDEHIDDEN ), 0 ) If $aRet = $S_OK Then $pIEnumIDList = $aRet ; Create an IDispatch-Object for the IEnumIDList Interface $IEnumIDList = _AutoItObject_WrapperCreate( $pIEnumIDList, $dtagIEnumIDList ) ; Enumerate the folders $aRet = $IEnumIDList.Next( 1, 0, 0 ) ; Param 1 [in] : Step value as in a For-loop While $aRet ; Param 2 [out]: PIDL relative to parent folder $iFolders += 1 ; Param 3 [out]: 0 if no more PIDLs, 1 else ... ... ... $aRet = $IEnumIDList.Next( 1, 0, 0 ) WEnd EndIf
Enumeration of a folder in this way uses PIDLs (pointers to ITEMIDLIST structures) in stead of file and folder names. See http://msdn.microsoft.com/en-us/library/windows/desktop/cc144090(v=vs.85).aspx.
The zipfile below contains a number of files:
- EnumDesktopConsts.au3 - definitions and declarations
- EnumDesktopFuncs.au3 - functions for the enumerations
- EnumDesktopGUI.au3 - the GUI, run this file
- Functions.au3 - different functions
- GetIcon.au3 - icon functions
- Windows.au3 - child windows for options and info
- StringSize.au3 - by Melba23, see http://www.autoitscript.com/forum/index.php?showtopic=114034
- HourglassOff.au3 - turn hourglass off, see below
- res\ - 4 icons and WSP.dll by Yashied, see http://www.autoitscript.com/forum/index.php?showtopic=83621 post #16
The central file in the example is EnumDesktopFuncs.au3. The most important functions in the file are
- GetParentFolder() - returns an IShellFolder Interface pointer to the parent folder
- EnumTreeViewObjects() - expands the folders of the parent folder in the TreeView
- EnumListViewObjects() - shows the folders and files in the ListView for the parent folder
- InvokeCommand() - opens a file or runs a program when an item in the ListView is activated
If the script fails for some reason and you are left with an hourglass cursor, then run HourglassOff.au3 to get the normal cursor back.
Run EnumDesktopGUI.au3 in the zipfile.
Testet on XP SP3.
The zip-files can be opened with 7-Zip.
2012-04-19: Implemented with AutoItObject
EnumDesktop.zip 33.56K 296 downloads
Update #2 2012-08-20: Implemented with ObjCreateInterface() (no need for AutoItObject, not included)
EnumDesktop.zip 65.5K 188 downloads
Edited by LarsJ, 22 August 2012 - 06:26 AM.