返回列表 发帖

[原创] VBS修改文件夹窗口查看方式、排序方式、分组依据

举个栗子:
Dim Shell
Set Shell = CreateObject("Shell.Application")
For Each window In Shell.Windows()
   If LCase(Right(window.FullName,13)) = "\explorer.exe" Then
   
      window.Document.CurrentViewMode = 1
      '设置查看方式为缩略图
      
      window.Document.IconSize = 48
      '设置图标尺寸为 48
      
      window.Document.SortColumns = "prop:-System.DateModified;"
      '设置排序方式为按修改日期逆序排列
      
      window.Document.GroupBy = "System.DateModified"
      '设置分组依据为修改日期
      
      window.Document.SelectItemRelative(0)
      '选中一个比较帅的文件
      
      MsgBox  "标题: " & window.LocationName & vbCrLf &_
             "路径: " & Replace(Mid(window.LocationURL,9),"/","\") & vbCrLf &_
            "选中: " & window.Document.SelectedItems().Count & " 个文件/文件夹"& vbCrLf_
      Exit For
   End If
NextCOPY
3

评分人数

本帖最后由 CrLf 于 2014-11-26 20:57 编辑

window.Document 下 CurrentViewMode、SortColumns、GroupBy 的值见下表(不完全,事实上我也不知道去哪里查完整的):


Document.CurrentViewMode
1、2、5、7 缩略图
        缩略图状态下可使用 Document.IconSize 设置任意大小
        16 小图标
        48 中等图标
        96 大图标
        256 超大图标
3、列表
4、详细信息
6、平铺
8、内容


Document.SortColumns(- 为逆序,如 prop:System.ItemNameDisplay; 和 prop:-System.ItemNameDisplay; 是相反的顺序)
prop:System.ItemNameDisplay;
名称
prop:System.DateModified;
修改日期
prop:System.ItemTypeText;System.ItemNameDisplay;
类型
prop:System.Size;
大小


Document.GroupBy
System.ItemNameDisplay
名称
System.DateModified
修改日期
System.ItemTypeText
类型
System.Size
大小
System.Null
(无)

TOP

返回列表