AutoHotkey 通过忽略完整路径从活动文件夹转到特定文件夹

AutoHotkey go to certain folder from active folder by ignoring full path

我有一个打开的文件夹:

"C:\Users\Me\Desktop\Named_Folder"

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

在"Named_Folder"之下 有一个名为“1”的文件夹 在该文件夹下还有另一个名为“2”的文件夹。

我想创建一个单字母快捷方式以从活动 "Named_Folder" 转到文件夹“2”,因此路径如下所示:

"C:\Users\Me\Desktop\Named_Folder"

在这里我需要提到文件夹“1”和“2”始终具有相同的名称,但 "Named_Folder" 始终具有不同的名称。

也许我可以改进这个主题标题:使用一个字母的快捷方式从活动目录向下移动 2 个目录?

#If WinActive("ahk_class CabinetWClass") ; explorer

F1::
for window in ComObjCreate("Shell.Application").Windows
try Fullpath := window.Document.Folder.Self.Path
; IfExist, %Fullpath%\
    Run, %Fullpath%
return

F2::
for window in ComObjCreate("Shell.Application").Windows
try Fullpath := % window.Document.Folder.Self.Path
; IfExist, %Fullpath%\
    Run, %Fullpath%
return

#If

编辑: 在不打开新目录的情况下导航到目录 window:

#If WinActive("ahk_class CabinetWClass") ; explorer

F1::
for window in ComObjCreate("Shell.Application").Windows
try Fullpath := % window.Document.Folder.Self.Path
IfExist, %Fullpath%\
    NavRun( Fullpath "")
return

F2::
for window in ComObjCreate("Shell.Application").Windows
try Fullpath := window.Document.Folder.Self.Path
IfExist, %Fullpath%\
     NavRun( Fullpath "")
return

#If


; http://msdn.microsoft.com/en-us/library/bb774094
GetActiveExplorer() {
    static objShell := ComObjCreate("Shell.Application")
    WinHWND := WinActive("A")    ; Active window
    for Item in objShell.Windows
        if (Item.HWND = WinHWND)
            return Item        ; Return active window object
    return -1    ; No explorer windows match active window
}

NavRun(Path) {
    if (-1 != objIE := GetActiveExplorer())
        objIE.Navigate(Path)
    else
        Run, % Path
}

https://autohotkey.com/board/topic/102127-navigating-explorer-directories/#entry634365