/* This barebones script loads the file structure into an AutoHotkey menu (including all subdirectories as submenus). Set TopMenu to the starting folder. Any file selected from the menu runs with its default program. See https://jacks-autohotkey-blog.com/2021/07/23/adding-folders-and-files-from-windows-to-autohotkey-menus/ */ TopMenu := "C:\Users\" A_UserName "\QuickLinks", LastMenu := "C:\Users\" A_UserName "\QuickLinks" Loop Files, C:\Users\%A_UserName%\QuickLinks\*.*, DFR ; Recurse into subfolders. { ; Skip any file that is H or S (System). If InStr(A_LoopFileAttrib, "H") or InStr(A_LoopFileAttrib, "S") Continue ; Add to Menu Menu, %A_LoopFileDir%, Add, %A_LoopFileName% , Action If (A_LoopFileDir != LastMenu) and (LastMenu != TopMenu) AddMenu(LastMenu) ; Save menu name LastMenu := A_LoopFileDir } AddMenu(LastMenu) Menu, %TopMenu%, Show Return Action: Run, % A_ThisMenu . "\" . A_ThisMenuItem Return AddMenu(MenuName) { SplitPath, MenuName , DirName, OutDir, OutExtension, OutNameNoExt, OutDrive Menu, %OutDir%, Add, %DirName%, :%MenuName% } ; ^!#m::Menu, %TopMenu%, Show