【问题标题】:Ahk Script to find in the current folder a file or a folder with the latest change?Ahk 脚本在当前文件夹中查找具有最新更改的文件或文件夹?
【发布时间】:2019-07-08 03:06:30
【问题描述】:

我经常将文件从 Chrome 保存到“下载”文件夹或“我的文档”文件夹。 您必须稍后在文件夹中查找这些文件。告诉我是否有可能以某种方式使用 ahk 脚本使其更方便。例如,通过按 F3,当前文件夹中的最后一个文件或文件夹会突出显示。如何实施。请帮帮我,我是新人

【问题讨论】:

    标签: autohotkey hotkeys


    【解决方案1】:
    F3::
        SetTitleMatchMode, 2
        File := "" ; empty variable
        Time := ""
        Loop, Files, %A_MyDocuments%\Downloads\*.*, DF ; include files and folders
        {
            If (A_LoopFileTimeModified >= Time)
            {
                Time := A_LoopFileTimeModified        ; the time the file/folder was last modified
                File := A_LoopFileFullPath            ; the path and name of the file/folder currently retrieved
            }
        }
        ; MsgBox, Last modified file in %A_MyDocuments%\Downloads is`n`n"%File%"
        IfWinNotExist Downloads ahk_class CabinetWClass
            Run % "explorer.exe /select," . File      ; open containing folder and highlight this file/folder
        else
        {
            SplitPath, File, name
            MsgBox, Last modified file = "%name%"
            WinActivate, Downloads ahk_class CabinetWClass
            WinWaitActive, Downloads ahk_class CabinetWClass
            ; SelectExplorerItem(name) ; or:
            SendInput, %name%
        }
        return
    
    SelectExplorerItem(ItemName) { ; selects the specified item in the active explorer window, if present
       ; SelectItem -> msdn.microsoft.com/en-us/library/bb774047(v=vs.85).aspx
       Window := ""
       Static Shell := ComObjCreate("Shell.Application")
       For Window In Shell.Windows
        try  IfWinActive, % "ahk_id " window.HWND
             If (Item := Window.Document.Folder.ParseName(ItemName))
                Window.Document.SelectItem(Item, 29)
       Return (Item ? True : False)
    }
    

    https://autohotkey.com/docs/commands/LoopFile.htm

    【讨论】:

    • 非常感谢!以及如何使它不是在新的资源管理器窗口中打开,而是在当前窗口中打开,如果它是打开的?
    • 添加了在当前窗口中选择文件的功能,如果它是打开的。
    • 我试过了,新功能的代码。不工作。按 F3 打开只是一个资源管理器。这是一个视频cloud.mail.ru/public/51Ds/UMXwjNqah
    • 将“下载”替换为浏览器窗口的确切标题,如 Window Spy 中所示。从脚本的托盘菜单或开始菜单启动 Window Spy。
    • 不幸的是,第二个版本根本不起作用。我也改变了下载,它没有帮助。这是一个视频cloud.mail.ru/public/FGcm/XgNHw8A5z
    猜你喜欢
    • 2012-06-12
    • 2022-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多