You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用AutoHotkey修改文件资源管理器的文件分组模式并解决报错

修复方案

报错原因

  • 执行顺序错误:原代码先设置分组规则再切换视图模式,若当前资源管理器处于不支持分组的视图(如列表、小图标模式),就会触发Element not found错误
  • 赋值格式兼容性差:部分Windows系统对GroupBy属性的prop:前缀、末尾分号的写法适配性不足

修复后完整脚本

#If WinActive("ahk_class CabinetWClass") || WinActive("ahk_class ExploreWClass")
q:: ;资源管理器:按修改日期倒序排序 + 按文件类型分组
WinGet, hWnd, ID, A
for oWin in ComObjCreate("Shell.Application").Windows
{
    if (oWin.HWND = hWnd)
    {
        MsgBox, % oWin.Document.GroupBy
        oWin.Document.CurrentViewMode := 4 ; 先切换到支持分组的详细信息视图
        oWin.Document.GroupBy := "System.ItemTypeText" ; 按文件类型分组
        oWin.Document.SortColumns := "prop:-System.DateModified;" ; 按修改日期倒序(最新在前)
        break
    }
}
oWin := ""
return
#If

注意事项

  • 如果运行仍报错,尝试以管理员权限启动AutoHotkey再运行脚本即可
  • 若需要切换其他分组维度,替换System.ItemTypeText为对应属性名即可,比如按修改日期分组可改为System.DateModified

内容的提问来源于stack exchange,提问作者daani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.05 12:24:03