; Folder Menu by rexx f_CurrentVer = 1.34 ; ; ** CREDITS ** ; Based on "Easy Access to Favorite Folders" by Savage ; http://www.autohotkey.com/docs/scripts/FavoriteFolders.htm ; ; Icons from "Silk Icons" by Mark James @ FAMFAMFAM ; http://www.famfamfam.com/lab/icons/silk/ ; ; Open Registry entry based on ; http://www.appinn.com/ahk-fast-food-restaurant-8-interactive-with-reader-1/ ; ; SendBig5 by Lumania @ Ptt ; http://www.ptt.cc/bbs/EzHotKey/M.1224744552.A.029.html ; ; Menu Icon Support by Lexikos ; http://www.autohotkey.net/~Lexikos/AutoHotkey_L/ ; ; TreeView eXtension by majkinetor ; http://www.autohotkey.com/forum/topic19021.html ; ; GUI ToolTip by Micahs ; http://www.autohotkey.com/forum/topic43105.html ; ; ShellContextMenu by Sean ; http://www.autohotkey.com/forum/topic22120.html ; ;=Change log==================================================================== ; ; 20090605 add: keep recently opened selected text v1.34 ; add: option - show index in recent menu ; fix: run a item if it is not a folder path in some apps ; fix: wider options gui ; 20090601 fix: update fav tree icon after selecting file v1.33 ; fix: auto adjust listview width ; 20090529 fix: loading tooltips v1.32 ; fix: hotkey help link ; add: set hotkey gui ; 20090528 fix: add favorite here v1.31 ; 20090525 add: add favorite here ; add: "select file/folder dialog" opens at the location of path field ; 20090524 add: toggle hide file extension v1.30 ; fix: extend/restore options window button ; 20090522 fix: don't activate minimized window ; 20090521 add: option - clicking on tray icon action ; 20090520 fix: msgbox title ; 20090514 add: check duplicated path v1.29 ; fix: itemmenu for computer ; 20090513 add: variable F_CurrentDir, current dir in active window ; 20090512 fix: rearrange options gui v1.28 ; 20090511 fix: open computer in browse mode ; 20090510 add: hide ext in recent menu, temp menu, add fav, item menu ; 20090509 add: auto create submenu for folder item ; fix: icon for unknown flietype ; add: hide ext when add fav ; add: add index to duplicated item ; 20090507 add: detailed dirve space info v1.27 ; fix: refresh ExploreWClass after toggle hidden ; add: hotkey - showmenu1.5 ; add: option - tempmenu no ext ; add: toggle bigger option window ; 20090506 add: detect for previous instance and show menu (thanks to Mr. Milk) ; add: option - browse mode when capslock off ; 20090505 add: update ahk_L rev 29 ; add: click on 2nd item in tempmenu to open the folder in browse mode ; 20090504 add: show specific file type in temp menu v1.26 ; 20090503 fix: option - restart regedit (thanks to Mr. Milk) ; add: file filter for cmd and vista explorer (thanks to Mr. Milk) ; add: toggle hidden files (thanks to Mr. Milk) ; add: fixed tempmenu position (thanks to Mr. Milk) ; add: SVS Menu (thanks to Mr. Milk) ; add: icon for folders which has subfolder (thanks to Mr. Milk) ; fix: rearrange options GUI ; 20090502 fix: relative path in desktop.ini v1.25 ; 20090501 fix: add at bottom ; add: drive list item ; 20090429 fix: explorer list use title if cannot get path v1.24 ; 20090428 add: drop multiple files to favorite management gui ; fix: fav tree insert & delete function ; add: shift+del to delete submenu ; add: option - replace existing item without asking ; 20090427 add: ahk update to 1.0.48.02 ; fix: blank path error msg ; add: get custom folder icon in desktop.ini ; add: add new fav at bottom ; 20090426 add: show tooltip when loading menu v1.23 ; add: icon list del key ; add: add favorite skip gui ; fix: open fav in explorer whose addressbar is not edit1 ; add: explorers list menu (thanks to F1reW1re) ; 20090425 fix: get path in explorer from ComboBoxEx321 for those edit1 is ; not addressbar (thanks to F1reW1re & Deep-Silence) v1.22 ; 20090424 fix: update icons after options ok ; 20090423 fix: add favorite get path bug ; fix: don't show menu when double click on a file ; 20090422 add: double click hotkey v1.21 ; 20090420 fix: gui tooltips bug v1.20 ; fix: pick icon bug ; add: favorite management drop file ; fix: split path bug ; 20090419 add: turn on capslock to use browse mode ; add: move add favorite into options GUI ; fix: ctrl-click up to 255 times ; add: open shell context menu when ctrl-click a file ; 20090418 add: options tooltip ; add: favorites management GUI icons ; add: option - menu icon size ; 20090417 add: add Computer item by path=Computer ; add: favorites management GUI ; fix: restore clipboard contents after open selected text ; 20090416 add: option - menu position ; 20090415 add: option - always show menu by hotkey1 ; add: options menu item, edit item will open the ini file ; add: option - custom icon GUI ; 20090414 fix: use /d switch in command ; fix: freecommander sometimes doesn't work ; fix: UNC path ; 20090413 add: *.* file filter in dialog ; add: ..\ can go up to computer, and show hdd info ; add: icons for computer, hdd ; 20090412 fix: some dialog doesn't work ; fix: can add empty submenu ; fix: can use same submenu name in different level ; add: option - show files in ctrl-click temp menu ; add: ctrl+shift+click to show files in temp menu ; add: warning if temp menu is too long ; add: show the position of edit1 when get class and add it automatically ; add: custom icon for unknown file type ; add: check new version ; 20090411 add: option - system recent size and only folder ; fix: system recent icon for xp ; add: support FreeCommander, Emacs, rxvt ; fix: send !d only when necessary in vista explorer ; 20090410 add: use abc as index for recent items more than 9 ; add: custom submenu item icon ; add: options GUI ; 20090409 fix: deref bug of path containing ahk escape char '`' ; fix: split bug of filename containing escape char '\' (³\¥\»\) ; add: option - disable hotkey1 on specified applications ; add: option - disable hotkey error checking ; 20090408 fix: submenu name can contains special characters ; (! " % & ' ( ) * + , - . / : ; < = > \ ^ ` { } ~) ; add: drop file on add favorite gui ; 20090407 fix: recent don't keep error item ; fix: don't record recents if there's no recent menu added ; add: option - recent size ; add: option - start with windows ; add: support 7zip 2 panel mode ; add: custom default icons for specified extensions ; add: more special items (Tool Items, SystemRecent) ; 20090406 add: option - click on desktop to show menu ; add: option - recent only keeps folder items ; add: option - no menu icons ; fix: new method to get path in open/save dialog ; add: url/reg example items in default config.ini ; 20090405 add: custom folder items icon ; add: record items recently opened by foldermenu (recent menu) ; original system recent menu is moved into the recent menu ; 20090404 add: add some icons ; 20090403 add: menu icon supported by AutoHotkey_L (Lexikos' custom build) ; 20090328 fix: submenu name can contain ' ' (space) ; fix: filezilla3 with no quick connect bar ; add: favorite can use reg path ; 20090327 fix: bug fix ; 20090325 fix: submenu name can contain '&' ; 20090323 add: custom special item position (Tool, Debug, Recent) ; 20090322 add: recent folder menu (search system recent lnks) ; 20090320 fix: send big5 in cmd ; 20090315 clean up code ; 20090314 add: temp menu go up (..\) ; 20090312 fix: vista explorer addressbar fix ; fix: path can contain '=' ; 20090311 add: rbutton-click works like ctrl-click ; add: support for filezilla3, totalcommander ; 20080712 add: open reg entry ; fix: submenu bug (duplicate error) ; add: shift-click works like ctrl-click ; 2007- ; ctrl-click to create menu for subforders of that item ; sort ; submenu ; options ; notray ; addfav gui ; check name and path ; hold shift to skip check ; edit wait notepad close, readconfig *canceled* ; addfav from cmd ; add tool menu to fav menu ; move 'addfav' in ; hotkey for addfav ; addfav GUI ; addfav from otherapp ; hotkey for edit reload exit etc. ; open selected path ; get class and check edit1 ; use '-' as separator ; check if the path vaild ; addfav - when name duplicated ; add support for more apps ; read config fav section ;=============================================================================== ; 301, Add Favorite , add.ico ; 302, Reload , arrow_refresh_small.ico ; 303, Option , cog.ico ; 304, Edit , page_white_edit.ico ; 305, Exit , cross.ico ; 306, Debug , bug.ico ; 307, Recent , folder_explore.ico ; 308, Folder , folder.ico ; 309, Drive , drive.ico ; 310, Computer , computer.ico ;=============================================================================== ;==================== Auto Execute ====================; ;#SingleInstance, Force ; Needed since the hotkey is dynamically created. #NoTrayIcon #SingleInstance, OFF #MaxThreads 255 SetBatchLines, -1 ; by MILK ; This code detects a previous instance and if it exists ; it sends the menu hotkey and exit. ; This makes possible to "pin" FolderMenu.exe to ; Windows 7 superbar, QuickLaunch, StartMenu, ; ObjectDock, RocketDock and other applications. ; The user will then be able to open the menu without ; using the hotkey. if A_IsCompiled { Process, Exist, %A_ScriptName% PrevPID := ErrorLevel ThisPID := DllCall("GetCurrentProcessId") if ThisPID != %PrevPID% { Send, #!+^x ExitApp } } f_Icons = %A_ScriptFullPath% if A_IsCompiled = { StringReplace, f_Icons, f_Icons, .ahk , .exe, 1 Menu, Tray, UseErrorLevel Menu, Tray, Icon, %f_Icons%,-307 Menu, Tray, UseErrorLevel, OFF } Menu, Tray, Tip, Folder Menu Menu, Tray, NoStandard Menu, Tray, Add, &Folder Menu, f_DisplayMenu15 Menu, Tray, Add Menu, Tray, Add, &Add Favorite, f_AddFavorite Menu, Tray, Add Menu, Tray, Add, &Reload, f_ToolReload Menu, Tray, Add, &Options, f_ToolOptions Menu, Tray, Add, &Edit, f_ToolEdit Menu, Tray, Add Menu, Tray, Add, E&xit, f_ToolExit Menu, Tray, UseErrorLevel Menu, Tray, Icon, &Folder Menu, %f_Icons% Menu, Tray, Icon, &Add Favorite, %f_Icons%,-301 Menu, Tray, Icon, &Reload, %f_Icons%,-302 Menu, Tray, Icon, &Options, %f_Icons%,-303 Menu, Tray, Icon, &Edit, %f_Icons%,-304 Menu, Tray, Icon, E&xit, %f_Icons%,-305 Menu, Tray, UseErrorLevel, OFF Menu, Tray, Default, &Folder Menu Menu, Tray, Click, 1 IfNotExist, %A_ScriptDir%\Config.ini ;if config file doesn't exist { f_ErrorMsg = %f_ErrorMsg%Config file not exist.`nDefault config is installed.`n FileInstall, Default.ini, %A_ScriptDir%\Config.ini } f_ReadConfig() f_SetConfig() if s_CheckVersion f_CheckVersion(1) gui_hh = 0 gui_ww = 0 ;Gosub, f_TOoLoPtIOnS return ;=================================== End Auto Execute =; f_CheckVersion(Quiet=0) { Global f_CurrentVer VerFileName = %Temp%\foldermenuversion.tmp UrlDownloadToFile, http://www.autohotkey.net/~rexx/FolderMenu/ver.txt, %VerFileName% FileRead, LatestVer, %VerFileName% FileDelete, %VerFileName% if LatestVer = { if !Quiet MsgBox, 16, Error, Cannot connect to the Internet. } else { if f_CurrentVer < %LatestVer% { MsgBox, 36, New Version!, There's a new version v%LatestVer% available.`n`nGo to website? IfMsgBox Yes Gosub, f_GoWebsite } else if !Quiet MsgBox, 64, Folder Menu, You are using the latest version v%f_CurrentVer%. } return } ;==================== Read Config File ====================; f_ReadConfig() { Global ; applications IniRead, s_Apps_Explorer , %A_ScriptDir%\Config.ini, Applications, Explorer , 1 ; all enabled by default IniRead, s_Apps_Dialog , %A_ScriptDir%\Config.ini, Applications, Dialog , 1 IniRead, s_Apps_Command , %A_ScriptDir%\Config.ini, Applications, Command , 1 IniRead, s_Apps_7z , %A_ScriptDir%\Config.ini, Applications, 7Zip , 1 IniRead, s_Apps_Fz3 , %A_ScriptDir%\Config.ini, Applications, FileZilla3 , 1 IniRead, s_Apps_TC , %A_ScriptDir%\Config.ini, Applications, TotalCommander, 1 IniRead, s_Apps_FC , %A_ScriptDir%\Config.ini, Applications, FreeCommander , 1 IniRead, s_Apps_Emacs , %A_ScriptDir%\Config.ini, Applications, Emacs , 1 IniRead, s_Apps_rxvt , %A_ScriptDir%\Config.ini, Applications, rxvt , 1 IniRead, s_Apps_Desktop , %A_ScriptDir%\Config.ini, Applications, Desktop , 1 IniRead, s_Apps_Others , %A_ScriptDir%\Config.ini, Applications, OtherApps , 1 IniRead, s_Apps_OthersList, %A_ScriptDir%\Config.ini, Applications, OtherAppsList , %A_Space% ; icons IniRead, s_NoMenuIcon, %A_ScriptDir%\Config.ini, Icons, NoMenuIcon, 0 IniRead, s_IconSize , %A_ScriptDir%\Config.ini, Icons, IconSize , %A_Space% ; others IniRead, s_MaxDepth , %A_ScriptDir%\Config.ini, Others, MaxDepth , 2 IniRead, s_StartWithWin , %A_ScriptDir%\Config.ini, Others, StartWithWin , 0 IniRead, s_NoTray , %A_ScriptDir%\Config.ini, Others, NoTray , 0 IniRead, s_CheckVersion , %A_ScriptDir%\Config.ini, Others, CheckVersion , 1 IniRead, s_DontKillReg , %A_ScriptDir%\Config.ini, Others, DontKillReg , 0 IniRead, s_BrowseMode , %A_ScriptDir%\Config.ini, Others, BrowseMode , 0 IniRead, s_HideExt , %A_ScriptDir%\Config.ini, Others, HideExt , 0 IniRead, s_CheckItmePath, %A_ScriptDir%\Config.ini, Others, CheckItmePath, 0 IniRead, s_TrayIconClick, %A_ScriptDir%\Config.ini, Others, TrayIconClick, 2 ; show menu 1.5 IniRead, s_AddFavBottom , %A_ScriptDir%\Config.ini, Others, AddFavBottom , 0 IniRead, s_AddFavSkipGUI, %A_ScriptDir%\Config.ini, Others, AddFavSkipGUI, 0 IniRead, s_AddFavReplace, %A_ScriptDir%\Config.ini, Others, AddFavReplace, 0 IniRead, s_TempShowAll , %A_ScriptDir%\Config.ini, Others, TempShowAll , 0 IniRead, s_ShowFileExt , %A_ScriptDir%\Config.ini, Others, ShowFileExt , * IniRead, s_AltFolderIcon, %A_ScriptDir%\Config.ini, Others, AltFolderIcon, 1 IniRead, s_MenuPosition , %A_ScriptDir%\Config.ini, Others, MenuPosition , 1 ; relative to screen IniRead, s_MenuPositionX, %A_ScriptDir%\Config.ini, Others, MenuPositionX, %A_Space% IniRead, s_MenuPositionY, %A_ScriptDir%\Config.ini, Others, MenuPositionY, %A_Space% ; rececnts IniRead, s_RecentSize , %A_ScriptDir%\Config.ini, Recents, RecentSize , 10 IniRead, s_RecentSizeS , %A_ScriptDir%\Config.ini, Recents, RecentSizeS , 10 IniRead, s_RecentOnlyFolder , %A_ScriptDir%\Config.ini, Recents, RecentOnlyFolder , 0 IniRead, s_RecentOnlyFolderS, %A_ScriptDir%\Config.ini, Recents, RecentOnlyFolderS, 0 IniRead, s_RecentShowIndex , %A_ScriptDir%\Config.ini, Recents, RecentShowIndex , 1 ; hotkeys IniRead, s_Hotkey1, %A_ScriptDir%\Config.ini, Hotkeys, Hotkey1 ,%A_Space% IniRead, s_Hotkey15,%A_ScriptDir%\Config.ini, Hotkeys, Hotkey15,%A_Space% IniRead, s_Hotkey2, %A_ScriptDir%\Config.ini, Hotkeys, Hotkey2 ,%A_Space% IniRead, s_HotkeyJ, %A_ScriptDir%\Config.ini, Hotkeys, OpenSel ,%A_Space% IniRead, s_HotkeyG, %A_ScriptDir%\Config.ini, Hotkeys, AddApp ,%A_Space% IniRead, s_HotkeyA, %A_ScriptDir%\Config.ini, Hotkeys, AddFav ,%A_Space% IniRead, s_HotkeyR, %A_ScriptDir%\Config.ini, Hotkeys, Reload ,%A_Space% IniRead, s_HotkeyO, %A_ScriptDir%\Config.ini, Hotkeys, Options ,%A_Space% IniRead, s_HotkeyE, %A_ScriptDir%\Config.ini, Hotkeys, Edit ,%A_Space% IniRead, s_HotkeyX, %A_ScriptDir%\Config.ini, Hotkeys, Exit ,%A_Space% ; StartTime := A_TickCount f_ReadFavorites() ; ElapsedTime := A_TickCount - StartTime ; MsgBox, %ElapsedTime% milliseconds have elapsed. return } f_SetConfig() { Global ; Class name in f_SupportApps = if s_Apps_Explorer f_SupportApps = %f_SupportApps%,CabinetWClass,ExploreWClass if s_Apps_Dialog f_SupportApps = %f_SupportApps%,#32770 if s_Apps_Command f_SupportApps = %f_SupportApps%,ConsoleWindowClass if s_Apps_7z f_SupportApps = %f_SupportApps%,FM if s_Apps_Fz3 f_SupportApps = %f_SupportApps%,wxWindowClassNR if s_Apps_TC f_SupportApps = %f_SupportApps%,TTOTAL_CMD if s_Apps_FC f_SupportApps = %f_SupportApps%,TfcForm if s_Apps_Emacs f_SupportApps = %f_SupportApps%,Emacs if s_Apps_Desktop f_SupportApps = %f_SupportApps%,Progman,WorkerW if s_Apps_Others f_SupportApps = %f_SupportApps%,%s_Apps_OthersList% if SubStr(f_SupportApps, 1, 1) = "," StringTrimLeft, f_SupportApps, f_SupportApps, 1 ; Class name contains f_SupportAppsC = if s_Apps_Dialog f_SupportAppsC = %f_SupportAppsC%,bosa_sdm_ if s_Apps_rxvt f_SupportAppsC = %f_SupportAppsC%,rxvt if SubStr(f_SupportAppsC, 1, 1) = "," StringTrimLeft, f_SupportAppsC, f_SupportAppsC, 1 if s_NoTray = 1 Menu, Tray, NoIcon else Menu, Tray, Icon if s_StartWithWin = 1 RegWrite, REG_SZ, HKCU, Software\Microsoft\Windows\CurrentVersion\Run, FolderMenu, %A_ScriptFullPath% else RegDelete, HKCU, Software\Microsoft\Windows\CurrentVersion\Run, FolderMenu ; disable old hotkeys Hotkey, %f_Hotkey1%, Off, UseErrorLevel Hotkey, %f_Hotkey15%,Off, UseErrorLevel Hotkey, %f_Hotkey2%, Off, UseErrorLevel Hotkey, %f_HotkeyJ%, Off, UseErrorLevel Hotkey, %f_HotkeyG%, Off, UseErrorLevel Hotkey, %f_HotkeyA%, Off, UseErrorLevel Hotkey, %f_HotkeyR%, Off, UseErrorLevel Hotkey, %f_HotkeyO%, Off, UseErrorLevel Hotkey, %f_HotkeyE%, Off, UseErrorLevel Hotkey, %f_HotkeyX%, Off, UseErrorLevel f_Hotkey1 := s_Hotkey1 f_Hotkey15:= s_Hotkey15 f_Hotkey2 := s_Hotkey2 f_HotkeyJ := s_HotkeyJ f_HotkeyG := s_HotkeyG f_HotkeyA := s_HotkeyA f_HotkeyR := s_HotkeyR f_HotkeyO := s_HotkeyO f_HotkeyE := s_HotkeyE f_HotkeyX := s_HotkeyX f_SetHotkey("Show Menu 1" , f_Hotkey1, "f_DisplayMenu1" ) f_SetHotkey("Show Menu 1.5" , f_Hotkey15,"f_DisplayMenu15") f_SetHotkey("Show Menu 2" , f_Hotkey2, "f_DisplayMenu2" ) f_SetHotkey("Open Selected Text", f_HotkeyJ, "f_OpenSel" ) f_SetHotkey("Add Application" , f_HotkeyG, "f_AddApp" ) f_SetHotkey("Add Favorite" , f_HotkeyA, "f_AddFavoriteK" ) f_SetHotkey("Reload" , f_HotkeyR, "f_ToolReload" ) f_SetHotkey("Options" , f_HotkeyO, "f_ToolOptions" ) f_SetHotkey("Edit" , f_HotkeyE, "f_ToolEdit" ) f_SetHotkey("Exit" , f_HotkeyX, "f_ToolExit" ) ; enable hotkeys that doesn't change Hotkey, %f_Hotkey1%, On, UseErrorLevel Hotkey, %f_Hotkey15%,On, UseErrorLevel Hotkey, %f_Hotkey2%, On, UseErrorLevel Hotkey, %f_HotkeyJ%, On, UseErrorLevel Hotkey, %f_HotkeyG%, On, UseErrorLevel Hotkey, %f_HotkeyA%, On, UseErrorLevel Hotkey, %f_HotkeyR%, On, UseErrorLevel Hotkey, %f_HotkeyO%, On, UseErrorLevel Hotkey, %f_HotkeyE%, On, UseErrorLevel Hotkey, %f_HotkeyX%, On, UseErrorLevel if s_TrayIconClick = 1 Hotkey, #!+^x, f_DisplayMenu1, UseErrorLevel else if s_TrayIconClick = 2 Hotkey, #!+^x, f_DisplayMenu15, UseErrorLevel else if s_TrayIconClick = 3 Hotkey, #!+^x, f_DisplayMenu2, UseErrorLevel if s_TrayIconClick = 1 Menu, Tray, Add, &Folder Menu, f_DisplayMenu1 else if s_TrayIconClick = 2 Menu, Tray, Add, &Folder Menu, f_DisplayMenu15 else if s_TrayIconClick = 3 Menu, Tray, Add, &Folder Menu, f_DisplayMenu2 TrayTip ; remove old one if f_ErrorMsg != { TrayTip, !, %f_ErrorMsg%, , 1 f_ErrorMsg = } return } f_SetHotkey(Name, ByRef Hotkey, Label) { Global if Hotkey != { if SubStr(Hotkey, 1, 2) = "DB" { StringTrimLeft, Hotkey, Hotkey, 2 Hotkey, %Hotkey%, %Label%DB, UseErrorLevel } else { Hotkey, %Hotkey%, %Label%, UseErrorLevel } if ErrorLevel in 2,3,4 f_ErrorMsg = %f_ErrorMsg%Hotkey [%Name%] error. (%ErrorLevel%)`n } return } f_ReadFavorites() { Global ; ToolTip, Loading Favorites... Menu, MainMenu, Add Menu, MainMenu, DeleteAll i_MainMenuItemPos = 1 s_FavoritesCount = 0 Local InFavSection = 0 ; check if in the favorites section Local A_LoopReadLineFirstChar Loop, Read, %A_ScriptDir%\Config.ini { if A_LoopReadLine = ; skip blank lines continue StringLeft, A_LoopReadLineFirstChar, A_LoopReadLine, 1 if A_LoopReadLineFirstChar = `; ; skip comments continue if InFavSection = 0 { IfInString, A_LoopReadLine, [Favorites] ; Favorites section start InFavSection = 1 else continue ; Start a new loop iteration. } else if InFavSection = 1 { if A_LoopReadLineFirstChar = [ ; Another section start Break else { ; Tooltip, Loading Favorites...`nItem %A_Index% Local ThisName, ThisPath, ThisItem f_Split2(A_LoopReadLine, "=", ThisName, ThisPath) ThisPath = %ThisPath% if s_CheckItmePath { ThisItem := f_ItemPathExist(ThisPath) if ThisItem MsgBox, 48, Warning, Path of item [%ThisName%] duplicated.`n`n(%ThisItem%) } s_FavoritesCount++ s_Favorites%s_FavoritesCount% = %A_LoopReadLine% f_CreateMenuItem("MainMenu", A_LoopReadLine) } } } ; ToolTip return } f_WriteConfig() { Global ; applications IniWrite, %s_Apps_Explorer% , %A_ScriptDir%\Config.ini, Applications, Explorer IniWrite, %s_Apps_Dialog% , %A_ScriptDir%\Config.ini, Applications, Dialog IniWrite, %s_Apps_Command% , %A_ScriptDir%\Config.ini, Applications, Command IniWrite, %s_Apps_7z% , %A_ScriptDir%\Config.ini, Applications, 7Zip IniWrite, %s_Apps_Fz3% , %A_ScriptDir%\Config.ini, Applications, FileZilla3 IniWrite, %s_Apps_TC% , %A_ScriptDir%\Config.ini, Applications, TotalCommander IniWrite, %s_Apps_FC% , %A_ScriptDir%\Config.ini, Applications, FreeCommander IniWrite, %s_Apps_Emacs% , %A_ScriptDir%\Config.ini, Applications, Emacs IniWrite, %s_Apps_rxvt% , %A_ScriptDir%\Config.ini, Applications, rxvt IniWrite, %s_Apps_Desktop% , %A_ScriptDir%\Config.ini, Applications, Desktop IniWrite, %s_Apps_Others% , %A_ScriptDir%\Config.ini, Applications, OtherApps IniWrite, %s_Apps_OthersList% , %A_ScriptDir%\Config.ini, Applications, OtherAppsList ; icons IniWrite, %s_NoMenuIcon% , %A_ScriptDir%\Config.ini, Icons , NoMenuIcon IniWrite, %s_IconSize% , %A_ScriptDir%\Config.ini, Icons , IconSize f_WriteIcons() ; others IniWrite, %s_StartWithWin% , %A_ScriptDir%\Config.ini, Others , StartWithWin IniWrite, %s_NoTray% , %A_ScriptDir%\Config.ini, Others , NoTray IniWrite, %s_CheckVersion% , %A_ScriptDir%\Config.ini, Others , CheckVersion IniWrite, %s_DontKillReg% , %A_ScriptDir%\Config.ini, Others , DontKillReg IniWrite, %s_BrowseMode% , %A_ScriptDir%\Config.ini, Others , BrowseMode IniWrite, %s_HideExt% , %A_ScriptDir%\Config.ini, Others , HideExt IniWrite, %s_CheckItmePath% , %A_ScriptDir%\Config.ini, Others , CheckItmePath IniWrite, %s_TrayIconClick% , %A_ScriptDir%\Config.ini, Others , TrayIconClick IniWrite, %s_AddFavBottom% , %A_ScriptDir%\Config.ini, Others , AddFavBottom IniWrite, %s_AddFavSkipGUI% , %A_ScriptDir%\Config.ini, Others , AddFavSkipGUI IniWrite, %s_AddFavReplace% , %A_ScriptDir%\Config.ini, Others , AddFavReplace IniWrite, %s_TempShowAll% , %A_ScriptDir%\Config.ini, Others , TempShowAll IniWrite, %s_ShowFileExt% , %A_ScriptDir%\Config.ini, Others , ShowFileExt IniWrite, %s_AltFolderIcon% , %A_ScriptDir%\Config.ini, Others , AltFolderIcon IniWrite, %s_MaxDepth% , %A_ScriptDir%\Config.ini, Others , MaxDepth IniWrite, %s_MenuPosition% , %A_ScriptDir%\Config.ini, Others , MenuPosition IniWrite, %s_MenuPositionX% , %A_ScriptDir%\Config.ini, Others , MenuPositionX IniWrite, %s_MenuPositionY% , %A_ScriptDir%\Config.ini, Others , MenuPositionY ; recent IniWrite, %s_RecentSize% , %A_ScriptDir%\Config.ini, Recents , RecentSize IniWrite, %s_RecentSizeS% , %A_ScriptDir%\Config.ini, Recents , RecentSizeS IniWrite, %s_RecentOnlyFolder% , %A_ScriptDir%\Config.ini, Recents , RecentOnlyFolder IniWrite, %s_RecentOnlyFolderS%, %A_ScriptDir%\Config.ini, Recents , RecentOnlyFolderS IniWrite, %s_RecentShowIndex% , %A_ScriptDir%\Config.ini, Recents , RecentShowIndex ; hotkeys IniWrite, %s_Hotkey1% , %A_ScriptDir%\Config.ini, Hotkeys , Hotkey1 IniWrite, %s_Hotkey15% , %A_ScriptDir%\Config.ini, Hotkeys , Hotkey15 IniWrite, %s_Hotkey2% , %A_ScriptDir%\Config.ini, Hotkeys , Hotkey2 IniWrite, %s_HotkeyJ% , %A_ScriptDir%\Config.ini, Hotkeys , OpenSel IniWrite, %s_HotkeyG% , %A_ScriptDir%\Config.ini, Hotkeys , AddApp IniWrite, %s_HotkeyA% , %A_ScriptDir%\Config.ini, Hotkeys , AddFav IniWrite, %s_HotkeyR% , %A_ScriptDir%\Config.ini, Hotkeys , Reload IniWrite, %s_HotkeyO% , %A_ScriptDir%\Config.ini, Hotkeys , Options IniWrite, %s_HotkeyE% , %A_ScriptDir%\Config.ini, Hotkeys , Edit IniWrite, %s_HotkeyX% , %A_ScriptDir%\Config.ini, Hotkeys , Exit ; favorites f_WriteFavorites() return } f_WriteIcons() { Global Loop, Parse, s_IconsDeleteList, `n { IniDelete, %A_ScriptDir%\Config.ini, Icons, %A_LoopField% f_Icons_%A_LoopField% := "" } s_IconsDeleteList = Local Extension, IconPath Loop, % s_IconsCount { Extension := s_Icons%A_Index%Ext IconPath := s_Icons%A_Index%Path . "," . s_Icons%A_Index%Index IniWrite, %IconPath%, %A_ScriptDir%\Config.ini, Icons, %Extension% f_Icons_%Extension% := IconPath } return } ;==================== Display The Menu ====================; f_DisplayMenu1: f_Hotkey1_Always = 0 Gosub, f_DisplayMenu return f_DisplayMenu15: f_Hotkey1_Always = 1 Gosub, f_DisplayMenu return f_DisplayMenu2: ; Always show menu ; Clear the w_Edit1Pos to do the default action w_WinID = w_Class = w_Edit1Pos = f_ShowMenu("MainMenu") return f_DisplayMenu: ; These first few variables are set here and used by f_OpenFavorite: WinGet, w_WinID, ID, A WinGet, w_WinMin, MinMax, ahk_id %w_WinID% if w_WinMin = -1 ; Only detect windows not Minimized. return WinGetClass, w_Class, ahk_id %w_WinID% ; by MILK ; This code checks for the known "dockable" applications/windows so that ; when the user clicks on the icon (instead of pressing the hotkey), the ; app will detect the previous activate window, get its ID and class ; and let it be the FolderMenu target. if !w_Class ; Windows 7/AHK problem: doesnt return active window w_Class = *** ; This is the list of windows classes for the applications that are supposed ; to run FolderMenu.exe from its icons. If any of these classes are detected ; than I know I have to get the previously active window so that the context ; menu works. We can add classes, maybe make it an option in the ini, futurely. ; Currently, it works with Taskbar Tray Icon, Windows QuickLauch, ; Windows 7 Superbar, Windows 7 Notification Icons, ObjectDock Docklet and ; RocketDock. They have all been tested successfully. f_DockableApps = ***,DockItemClass,DockItemTitleWindow,DockCatcher,DockBackgroundClass,ODIndicator,RocketDock,Shell_TrayWnd,NotifyIconOverflowWindow if w_Class in %f_DockableApps% { ; here we check to see if it is a top level window WS_OVERLAPPEDWINDOW := 0x0cf0000 WS_POPUPWINDOW := 0x80880000 WinGet, w_WinIDs, List Loop, %w_WinIDs% { w_WinID := w_WinIDs%A_Index% WinGet, w_Style, Style, ahk_id %w_WinID% WinGet, w_ExStyle, ExStyle, ahk_id %w_WinID% ; for the window to be considered a valid target we discard non-toplevel windows ; AND topmost (always on top) windows. We skip the topmost because they are the ; first to come in the list. Also, topmost windows don't usually have context ; meaning such as TaskManager, Sidebar, System Monitors, etc. if ((w_Style & WS_OVERLAPPEDWINDOW) || (w_Style & WS_POPUPWINDOW)) && !(w_ExStyle & 0x8) { WinGet, w_WinMin, MinMax, ahk_id %w_WinID% if w_WinMin != -1 { WinGetClass, w_Class, ahk_id %w_WinID% if w_Class not in %f_DockableApps% { WinActivate ahk_id %w_WinID% break } } } } } w_Edit1Pos = ; return if not supported if w_Class not in %f_SupportApps% if w_Class not contains %f_SupportAppsC% { if f_Hotkey1_Always { w_WinID = w_Class = w_Edit1Pos = f_ShowMenu("MainMenu") } else return } ; Vista Explorer if w_Class = CabinetWClass { ControlGetPos, w_Edit1Pos,,,, Edit1, ahk_id %w_WinID% if A_OSVersion = WIN_VISTA ; For new addresbar in Vista or 7 { if w_Edit1Pos = { Send, !d ; Set focus on addressbar to enable Edit1 ControlGetPos, w_Edit1Pos,,,, Edit1, ahk_id %w_WinID% } } if w_Edit1Pos != f_ShowMenu("MainMenu") return } ; Dialog, Explorer, Total Commander, Others, FileZilla 3 if w_Class in #32770,ExploreWClass,TTOTAL_CMD,FM,wxWindowClassNR,%s_Apps_OthersList% ; no spaces around ',' { ControlGetPos, w_Edit1Pos,,,, Edit1, ahk_id %w_WinID% if w_Edit1Pos != f_ShowMenu("MainMenu") return } ; Microsoft Office application if w_Class contains bosa_sdm_ { ControlGetPos, w_Edit1Pos,,,, RichEdit20W2, ahk_id %w_WinID% if w_Edit1Pos != f_ShowMenu("MainMenu") return } ; Rxvt command prompt if w_Class contains rxvt { w_Edit1Pos = 1 f_ShowMenu("MainMenu") return } ; Command Prompt, Emacs, FreeCommander, Console2 if w_Class in ConsoleWindowClass,Emacs,TfcForm ;,Console_2_Main { w_Edit1Pos = 1 f_ShowMenu("MainMenu") return } ; Desktop if w_Class in Progman,WorkerW { w_WinID = w_Class = w_Edit1Pos = f_ShowMenu("MainMenu") return } ; Else don't display menu return f_ShowMenu(Menu) { Global Local X, Y, W, H CoordMode, Mouse , Screen if s_MenuPosition = 1 ; relative to screen { if s_MenuPositionX = MouseGetPos, X else X = %s_MenuPositionX% if s_MenuPositionY = MouseGetPos, , Y else Y = %s_MenuPositionY% } else if s_MenuPosition = 2 ; relative to window { WinGetPos, X, Y, W, H, A if s_MenuPositionX = ; blank, use current mouse position MouseGetPos, X else if s_MenuPositionX < %W% ; < window width, inside window X := X + s_MenuPositionX else ; out of window, use window edge X := X + W if s_MenuPositionY = MouseGetPos, , Y else if s_MenuPositionY < %H% Y := Y + s_MenuPositionY else Y := Y + H } CoordMode, Menu , Screen Menu, %Menu%, Show, %X%, %Y% return } ;==================== Open Favorite Item ====================; f_OpenFavorite: ; Fetch the array element that corresponds to the selected menu item: f_OpenFavPath := i_%A_ThisMenu%Path%A_ThisMenuItemPos% if f_OpenFavPath = { TrayTip, Error, Could not open`n`"%A_ThisMenuItem%`"`nIts path is blank., , 3 return } if InStr(f_OpenFavPath, "%F_CurrentDir%") StringReplace, f_OpenFavPath, f_OpenFavPath, `%F_CurrentDir`%, % f_GetPath(w_WinID, w_Class) . "\", All if f_OpenFavPath = Computer f_OpenFavPath = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" if (f_OpenFavPath = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}") f_OpenFavPath = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" if SubStr(f_OpenFavPath, 1, 1) = "*" ; file filter { ; Dialog if w_Class = #32770 { WinActivate ahk_id %w_WinID% ControlGetText, w_Edit1Text, Edit1, ahk_id %w_WinID% ControlClick, Edit1, ahk_id %w_WinID% ControlSetText, Edit1, %f_OpenFavPath%, ahk_id %w_WinID% ControlSend, Edit1, {Enter}, ahk_id %w_WinID% Sleep, 100 ; It needs extra time on some dialogs or in some cases. ControlSetText, Edit1, %w_Edit1Text%, ahk_id %w_WinID% } ; Microsoft Office application else if w_Class contains bosa_sdm_ { WinActivate ahk_id %w_WinID% ControlGetText, w_Edit1Text, RichEdit20W2, ahk_id %w_WinID% ControlClick, RichEdit20W2, ahk_id %w_WinID% ControlSetText, RichEdit20W2, %f_OpenFavPath%, ahk_id %w_WinID% ControlSend, RichEdit20W2, {Enter}, ahk_id %w_WinID% Sleep, 100 ControlSetText, RichEdit20W2, %w_Edit1Text%, ahk_id %w_WinID% } ; Command Prompt (thanks to Mr. Milk) else if w_Class = ConsoleWindowClass { StringReplace, f_OpenFavPath, f_OpenFavPath, `;, %A_Space%, All f_OpenFavPath := "for /R %a in (" . f_OpenFavPath . ") do @echo %~aa %~ta %~za`t%~Fa" WinActivate, ahk_id %w_WinID% ; Because sometimes the mclick deactivates it. SetKeyDelay, 0 ; This will be in effect only for the duration of this thread. f_SendBig5("cmd.exe /F:OFF") Send, {Enter} f_SendBig5(f_OpenFavPath) Send, {Enter}exit{Enter} } ; Vista Explorer (thanks to Mr. Milk) else if A_OSVersion = WIN_VISTA { if f_OpenFavPath != *.* { StringReplace, f_OpenFavPath, f_OpenFavPath, *., ext:, All StringReplace, f_OpenFavPath, f_OpenFavPath, `;, %A_Space%OR%A_Space%, All } if w_Class in CabinetWClass Send, ^e ; Set focus on searchbox to enable Edit2 else { Send, #f ; Open vista search WinWaitActive, ahk_class CabinetWClass, , 5 WinGet, w_WinID, ID Sleep, 100 } ; ControlSetText, Edit2, %f_OpenFavPath%, ahk_id %w_WinID% Send, %f_OpenFavPath% WinActivate ahk_id %w_WinID% } return } if InStr(f_OpenFavPath, "svscmd.exe") { if SubStr(f_OpenFavPath, -1) = " D" SplashTextOn,,,Deactivating SVS Layer... else SplashTextOn,,,Activating SVS Layer... RunWait, %ThisPath%, , Hide UseErrorLevel SplashTextOff f_CreateSVSMenu() return } ; if CapsLock is on, use browse mode if (!s_BrowseMode && GetKeyState("CapsLock", "T")) || (s_BrowseMode && !GetKeyState("CapsLock", "T")) { if A_ThisMenu = TempMenu { if (A_ThisMenuItemPos = 2) || (A_ThisMenuItemPos = 1 && A_ThisMenuItem != "..\") ; current folder item { f_OpenPath(f_OpenFavPath) return } } if f_IsFolder(f_OpenFavPath) { if GetKeyState("Shift") && GetKeyState("Ctrl") f_OpenTempMenu(f_OpenFavPath, 1) else if GetKeyState("Shift") || GetKeyState("Ctrl") || GetKeyState("RButton") f_OpenPath(f_OpenFavPath) else f_OpenTempMenu(f_OpenFavPath, s_TempShowAll) return } } ; Holding ctrl (or shift) (or right mouse button) ; Holding both ctrl and shift for files and folders if GetKeyState("Shift") && GetKeyState("Ctrl") { if f_IsFolder(f_OpenFavPath) f_OpenTempMenu(f_OpenFavPath, 1) else ShellContextMenu(f_OpenFavPath) } else if GetKeyState("Shift") || GetKeyState("Ctrl") || GetKeyState("RButton") { if f_IsFolder(f_OpenFavPath) f_OpenTempMenu(f_OpenFavPath, s_TempShowAll) else ShellContextMenu(f_OpenFavPath) } else f_OpenPath(f_OpenFavPath) return f_OpenPath(ThisPath) { Global if !f_IsFolder(ThisPath) && !FileExist(ThisPath) ; not a folder, file not exist, run it { if !f_RunPath(ThisPath) ; if no error if f_RecentEnabled = 1 if !s_RecentOnlyFolder ; if recent not only record folders f_AddRecent(ThisPath) return } if w_Edit1Pos = { Run, explore %ThisPath%, , UseErrorLevel ; Might work on more systems without double quotes. if ErrorLevel f_RunPath(ThisPath) } else { ; Dialog if w_Class = #32770 { ; Activate the window so that if the user is middle-clicking ; outside the dialog, subsequent clicks will also work: WinActivate ahk_id %w_WinID% ; Retrieve any filename that might already be in the field so ; that it can be restored after the switch to the new folder: ControlGetText, w_Edit1Text, Edit1, ahk_id %w_WinID% ControlClick, Edit1, ahk_id %w_WinID% ControlSetText, Edit1, %ThisPath%, ahk_id %w_WinID% ControlSend, Edit1, {Enter}, ahk_id %w_WinID% Sleep, 100 ; It needs extra time on some dialogs or in some cases. ControlSetText, Edit1, %w_Edit1Text%, ahk_id %w_WinID% } ; Explorer else if w_Class in CabinetWClass,ExploreWClass { ;ControlClick, Edit1, ahk_id %w_WinID% Local PathEdit := f_GetPathEdit(w_WinID) ControlSetText, %PathEdit%, %ThisPath%, ahk_id %w_WinID% ; Tekl reported the following: "If I want to change to Folder L:\folder ; then the addressbar shows http://www.L:\folder.com. To solve this, ; I added a {right} before {Enter}": ControlSend, %PathEdit%, {Right}{Enter}, ahk_id %w_WinID% WinActivate ahk_id %w_WinID% } ; 7-Zip File Manager else if w_Class = FM { MouseGetPos, , , , w_Control if w_Control = SysListView322 ; second panel { ControlSetText, Edit2, %ThisPath%, ahk_id %w_WinID% ControlSend, Edit2, {Enter}, ahk_id %w_WinID% } else { ControlSetText, Edit1, %ThisPath%, ahk_id %w_WinID% ControlSend, Edit1, {Enter}, ahk_id %w_WinID% } } ; FileZilla 3 else if w_Class = wxWindowClassNR { if InStr(FileExist(ThisPath), "D") { ControlGetPos, w_Edit1Pos,,,, Edit5, ahk_id %w_WinID% if w_Edit1Pos != ; it has quick connect bar, addressbar is edit5 { ControlSetText, Edit5, %ThisPath%, ahk_id %w_WinID% ControlSend, Edit5, {Enter}, ahk_id %w_WinID% } else { ControlSetText, Edit1, %ThisPath%, ahk_id %w_WinID% ControlSend, Edit1, {Enter}, ahk_id %w_WinID% } ControlFocus, SysListView321, ahk_id %w_WinID% ; Set focus to file list } else f_RunPath(ThisPath) } ; Microsoft Office application else if w_Class contains bosa_sdm_ { WinActivate ahk_id %w_WinID% ControlGetText, w_Edit1Text, RichEdit20W2, ahk_id %w_WinID% ControlClick, RichEdit20W2, ahk_id %w_WinID% ;<----------important!!! ControlSetText, RichEdit20W2, %ThisPath%, ahk_id %w_WinID% ControlSend, RichEdit20W2, {Enter}, ahk_id %w_WinID% Sleep, 100 ControlSetText, RichEdit20W2, %w_Edit1Text%, ahk_id %w_WinID% } ; Total Commander (thanks to FatZgrED) else if w_Class = TTOTAL_CMD { ;Total Commander has Edit1 control but you need to cd to location if InStr(FileExist(ThisPath), "D") { ControlSetText, Edit1, cd %ThisPath%, ahk_id %w_WinID% ControlSend, Edit1, {Enter}, ahk_id %w_WinID% } else f_RunPath(ThisPath) } ; FreeCommander (thanks to catweazle (John)) else if w_Class = TfcForm { Send, !g ControlClick, TfcPathEdit1, ahk_id %w_WinID% ControlSetText, TfcPathEdit1, %ThisPath%, ahk_id %w_WinID% ControlSend, TfcPathEdit1, {Enter}, ahk_id %w_WinID% } ; Command Prompt else if w_Class = ConsoleWindowClass { if InStr(FileExist(ThisPath), "D") { WinActivate, ahk_id %w_WinID% ; Because sometimes the mclick deactivates it. SetKeyDelay, 0 ; This will be in effect only for the duration of this thread. f_SendBig5("cd /d " . ThisPath . "\") ; (thanks to tireless for the /d switch) Send, {Enter} } else f_RunPath(ThisPath) } ; Emacs (thanks to catweazle (John)) else if w_Class = Emacs { WinActivate, ahk_id %w_WinID% SetKeyDelay, 0 Send, !xfind-file{Enter} Send, %ThisPath%{Tab} } ; Rxvt command prompt (thanks to catweazle (John)) else if w_Class contains rxvt { if InStr(FileExist(ThisPath), "D") { WinActivate, ahk_id %w_WinID% SetKeyDelay, 0 Send, cd `'%ThisPath%`'{Enter} Send, ls{Enter} } else f_RunPath(ThisPath) } ; Others else if w_Class in %s_Apps_OthersList% { if InStr(FileExist(ThisPath), "D") { ControlSetText, Edit1, %ThisPath%, ahk_id %w_WinID% ControlSend, Edit1, {Right}{Enter}, ahk_id %w_WinID% } else f_RunPath(ThisPath) } } if f_RecentEnabled = 1 { if f_IsFolder(ThisPath) ; it's a folder f_AddRecent(ThisPath) else if !s_RecentOnlyFolder ; if recent not only record folders f_AddRecent(ThisPath) } return } f_RunPath(ThisPath) { Run, %ThisPath%, , UseErrorLevel ; run a file or url if ErrorLevel { if f_OpenReg(ThisPath) ; open reg { TrayTip, Error, Could not open`n`"%ThisPath%`", , 3 return 1 } } return 0 } f_IsFolder(ThisPath) { if InStr(FileExist(ThisPath), "D") || (ThisPath = """::{20D04FE0-3AEA-1069-A2D8-08002B30309D}""") || SubStr(ThisPath, 1, 2) = "\\" return 1 else return 0 } f_GetPathEdit(ThisID) ; get the classnn of the addressbar, thanks to F1reW1re { WinGetClass, ThisClass, ahk_id %ThisID% if ThisClass not in ExploreWClass,CabinetWClass return ControlGetText, ComboBoxEx321_Content, ComboBoxEx321, ahk_id %ThisID% WinGet, ActiveControlList, ControlList, ahk_id %ThisID% Loop, Parse, ActiveControlList, `n { StringLeft, WhichControl, A_LoopField, 4 if WhichControl = Edit { ControlGetText, Edit_Content, %A_LoopField%, ahk_id %ThisID% if ComboBoxEx321_Content = %Edit_Content% { return % A_LoopField } } } return } ;==================== Add Favorite ====================; f_AddFavoriteK: ; use addfav hotkey, get informations from active window WinGet, w_WinID, ID, A WinGet, w_WinMin, MinMax, ahk_id %w_WinID% if w_WinMin = -1 ; Only detect windows not Minimized. return WinGetClass, w_Class, ahk_id %w_WinID% Gosub, f_AddFavorite return f_GetPath(WindowID, Class) { Global s_Apps_OthersList if Class in #32770 { if A_OSVersion = WIN_VISTA { ControlGetPos, ToolbarPos,,,, ToolbarWindow322, ahk_id %WindowID% if ToolbarPos != { Send, !d ; Set focus on addressbar to enable Edit2 Sleep, 100 ControlGetText, ThisPath, Edit2, ahk_id %WindowID% } } if ThisPath = ; nothing retrieved, maybe it's an old open/save dialog { ControlGetText, ThisFolder, ComboBox1, ahk_id %WindowID% ; current folder name ControlGet, List, List,, ComboBox1, ahk_id %WindowID% ; list of folders on the path Loop, Parse, List, `n ; create array and get position of this folder { List%A_Index% = %A_LoopField% if A_LoopField = %ThisFolder% ThisIndex = %A_Index% } Loop, % ThisIndex ; add path til root { Index0 := ThisIndex - A_Index + 1 ; ThisIndex ~ 1 IfInString, List%Index0%, : ; drive root { ThisPath := SubStr(List%Index0%, InStr(List%Index0%, ":")-1, 2) . "\" . ThisPath break } ThisPath := List%Index0% . "\" . ThisPath } } } else if Class in CabinetWClass,ExploreWClass { if A_OSVersion = WIN_VISTA { ControlGetPos, ToolbarPos,,,, ToolbarWindow322, ahk_id %WindowID% if ToolbarPos != { Send, !d ; Set focus on addressbar to enable Edit2 Sleep, 100 ControlGetText, ThisPath, ComboBoxEx321, ahk_id %WindowID% ; ControlGetText, ThisPath, Edit1, ahk_id %WindowID% } } else ControlGetText, ThisPath, ComboBoxEx321, ahk_id %WindowID% ; ControlGetText, ThisPath, Edit1, ahk_id %WindowID% } else if Class = FM { MouseGetPos, , , , w_Control if w_Control = SysListView322 ; second panel ControlGetText, ThisPath, Edit2, ahk_id %WindowID% else ControlGetText, ThisPath, Edit1, ahk_id %WindowID% } else if Class = wxWindowClassNR { ControlGetPos, Edit1Pos,,,, Edit5, ahk_id %WindowsID% if Edit1Pos != ; it has quick connect bar, addressbar is edit5 ControlGetText, ThisPath, Edit5, ahk_id %WindowID% else ControlGetText, ThisPath, Edit1, ahk_id %WindowID% } else if Class = TfcForm { Send, !g ControlGetText, ThisPath, TfcPathEdit1, ahk_id %WindowID% } else if Class = ConsoleWindowClass { SetKeyDelay, 0 ; This will be in effect only for the duration of this thread. Send, cd > %Temp%\f_cdtmp{Enter} Sleep, 100 FileReadLine, ThisPath, %Temp%\f_cdtmp, 1 FileDelete, %Temp%\f_cdtmp } else if Class in %s_Apps_OthersList% { ControlGetText, ThisPath, Edit1, ahk_id %WindowID% } ; Remove the trailing backslash. if ThisPath != if f_LastIsBackslash(ThisPath) StringTrimRight, ThisPath, ThisPath, 1 return ThisPath } f_GetName(ThisPath) { if ThisPath != f_SplitPath(ThisPath, ThisName, a) Global s_HideExt if s_HideExt SplitPath, ThisName, , , , ThisName if ThisName = ; if empty, use whole path as name. ThisName = %ThisPath% return ThisName } ;==================== Get Win Class Hotkey ====================; f_AddApp: WinGet, w_WinID, ID, A WinGet, w_WinMin, MinMax, ahk_id %w_WinID% if w_WinMin = -1 ; Only detect windows not Minimized. return WinGetTitle, w_Title, ahk_id %w_WinID% WinGetClass, w_Class, ahk_id %w_WinID% if f_AddAppEdit1(w_WinID) ; edit1 exist { MsgBox, 36, Add Application, Title:`t[%w_Title%]`nClass:`t[%w_Class%]`n`nEdit1 exist!`n`nIs this the addressbar of that application? IfMsgBox Yes { MsgBox, 36, Add Application, Do you want to add this application? IfMsgBox Yes Gosub, f_AddApplication } } else { MsgBox, 308, Add Application, Title:`t[%w_Title%]`nClass:`t[%w_Class%]`n`nEdit1 do NOT exist!`n`nDo you still want to add this application? IfMsgBox Yes Gosub, f_AddApplication } Gui, 3:Destroy return f_AddAppEdit1(WinID) { WinGetPos, wx, wy, , , ahk_id %WinID% ControlGetPos, x, y, w, h, Edit1, ahk_id %WinID% ; Get edit1 if x = ; edit1 not found return 0 x := wx + x y := wy + y Gui 3:+LastFound +AlwaysOnTop -Caption +ToolWindow ; +ToolWindow avoids a taskbar button and an alt-tab menu item. Gui, 3:Color, FFBBBB WinSet, Transparent, 128 Gui, 3:Show, x%x% y%y% w%w% h%h% NoActivate ; NoActivate avoids deactivating the currently active window. return 1 } f_AddApplication: ;gui_hh = 0 ;gui_ww = 0 gui_Tab = Applications Gosub, f_OptionsGUI GuiControl, ChooseString, gui_Tab, %gui_Tab% GuiControl, , gui_AppsAddName, %w_Class% Gosub, f_AddOtherApps GuiControl, Choose, gui_AppsListBox, 1 GuiControl, Focus, gui_AppsListBox return ;==================== Open Selected Path Hotkey ====================; f_OpenSel: f_ClipSaved := ClipboardAll Send, ^c Clipwait f_OpenSelected(Clipboard) Clipboard := f_ClipSaved f_ClipSaved = ; Free the memory in case the clipboard was very large. return f_OpenSelected(SelectedPath) { SelectedPath := f_DerefPath(SelectedPath) StringReplace, SelectedPath, SelectedPath, ¢@, \, All ; Remove the trailing backslash. if f_LastIsBackslash(SelectedPath) StringTrimRight, SelectedPath, SelectedPath, 1 if SelectedPath != { Run, explore %SelectedPath%, , UseErrorLevel if ErrorLevel if f_RunPath(SelectedPath) { TrayTip, Error, Could not open "%Clipboard%" ., , 3 return ; don't keep error item } if f_IsFolder(SelectedPath) ; it's a folder f_AddRecent(SelectedPath) else if !s_RecentOnlyFolder ; if recent not only record folders f_AddRecent(SelectedPath) } return } ;==================== Functions ====================; f_Split2(String, Seperator, ByRef LeftStr, ByRef RightStr) { SplitPos := InStr(String, Seperator) if SplitPos = 0 ; Seperator not found, L = Str, R = "" { LeftStr := String RightStr:= "" } else { SplitPos-- StringLeft, LeftStr, String, %SplitPos% SplitPos++ StringTrimLeft, RightStr, String, %SplitPos% } return } f_OpenReg(RegPath) { StringLeft, RegPathFirst4, RegPath, 4 if RegPathFirst4 = HKCR StringReplace, RegPath, RegPath, HKCR, HKEY_CLASSES_ROOT if RegPathFirst4 = HKCU StringReplace, RegPath, RegPath, HKCU, HKEY_CURRENT_USER if RegPathFirst4 = HKLM StringReplace, RegPath, RegPath, HKLM, HKEY_LOCAL_MACHINE StringLeft, RegPathFirst4, RegPath, 4 if RegPathFirst4 = HKEY { RegRead, MyComputer, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Applets\Regedit, LastKey f_Split2(MyComputer, "\", MyComputer, aaa) Global s_DontKillReg if !s_DontKillReg RunWait, % "cmd.exe /c taskkill /IM regedit.exe", , Hide RegWrite, REG_SZ, HKEY_CURRENT_USER, Software\Microsoft\Windows\CurrentVersion\Applets\Regedit, LastKey, %MyComputer%\%RegPath% Run regedit return 0 } else return 1 } f_SendBig5(xx) ; Thanks to Lumania @ Ptt { i := StrLen(xx) if i=0 return Loop { tmp1 := NumGet(xx, 0, "UChar") if tmp1<128 { i-- StringTrimLeft, xx, xx, 1 } else { tmp1 := (tmp1<<8) | NumGet(xx, 1, "UChar") i -= 2 StringTrimLeft, xx, xx, 2 } Send, {ASC %tmp1%} if i = 0 break } } f_SetMenuIcon(Menu, Item, IconPath, Size="") ; Index start from 0, index included in IconPath { Global s_NoMenuIcon, s_IconSize Size := s_IconSize if !s_NoMenuIcon { Menu, Tray, UseErrorLevel f_Split2(IconPath, ",", IconPath, Index) if Index > 0 ; dont change negative index Index++ ; index start from 1 for ahk Menu, %Menu%, Icon, %Item%, %IconPath%, %Index%, %Size% if ErrorLevel ;MsgBox, Menu, %Menu%, Icon, %Item%, %IconPath%, %Index%, %Size% Menu, Tray, UseErrorLevel, OFF } return } f_DerefPath(ThisPath) { StringReplace, ThisPath, ThisPath, ``, ````, All ; StringReplace, ThisPath, ThisPath, `%, ```%, All StringReplace, ThisPath, ThisPath, `%F_CurrentDir`%, ```%F_CurrentDir```%, All Transform, ThisPath, deref, %ThisPath% return ThisPath } f_GetIcon(ThisPath) { Global ThisPath := f_DerefPath(ThisPath) if f_LastIsBackslash(ThisPath) StringTrimRight, ThisPath, ThisPath, 1 if SubStr(ThisPath, 0) = ":" ; Drive { if f_Icons_Drive = { IniRead, f_Icons_Drive, %A_ScriptDir%\Config.ini, Icons, Drive, %A_Space% if f_Icons_Drive = f_Icons_Drive = %f_Icons%,-309 ; built-in icon f_Icons_Drive := f_DerefPath(f_Icons_Drive) } return f_Icons_Drive } else if InStr(FileExist(ThisPath), "D") ; Folder { ; read from desktop.ini first Local IconPath, IconFile, IconIndex IniRead, IconPath, %ThisPath%\Desktop.ini, `.ShellClassInfo, IconResource, %A_Space% if IconPath = { IniRead, IconFile , %ThisPath%\Desktop.ini, `.ShellClassInfo, IconFile , %A_Space% IniRead, IconIndex, %ThisPath%\Desktop.ini, `.ShellClassInfo, IconIndex, %A_Space% if IconFile != IconPath = %IconFile%,%IconIndex% } if IconPath != { IconPath := f_DerefPath(IconPath) return IconPath } if f_Icons_Folder = { IniRead, f_Icons_Folder, %A_ScriptDir%\Config.ini, Icons, Folder, %A_Space% if f_Icons_Folder = f_Icons_Folder = %f_Icons%,-308 ; built-in icon f_Icons_Folder := f_DerefPath(f_Icons_Folder) } return f_Icons_Folder } else if ThisPath = FolderS ; Folder with subfolders { if f_Icons_FolderS = { IniRead, f_Icons_FolderS, %A_ScriptDir%\Config.ini, Icons, FolderS, %A_Space% if f_Icons_FolderS = f_Icons_FolderS = %f_Icons%,-1 ; built-in icon f_Icons_FolderS := f_DerefPath(f_Icons_FolderS) } return f_Icons_FolderS } else if ThisPath in Computer,"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}",::{20D04FE0-3AEA-1069-A2D8-08002B30309D} ; Computer { if f_Icons_Computer = { IniRead, f_Icons_Computer, %A_ScriptDir%\Config.ini, Icons, Computer, %A_Space% if f_Icons_Computer = f_Icons_Computer = %f_Icons%,-310 ; built-in icon f_Icons_Computer := f_DerefPath(f_Icons_Computer) } return f_Icons_Computer } else if ThisPath = Recent ; Recent { if f_Icons_Recent = { IniRead, f_Icons_Recent, %A_ScriptDir%\Config.ini, Icons, Recent, %A_Space% if f_Icons_Recent = { if A_OSVersion = WIN_VISTA f_Icons_Recent := "imageres.dll,-117" else f_Icons_Recent := "shell32.dll,-21" } f_Icons_Recent := f_DerefPath(f_Icons_Recent) } return f_Icons_Recent } else if ThisPath = Menu ; Menu { if f_Icons_Menu = { IniRead, f_Icons_Menu, %A_ScriptDir%\Config.ini, Icons, Menu, %A_Space% if f_Icons_Menu = f_Icons_Menu = %f_Icons%,0 f_Icons_Menu := f_DerefPath(f_Icons_Menu) } return f_Icons_Menu } else if ThisPath = Explorer ; Explorer { if f_Icons_Explorer = { IniRead, f_Icons_Explorer, %A_ScriptDir%\Config.ini, Icons, Explorer, %A_Space% if f_Icons_Explorer = f_Icons_Explorer := "explorer.exe,1" f_Icons_Explorer := f_DerefPath(f_Icons_Explorer) } return f_Icons_Explorer } else ; a file, use its icon { Local ThisExtension ; get file extension SplitPath, ThisPath, , , ThisExtension ; URL if InStr(ThisPath, "http://") or InStr(ThisPath, "https://") ThisExtension = url ; Registry key if SubStr(ThisPath, 1, 2) = "HK" ThisExtension = reg ; Link file if ThisExtension = lnk { Local TargetPath, IconPath, IconIndex FileGetShortcut, %ThisPath%, TargetPath, , , , IconPath, IconIndex if IconPath != return IconPath . "," . IconIndex-1 else return f_GetIcon(TargetPath) } ; Unknown if ThisExtension = ThisExtension = Unknown if ThisExtension contains !, ,&,',(,),*,+,-,.,/,:,<,=,>,\,^,{,|,},~,``,`,,`",`%,`; ThisExtension = Unknown ; Normal file ; first check variables if f_Icons_%ThisExtension% = { ; second read ini for custom icon IniRead, IconPath, %A_ScriptDir%\Config.ini, Icons, %ThisExtension%, %A_Space% if IconPath = { ; third read registry for system default icon if ThisExtension = Unknown RegRead, IconPath, HKEY_CLASSES_ROOT, Unknown\DefaultIcon else { Local FileType RegRead, FileType, HKEY_CLASSES_ROOT, .%ThisExtension% RegRead, IconPath, HKEY_CLASSES_ROOT, %FileType%\DefaultIcon if IconPath = ; check CLSID { Local CLSID RegRead, CLSID, HKEY_CLASSES_ROOT, %FileType%\CLSID RegRead, IconPath, HKEY_CLASSES_ROOT, CLSID\%CLSID%\DefaultIcon } if InStr(IconPath, "%1") ; the file icon is itself (%1 or "%1") { RegRead, CLSID, HKEY_CLASSES_ROOT, %FileType%\CLSID RegRead, IconPath, HKEY_CLASSES_ROOT, CLSID\%CLSID%\DefaultIcon if IconPath = IconPath = This } if IconPath = IconPath := f_GetIcon("") ; get unknown icon if FileType = IconPath := f_GetIcon("") ; get unknown icon } } f_Icons_%ThisExtension% := f_DerefPath(IconPath) } return f_Icons_%ThisExtension% } } f_MenuItemExist(Menu, Item) { Menu, %Menu%, UseErrorLevel Menu, %Menu%, Enable, %Item% if ErrorLevel ; Not exist { Menu, %Menu%, UseErrorLevel, OFF return 0 } else ; Exist { Menu, %Menu%, UseErrorLevel, OFF return 1 } } f_ItemPathExist(ThisPath) { Global if ThisPath = return Local ItemName, ItemPath Loop, % s_FavoritesCount { f_Split2(s_Favorites%A_Index%, "=", ItemName, ItemPath) ItemPath = %ItemPath% ; trim blanks if ItemPath = %ThisPath% return s_Favorites%A_Index% } return } f_TrimVarName(ThisMenu){ Local Temp := ThisMenu StringReplace, ThisMenu, ThisMenu, @, _, All StringReplace, ThisMenu, ThisMenu, !, _, All StringReplace, ThisMenu, ThisMenu, &, _, All StringReplace, ThisMenu, ThisMenu, ', _, All StringReplace, ThisMenu, ThisMenu, (, _, All StringReplace, ThisMenu, ThisMenu, ), _, All StringReplace, ThisMenu, ThisMenu, *, _, All StringReplace, ThisMenu, ThisMenu, +, _, All StringReplace, ThisMenu, ThisMenu, -, _, All StringReplace, ThisMenu, ThisMenu, ., _, All StringReplace, ThisMenu, ThisMenu, /, _, All StringReplace, ThisMenu, ThisMenu, :, _, All StringReplace, ThisMenu, ThisMenu, <, _, All StringReplace, ThisMenu, ThisMenu, =, _, All StringReplace, ThisMenu, ThisMenu, >, _, All StringReplace, ThisMenu, ThisMenu, \, _, All StringReplace, ThisMenu, ThisMenu, ^, _, All StringReplace, ThisMenu, ThisMenu, {, _, All StringReplace, ThisMenu, ThisMenu, |, _, All StringReplace, ThisMenu, ThisMenu, }, _, All StringReplace, ThisMenu, ThisMenu, ~, _, All StringReplace, ThisMenu, ThisMenu, ``, _, All StringReplace, ThisMenu, ThisMenu, `,, _, All StringReplace, ThisMenu, ThisMenu, `", _, All StringReplace, ThisMenu, ThisMenu, `%, _, All StringReplace, ThisMenu, ThisMenu, `;, _, All StringReplace, ThisMenu, ThisMenu, % " ", _, All StringReplace, ThisMenu, ThisMenu, %A_Space%, _, All f_Menu_%ThisMenu% := Temp return ThisMenu } f_LastIsBackslash(ThisPath) { if SubStr(ThisPath, 0) = "\" ; if last is \ { StringTrimRight, ThisPath, ThisPath, 1 ; trim last \ Loop ; prevent ³\¥\»\ problem { if ThisPath = return Mod(A_Index, 2) if Asc(SubStr(ThisPath, 0)) < 128 ; if last char is not lead byte return Mod(A_Index, 2) ; if 1, last char is \ else StringTrimRight, ThisPath, ThisPath, 1 ; trim last, go to next char } } else return 0 } f_SplitPath(ThisPath, ByRef FileName, ByRef Dir) { Temp = %ThisPath% Loop { if f_LastIsBackslash(Temp) { FileNameLength := A_Index-1 break } else StringTrimRight, Temp, Temp, 1 ; trim last, go to next char } StringRight, FileName, ThisPath, FileNameLength StringTrimRight, Dir, ThisPath, FileNameLength+1 return } f_CreateMenuItem(ThisMenu, ThisItem, Quiet=0) { Global if ThisMenu = return "empty" if ThisItem = return "empty" Local ThisItemName, ThisItemPath if SubStr(ThisItem, 1, 1) = ":" ; start with ':' indicates a submenu { Local ThisItemVarName StringTrimLeft, ThisItem, ThisItem, 1 ; trim ':' if InStr(ThisItem, "|") ; a submenu { f_Split2(ThisItem, "|", ThisItemName, ThisItemPath) ThisItemName = %ThisItemName% ; Trim leading and trailing spaces. ThisItemPath = %ThisItemPath% ; Trim leading and trailing spaces. ; use the full path as submenu name to avoid same submenu name in different level ; trim all illegal characters in the display name ThisItemVarName := ThisMenu . "@" . f_TrimVarName(ThisItemName) if !f_MenuItemExist(ThisMenu, ThisItemName) ; first time to create this submenu { i_%ThisItemVarName%ItemPos = 1 ; this submenu initial i_%ThisMenu%ItemPos++ ; parent menu +1 Menu, %ThisItemVarName%, Add Menu, %ThisItemVarName%, DeleteAll } f_CreateMenuItem(ThisItemVarName, ThisItemPath) Menu, %ThisMenu%, Add, %ThisItemName%, :%ThisItemVarName% f_SetMenuIcon(ThisMenu, ThisItemName, f_GetIcon("Menu")) } else ; a itemmenu { f_Split2(ThisItem, "=", ThisItemName, ThisItemPath) ThisItemName = %ThisItemName% ; Trim leading and trailing spaces. ThisItemPath = %ThisItemPath% ; Trim leading and trailing spaces. if f_MenuItemExist(ThisMenu, ThisItemName) { if !Quiet MsgBox, 16, Error, Item [%ThisItemName%] duplicated.`n`nPlease check your config file. Loop { if !f_MenuItemExist(ThisMenu, ThisItemName . " " . A_Index+1) { ThisItemName := ThisItemName . " " . A_Index+1 break } ; return "duplicate" } } ThisItemVarName := ThisMenu . "@" . f_TrimVarName(ThisItemName) Local ItemPos ItemPos := i_%ThisMenu%ItemPos ; Resolve any references to variables within either field i_%ThisMenu%Path%ItemPos% := f_DerefPath(ThisItemPath) f_CreateItemMenu(i_%ThisMenu%Path%ItemPos%, ThisItemVarName, s_MaxDepth) Menu, %ThisMenu%, Add, %ThisItemName%, :%ThisItemVarName% if !s_NoMenuIcon { Local ThisIcon := f_GetIcon(i_%ThisMenu%Path%ItemPos%) if ThisIcon = This ; default icon is %1 ThisIcon := i_%ThisMenu%Path%ItemPos% SetWorkingDir % i_%ThisMenu%Path%ItemPos% f_SetMenuIcon(ThisMenu, ThisItemName, ThisIcon) SetWorkingDir %A_ScriptDir% } i_%ThisMenu%ItemPos++ } } else if ThisItem = - ; '-' indicates a separator { Menu, %ThisMenu%, Add i_%ThisMenu%ItemPos++ } else ; a favorite item { f_Split2(ThisItem, "=", ThisItemName, ThisItemPath) ThisItemName = %ThisItemName% ; Trim leading and trailing spaces. ThisItemPath = %ThisItemPath% ; Trim leading and trailing spaces. if f_MenuItemExist(ThisMenu, ThisItemName) { if !Quiet MsgBox, 16, Error, Item [%ThisItemName%] duplicated.`n`nPlease check your config file. Loop { if !f_MenuItemExist(ThisMenu, ThisItemName . " " . A_Index+1) { ThisItemName := ThisItemName . " " . A_Index+1 break } ; return "duplicate" } } if SubStr(ThisItemPath, 1, 1) = "_" ; special items { if ThisItemPath = _ToolAdd { Menu, %ThisMenu%, Add, %ThisItemName%, f_AddFavorite f_SetMenuIcon(ThisMenu, ThisItemName, f_Icons . ",-301") } else if ThisItemPath = _ToolAddHere { Menu, %ThisMenu%, Add, %ThisItemName%, f_AddFavoriteHere f_SetMenuIcon(ThisMenu, ThisItemName, f_Icons . ",-301") } else if ThisItemPath = _ToolReload { Menu, %ThisMenu%, Add, %ThisItemName%, f_ToolReload f_SetMenuIcon(ThisMenu, ThisItemName, f_Icons . ",-302") } else if ThisItemPath = _ToolToggleHidden { Menu, %ThisMenu%, Add, %ThisItemName%, f_ToolToggleHidden f_SetMenuIcon(ThisMenu, ThisItemName, f_Icons . ",-302") } else if ThisItemPath = _ToolToggleFileExt { Menu, %ThisMenu%, Add, %ThisItemName%, f_ToolToggleFileExt f_SetMenuIcon(ThisMenu, ThisItemName, f_Icons . ",-302") } else if ThisItemPath = _ToolOptions { Menu, %ThisMenu%, Add, %ThisItemName%, f_ToolOptions f_SetMenuIcon(ThisMenu, ThisItemName, f_Icons . ",-303") } else if ThisItemPath = _ToolEdit { Menu, %ThisMenu%, Add, %ThisItemName%, f_ToolEdit f_SetMenuIcon(ThisMenu, ThisItemName, f_Icons . ",-304") } else if ThisItemPath = _ToolExit { Menu, %ThisMenu%, Add, %ThisItemName%, f_ToolExit f_SetMenuIcon(ThisMenu, ThisItemName, f_Icons . ",-305") } else if ThisItemPath = _SystemRecent { Menu, %ThisMenu%, Add, %ThisItemName%, f_SystemRecent f_SetMenuIcon(ThisMenu, ThisItemName, f_GetIcon("Recent")) } else if ThisItemPath = _ExplorerList { Menu, %ThisMenu%, Add, %ThisItemName%, f_ExplorerList f_SetMenuIcon(ThisMenu, ThisItemName, f_GetIcon("Explorer")) } else if ThisItemPath = _DriveList { Menu, %ThisMenu%, Add, %ThisItemName%, f_DriveList f_SetMenuIcon(ThisMenu, ThisItemName, f_GetIcon("Computer")) } else if ThisItemPath = _ToolMenu { f_CreateToolMenu() Menu, %ThisMenu%, Add, %ThisItemName%, :ToolMenu f_SetMenuIcon(ThisMenu, ThisItemName, f_Icons) } else if ThisItemPath = _RecentMenu { f_RecentEnabled = 1 f_ReadRecent() Menu, %ThisMenu%, Add, %ThisItemName%, :RecentMenu f_SetMenuIcon(ThisMenu, ThisItemName, f_Icons . ",-307") } else if ThisItemPath = _DebugMenu { f_CreateDebugMenu() Menu, %ThisMenu%, Add, %ThisItemName%, :DebugMenu f_SetMenuIcon(ThisMenu, ThisItemName, f_Icons . ",-306") } else if ThisItemPath = _SVSMenu { f_CreateSVSMenu() Menu, %ThisMenu%, Add, %ThisItemName%, :SVSMenu f_SetMenuIcon(ThisMenu, ThisItemName, f_Icons . ",-311") } else f_ErrorMsg = %f_ErrorMsg%`"%ThisItemPath%`" is not a valid special item.`n } else ; a normal item { Local ItemPos ItemPos := i_%ThisMenu%ItemPos ; Resolve any references to variables within either field i_%ThisMenu%Path%ItemPos% := f_DerefPath(ThisItemPath) Menu, %ThisMenu%, Add, %ThisItemName%, f_OpenFavorite if !s_NoMenuIcon && !InStr(ThisItemPath, "svscmd.exe") { Local ThisIcon := f_GetIcon(i_%ThisMenu%Path%ItemPos%) if ThisIcon = This ; default icon is %1 ThisIcon := i_%ThisMenu%Path%ItemPos% ; show different icon for folders which has subfolder if s_AltFolderIcon if ThisMenu = TempMenu if SubStr(ThisItemPath, 0) != ":" && SubStr(ThisItemName, 0) != "\" && ThisItemName != "..\" Loop, %ThisItemPath%\*, 2 { ThisIcon := f_GetIcon("FolderS") break } SetWorkingDir % i_%ThisMenu%Path%ItemPos% f_SetMenuIcon(ThisMenu, ThisItemName, ThisIcon) SetWorkingDir %A_ScriptDir% } } i_%ThisMenu%ItemPos++ } return } f_CreateItemMenu(ThisFolderPath, MenuName, MaxDepth, Depth=1) { Global Local ItemCount, FolderList, FileList Menu, %MenuName%, Add Menu, %MenuName%, DeleteAll ; delete old menu i_%MenuName%ItemPos = 1 f_CreateMenuItem(MenuName, "[Open]=" . ThisFolderPath) f_CreateMenuItem(MenuName, "-") ; Remove the trailing backslash if f_LastIsBackslash(ThisFolderPath) StringTrimRight, ThisFolderPath, ThisFolderPath, 1 if MaxDepth = MaxDepth = 2 if ThisFolderPath in Computer,"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}",::{20D04FE0-3AEA-1069-A2D8-08002B30309D} ; Computer, list HDDs { ItemCount++ Local DriveList, DriveSpace, FreeSpace, DriveName DriveGet, DriveList, List, FIXED Loop, Parse, DriveList { DriveGet, DriveSpace, Capacity, %A_LoopField%:\ DriveSpaceFree, FreeSpace, %A_LoopField%:\ DriveName := A_LoopField . ":\ " . Round(FreeSpace/1024,1) . "GB/" . Round(DriveSpace/1024,1) . "GB " . 100*FreeSpace//DriveSpace . "% Free" if (Depth < MaxDepth || MaxDepth = 0) { Local ItemName, ItemVarName, ItemIcon ItemName := DriveName ItemVarName := MenuName . "@" . f_TrimVarName(ItemName) ItemIcon := f_GetIcon("C:") f_CreateItemMenu(A_LoopField . ":\", ItemVarName, MaxDepth, Depth+1) Menu, %MenuName%, Add, %ItemName%, :%ItemVarName% f_SetMenuIcon(MenuName, ItemName, ItemIcon) i_%MenuName%ItemPos++ } else FolderList = %FolderList%%DriveName%=%A_LoopField%:`n } } Loop, %ThisFolderPath%\*, 2 { ItemCount++ if (Depth < MaxDepth || MaxDepth = 0) { Local ItemName, ItemVarName, ItemIcon ItemName := A_LoopFileName ItemVarName := MenuName . "@" . f_TrimVarName(ItemName) ItemIcon := f_GetIcon(A_LoopFileFullPath) f_CreateItemMenu(A_LoopFileFullPath, ItemVarName, MaxDepth, Depth+1) Menu, %MenuName%, Add, %ItemName%, :%ItemVarName% SetWorkingDir % A_LoopFileFullPath f_SetMenuIcon(MenuName, ItemName, ItemIcon) SetWorkingDir %A_ScriptDir% i_%MenuName%ItemPos++ } else FolderList = %FolderList%%A_LoopFileName%`=%A_LoopFileFullPath%`n } Loop, Parse, s_ShowFileExt, `, { Loop, %ThisFolderPath%\*.%A_LoopField%, 0 { ItemCount++ Local Name := A_LoopFileName if s_HideExt SplitPath, Name, , , , Name FileList = %FileList%%Name%`=%A_LoopFileFullPath%`n } } ; sort and merge list Sort, FolderList Sort, FileList, U FileList = %FolderList%%FileList% ; Create items ; ToolTip, Loading Item Menu... Loop, parse, FileList, `n { ; ToolTip, Loading Item Menu...`nItem %A_Index% if A_Index = 500 { MsgBox, 308, Warning, There are more than 500 items (%ItemCount% items)`n`nDo you want to continue? IfMsgBox No break } if A_LoopField != f_CreateMenuItem(MenuName, A_LoopField, 1) } ; ToolTip if i_%MenuName%ItemPos = 3 { f_CreateMenuItem(MenuName, "Empty = nothing") Menu, %MenuName%, Disable, Empty } return } f_CreateToolMenu() { Global Menu, ToolMenu, Add Menu, ToolMenu, DeleteAll ; delete old menu Menu, ToolMenu, Add, &Add Favorite, f_AddFavorite Menu, ToolMenu, Add, Menu, ToolMenu, Add, &Reload, f_ToolReload Menu, ToolMenu, Add, &Options, f_ToolOptions Menu, ToolMenu, Add, &Edit, f_ToolEdit Menu, ToolMenu, Add Menu, ToolMenu, Add, E&xit, f_ToolExit f_SetMenuIcon("ToolMenu", "&Add Favorite", f_Icons . ",-301") f_SetMenuIcon("ToolMenu", "&Reload" , f_Icons . ",-302") f_SetMenuIcon("ToolMenu", "&Options" , f_Icons . ",-303") f_SetMenuIcon("ToolMenu", "&Edit" , f_Icons . ",-304") f_SetMenuIcon("ToolMenu", "E&xit" , f_Icons . ",-305") return } f_CreateDebugMenu() { Global Menu, DebugMenu, Add Menu, DebugMenu, DeleteAll ; delete old menu Menu, DebugMenu, Add, List&Lines, f_ListLines Menu, DebugMenu, Add, List&Vars, f_ListVars Menu, DebugMenu, Add, List&Hotkeys, f_ListHotkeys Menu, DebugMenu, Add, &KeyHistory, f_KeyHistory f_SetMenuIcon("DebugMenu", "List&Lines" , f_Icons . ",1") f_SetMenuIcon("DebugMenu", "List&Vars" , f_Icons . ",1") f_SetMenuIcon("DebugMenu", "List&Hotkeys", f_Icons . ",1") f_SetMenuIcon("DebugMenu", "&KeyHistory" , f_Icons . ",1") return } f_RecentMenu: f_CreateRecentMenu() f_ShowMenu("RecentMenu") return f_CreateRecentMenu() { Global Menu, RecentMenu, Add Menu, RecentMenu, DeleteAll ; delete old menu i_RecentMenuItemPos = 1 if f_RecentList0 != ; if the list is not empty, create recent menu { Local Index0, Indexa Loop, % s_RecentSize { Index0 := A_Index-1 ; 0 ~ 9 (s_RecentSize-1) if A_Index < 11 Indexa := A_Index-1 else Indexa := Chr(86+A_Index) if f_RecentList%Index0% != ; it's not blank { Local ThisName, ThisDir, ThisNameNoExt ThisName := f_RecentList%Index0% if s_HideExt { SplitPath, ThisName, , ThisDir, , ThisNameNoExt ThisName = %ThisDir%\%ThisNameNoExt% } if s_RecentShowIndex f_CreateMenuItem("RecentMenu", "&" . Indexa . " " . ThisName . "=" . f_RecentList%Index0%) else f_CreateMenuItem("RecentMenu", ThisName . "=" . f_RecentList%Index0%) } } Menu, RecentMenu, Add Menu, RecentMenu, Add, Clea&r, f_ClearRecent f_SetMenuIcon("RecentMenu", "Clea&r", f_Icons . ",-305") Menu, RecentMenu, Add } Menu, RecentMenu, Add, &System Recent, f_SystemRecent f_SetMenuIcon("RecentMenu", "&System Recent", f_GetIcon("Recent")) Loop, % s_RecentSize { Index0 := A_Index-1 ; 0 ~ 9 (s_RecentSize-1) Local RecentItem := f_RecentList%Index0% IniWrite, %RecentItem%, %A_ScriptDir%\Config.ini, Recents, Recent%Index0% } return } f_ReadRecent() { Global Local Index0 Loop, % s_RecentSize { Index0 := A_Index-1 ; 0 ~ 9 (s_RecentSize-1) IniRead, f_RecentList%Index0%, %A_ScriptDir%\Config.ini, Recents, Recent%Index0%, %A_Space% } f_CreateRecentMenu() return } f_AddRecent(Path) { Global Local Index0, Index1, ThisIndex Loop, % s_RecentSize ; find if the item already exists { Index0 := A_Index-1 ; 0 ~ 9 (s_RecentSize-1) if f_RecentList%Index0% = %Path% ThisIndex := Index0 } if ThisIndex = ; not found ThisIndex := s_RecentSize-1 ; move all Loop, % ThisIndex ; move only items above this item { Index0 := ThisIndex - A_Index ; ThisIndex-1 ~ 0 Index1 := Index0 + 1 ; ThisIndex ~ 1 f_RecentList%Index1% := f_RecentList%Index0% } f_RecentList0 = %Path% f_CreateRecentMenu() return } f_ClearRecent: f_RecentList0 = Loop, % s_RecentSize-1 f_RecentList%A_Index% = f_CreateRecentMenu() return f_SystemRecent: f_CreateSystemRecentMenu() f_ShowMenu("SystemRecentMenu") return f_CreateSystemRecentMenu() { Menu, SystemRecentMenu, Add Menu, SystemRecentMenu, Delete ; delete old menu if A_OSVersion = WIN_VISTA RecentPath = %AppData%\Microsoft\Windows\Recent ; For Vista / 7 else RecentPath = %UserProfile%\Recent ; For XP ToolTip, Loading Recent Items... Loop, %RecentPath%\*.lnk { ; ToolTip, Loading Recent Items...`nItem %A_Index% FileGetTime, ItemTime FormatTime, ItemTime, %ItemTime%, yyyy/MM/dd HH:mm:ss FileGetShortcut, %A_LoopFileLongPath%, ThisFolderPath Global s_RecentOnlyFolderS if !s_RecentOnlyFolderS ; not only folder, add all { if FileExist(ThisFolderPath) { ThisFolderName = %ThisFolderPath% Global s_HideExt if s_HideExt { SplitPath, ThisFolderPath, , ThisDir, , ThisNameNoExt ThisFolderName = %ThisDir%\%ThisNameNoExt% } RecentFolderList = %RecentFolderList%`n%ItemTime% %ThisFolderName%`=%ThisFolderPath% } } else ; add only folders { if InStr(FileExist(ThisFolderPath), "D") RecentFolderList = %RecentFolderList%`n%ItemTime% %ThisFolderPath%`=%ThisFolderPath% } } ToolTip if RecentFolderList = { f_CreateMenuItem("SystemRecentMenu", "Empty = nothing") Menu, SystemRecentMenu, Disable, Empty } else { ; Sort and create items Sort, RecentFolderList, R ; latest first Global i_SystemRecentMenuItemPos = 1 Loop, parse, RecentFolderList, `n { Global s_RecentSizeS if A_Index > %s_RecentSizeS% break if A_LoopField != { if A_Index < 11 Indexa := A_Index-1 else Indexa := Chr(86+A_Index) Global s_RecentShowIndex if s_RecentShowIndex f_CreateMenuItem("SystemRecentMenu", "&" . indexa . " " . A_LoopField) else f_CreateMenuItem("SystemRecentMenu", A_LoopField) } } } return } f_DriveList: f_OpenTempMenu("""::{20D04FE0-3AEA-1069-A2D8-08002B30309D}""") return f_OpenTempMenu(ThisFolderPath, ShowAll=0) { Global ; fix temp menu position ; by MILK CoordMode, Mouse, Screen Local X, Y, sX, sY MouseGetPos, X, Y sX := s_MenuPositionX sY := s_MenuPositionY ; -65 and -35 aligns current folder item with the mouse position s_MenuPositionX := X - 65 s_MenuPositionY := Y - 35 if f_CreateTempMenu(ThisFolderPath, ShowAll) ; has subfolders { f_ShowMenu("TempMenu") s_MenuPositionX := sX s_MenuPositionY := sY return 1 } else ; no subfolder { f_ShowMenu("TempMenu") s_MenuPositionX := sX s_MenuPositionY := sY return 0 } } f_CreateTempMenu(ThisFolderPath, ShowAll) { Menu, TempMenu, Add Menu, TempMenu, Delete ; delete old menu ; Remove the trailing backslash if f_LastIsBackslash(ThisFolderPath) StringTrimRight, ThisFolderPath, ThisFolderPath, 1 ; Get subfolders list if ThisFolderPath = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" ; Computer, list HDDs { DriveGet, DriveList, List, FIXED Loop, Parse, DriveList { DriveGet, DriveSpace, Capacity, %A_LoopField%:\ DriveSpaceFree, FreeSpace, %A_LoopField%:\ DriveName := A_LoopField . ":\ " . Round(FreeSpace/1024,1) . "GB/" . Round(DriveSpace/1024,1) . "GB " . 100*FreeSpace//DriveSpace . "% Free" SubFolderList = %SubFolderList%%DriveName%=%A_LoopField%:`n } } else { Global s_ShowFileExt if ShowAll Loop, Parse, s_ShowFileExt, `, { Loop, %ThisFolderPath%\*.%A_LoopField%, 0 { FileCount++ Name := A_LoopFileName Global s_HideExt if s_HideExt SplitPath, Name, , , , Name SubFileList = %SubFileList%%Name%`=%A_LoopFileFullPath%`n } } Loop, %ThisFolderPath%\*, 2 { FileCount++ SubFolderList = %SubFolderList%%A_LoopFileName%`=%A_LoopFileFullPath%`n } ; sort and merge list Sort, SubFileList, U Sort, SubFolderList SubFolderList = %SubFolderList%%SubFileList% } Global i_TempMenuItemPos = 1 if ThisFolderPath = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" ; Computer { ThisFolderName = Computer } else if SubStr(ThisFolderPath, 0) = ":" ; it's root, use path as name { ThisFolderName = %ThisFolderPath%\ f_CreateMenuItem("TempMenu", "..\=""::{20D04FE0-3AEA-1069-A2D8-08002B30309D}""") } else ; it's not root, add parent folder item ..\ { f_SplitPath(ThisFolderPath, ThisFolderName, ParentFolderPath) ThisFolderName = %ThisFolderName%\ f_CreateMenuItem("TempMenu", "..\=" . ParentFolderPath) } f_CreateMenuItem("TempMenu", ThisFolderName "=" . ThisFolderPath) f_CreateMenuItem("TempMenu", "-") if SubFolderList = ; if no subfolder { f_CreateMenuItem("TempMenu", "Empty = nothing") Menu, TempMenu, Disable, Empty return 0 } else { ; Create items ToolTip, Loading Items... Loop, parse, SubFolderList, `n { ; ToolTip, Loading Items...`nItem %A_Index% if A_Index = 500 { MsgBox, 308, Warning, There are more than 500 items (%FileCount% items)`n`nDo you want to continue? IfMsgBox No break } if A_LoopField != f_CreateMenuItem("TempMenu", A_LoopField, 1) } ToolTip return 1 } } f_CreateExplorerMenu() { Global Local AllExplorerPaths := f_GetExplorerList() Menu, ExplorerMenu, Add Menu, ExplorerMenu, DeleteAll Local ItemPos = 1 Local Name Loop, Parse, AllExplorerPaths, `n { if A_LoopField = continue f_Split2(A_LoopField, "=", i_ExplorerMenuID%ItemPos%, Name) Menu, ExplorerMenu, Add, %Name%, f_ActivateWindow f_SetMenuIcon("ExplorerMenu", Name, f_GetIcon("Explorer")) ItemPos++ } if ItemPos = 1 { Menu, ExplorerMenu, Add, Empty, f_ActivateWindow Menu, ExplorerMenu, Disable, Empty } return } f_ExplorerList: f_CreateExplorerMenu() f_ShowMenu("ExplorerMenu") return f_ActivateWindow: f_OpenFavPath := i_%A_ThisMenu%ID%A_ThisMenuItemPos% WinActivate, ahk_id %f_OpenFavPath% return f_GetExplorerList() ; Thanks to F1reW1re { WinGet, IDList, list, , , Program Manager Loop, %IDList% { ThisID := IDList%A_Index% WinGetClass, ThisClass, ahk_id %ThisID% if ThisClass in ExploreWClass,CabinetWClass { if A_OSVersion = WIN_VISTA ControlGetText, ThisPath, ToolbarWindow322, ahk_id %ThisID% else ControlGetText, ThisPath, ComboBoxEx321, ahk_id %ThisID% if ThisPath = ; if cannot get path, use title instead WinGetTitle, ThisPath, ahk_id %ThisID% PathList = %PathList%%ThisID%=%ThisPath%`n } } return PathList } f_ToggleFileExt() { RootKey = HKEY_CURRENT_USER SubKey = Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced RegRead, HideFileExt , % RootKey, % SubKey, HideFileExt if HideFileExt = 1 RegWrite, REG_DWORD, % RootKey, % SubKey, HideFileExt, 0 else RegWrite, REG_DWORD, % RootKey, % SubKey, HideFileExt, 1 f_RefreshExplorer() return } f_ToggleHidden() ; thanks to Mr. Milk { RootKey = HKEY_CURRENT_USER SubKey = Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced RegRead, HiddenFiles_Status, % RootKey, % SubKey, Hidden if HiddenFiles_Status = 2 { RegWrite, REG_DWORD, % RootKey, % SubKey, Hidden, 1 RegWrite, REG_DWORD, % RootKey, % SubKey, ShowSuperHidden, 1 } else { RegWrite, REG_DWORD, % RootKey, % SubKey, Hidden, 2 RegWrite, REG_DWORD, % RootKey, % SubKey, ShowSuperHidden, 0 } f_RefreshExplorer() return } f_RefreshExplorer() { WinGet, w_WinID, ID, ahk_class Progman if A_OSVersion = WIN_VISTA SendMessage, 0x111, 0x1A220,,, ahk_id %w_WinID% else SendMessage, 0x111, 0x7103,,, ahk_id %w_WinID% WinGet, w_WinIDs, List, ahk_class CabinetWClass Loop, %w_WinIDs% { w_WinID := w_WinIDs%A_Index% if A_OSVersion = WIN_VISTA SendMessage, 0x111, 0x1A220,,, ahk_id %w_WinID% else SendMessage, 0x111, 0x7103,,, ahk_id %w_WinID% } WinGet, w_WinIDs, List, ahk_class ExploreWClass Loop, %w_WinIDs% { w_WinID := w_WinIDs%A_Index% if A_OSVersion = WIN_VISTA SendMessage, 0x111, 0x1A220,,, ahk_id %w_WinID% else SendMessage, 0x111, 0x7103,,, ahk_id %w_WinID% } WinGet, w_WinIDs, List, ahk_class #32770 Loop, %w_WinIDs% { w_WinID := w_WinIDs%A_Index% ControlGet, w_CtrID, Hwnd,, SHELLDLL_DefView1, ahk_id %w_WinID% if w_CtrID != SendMessage, 0x111, 0x7103,,, ahk_id %w_CtrID% } return } f_CreateSVSMenu() ; thanks to Mr. Milk { Global i_SVSMenuItemPos = 1 Menu, SVSMenu, Add Menu, SVSMenu, DeleteAll ; delete old menu Local LayerName, SVSCommand, LayerStatus, LayerList SVSCommand := "cmd.exe /c svscmd.exe enum -v > " . Temp . "\svsstatus.cfg" RunWait, %SVSCommand%, %A_ScriptDir%, Hide UseErrorLevel if ErrorLevel return Loop, Read, %Temp%\svsstatus.cfg { if SubStr(A_LoopReadLine, 1, 11) != "Layer name:" && SubStr(A_LoopReadLine, 1, 7) != "Active:" continue if SubStr(A_LoopReadLine, 1, 11) = "Layer name:" { StringTrimLeft, LayerName, A_LoopReadLine, 11 LayerName = %LayerName% continue } if SubStr(A_LoopReadLine, 1, 7) = "Active:" { StringTrimLeft, LayerStatus, A_LoopReadLine, 7 LayerStatus = %LayerStatus% if LayerStatus = No LayerStatus := "A" else LayerStatus := "D" SVSCommand := LayerName . "=" . "svscmd.exe -W " . """" . LayerName . """" . " " . LayerStatus LayerList = %LayerList%%SVSCommand%`n } } Sort, LayerList Loop, Parse, LayerList, `n { f_CreateMenuItem("SVSMenu", A_LoopField) if SubStr(A_LoopField, -1) = " D" { LayerName := SubStr(A_LoopField, 1, InStr(A_LoopField, "=")-1) Menu, SVSMenu, Check, %LayerName% } } if LayerList != Menu, SVSMenu, Add Menu, SVSMenu, Add, Run SVS Admin, f_SVSAdmin f_SetMenuIcon("SVSMenu", "Run SVS Admin", f_Icons . ",-311") return } ;==================== Labels ====================; ;f_RButton: ;Thread, Priority, 1 ;MouseGetPos, , , w_WinID ;WinGetClass, w_Class, ahk_id %w_WinID% ;if w_Class = #32768 ;{ ; WinGet, w_ProcessName, ProcessName, ahk_id %w_WinID% ; msgbox, % w_ProcessName ; f_RightClick = 1 ; Click ;} ;return f_DisplayMenu1DB: if (A_PriorHotkey = A_ThisHotKey && A_TimeSincePriorHotkey < 500) { if A_ThisHotKey contains LButton { ControlGet, f_SelectedFile, List, Selected, SysListView321, A if f_SelectedFile != return } Gosub, f_DisplayMenu1 } return f_DisplayMenu15DB: if (A_PriorHotkey = A_ThisHotKey && A_TimeSincePriorHotkey < 500) { if A_ThisHotKey contains LButton { ControlGet, f_SelectedFile, List, Selected, SysListView321, A if f_SelectedFile != return } Gosub, f_DisplayMenu15 } return f_DisplayMenu2DB: if (A_PriorHotkey = A_ThisHotKey && A_TimeSincePriorHotkey < 500) { if A_ThisHotKey contains LButton { ControlGet, f_SelectedFile, List, Selected, SysListView321, A if f_SelectedFile != return } Gosub, f_DisplayMenu2 } return f_OpenSelDB: if (A_PriorHotkey = A_ThisHotKey && A_TimeSincePriorHotkey < 500) Gosub, f_OpenSel return f_AddAppDB: if (A_PriorHotkey = A_ThisHotKey && A_TimeSincePriorHotkey < 500) Gosub, f_AddApp return f_AddFavoriteKDB: if (A_PriorHotkey = A_ThisHotKey && A_TimeSincePriorHotkey < 500) Gosub, f_AddFavoriteK return f_ToolReloadDB: if (A_PriorHotkey = A_ThisHotKey && A_TimeSincePriorHotkey < 500) Gosub, f_ToolReload return f_ToolOptionsDB: if (A_PriorHotkey = A_ThisHotKey && A_TimeSincePriorHotkey < 500) Gosub, f_ToolOptions return f_ToolEditDB: if (A_PriorHotkey = A_ThisHotKey && A_TimeSincePriorHotkey < 500) Gosub, f_ToolEdit return f_ToolExitDB: if (A_PriorHotkey = A_ThisHotKey && A_TimeSincePriorHotkey < 500) Gosub, f_ToolExit return f_ToolReload: Reload return f_ToolOptions: ;gui_hh = 0 ;gui_ww = 0 gui_Tab = Gosub, f_OptionsGUI return f_ToolEdit: Run, %A_ScriptDir%\Config.ini return f_ToolExit: Exitapp return f_ListLines: ListLines return f_ListVars: ListVars return f_ListHotkeys: ListHotkeys return f_KeyHistory: KeyHistory return f_ToolToggleHidden: f_ToggleHidden() return f_ToolToggleFileExt: f_ToggleFileExt() return f_SVSAdmin: f_CreateSVSMenu() Run, "svsadmin.exe" return #Include %A_ScriptDir%\GUI.ahk #Include %A_ScriptDir%\Lib.ahk