This code is working nicely in Windows 7, but I'm curious if there are any adjustments necessary for Windows Vista or XP. Since the path isn't necessarily in the Explorer window title, I got it from the window text ("Address: "). Any feedback would be appreciated, especially to make it more reliable for getting folder paths from Windows Explorer.
Code:
;~ ; Add Open Folders to Links
GroupAdd, opensavedialog, ahk_class #32770
GroupAdd, opensavedialog, Open
GroupAdd, opensavedialog, Save As
GroupAdd, opensavedialog, Save
GroupAdd, opensavedialog, Import
GroupAdd, opensavedialog, Export
Loop
{
WinWaitActive, ahk_group opensavedialog
thisdialog := WinExist("A")
SetTitleMatchMode, RegEx
match:="ahk_class (?:Cabinet|Explore)WClass"
WinGet, wList, List, %match%
Loop % wList {
WinGetText, wintxt, % "ahk_id " wList%A_Index%
StringGetPos, ret, wintxt, `r`n
wPath := SubStr(wintxt, 10, ret - 9)
SplitPath, wPath, name
IfExist, C:\Users\%A_UserName%\Links\%name%.lnk
Break
FileCreateShortcut, %wPath%, C:\Users\%A_UserName%\Links\%name% OPEN.lnk, , , %A_Now%
}
SetTitleMatchMode, 1
ControlClick, SysTreeView321, ahk_id %thisdialog%,,,,,NA ; refresh Favorites/Links in Sidebar
Send, {F5}
WinWaitClose, ahk_id %thisdialog%
FileDelete, C:\Users\%A_UserName%\Links\*OPEN.lnk
}
Thanks to sinkfaze for his
help.