Skip to content

Instantly share code, notes, and snippets.

@akaleeroy
Last active January 20, 2019 13:47
Show Gist options
  • Save akaleeroy/947c06223dd48aadc51fef8069b72c7f to your computer and use it in GitHub Desktop.
Save akaleeroy/947c06223dd48aadc51fef8069b72c7f to your computer and use it in GitHub Desktop.
Quick Folder Aliases - Self-shortcut aliases to help you find a folder by several names

Quick Folder Aliases

Windows AutoHotkey Usability Accelerator

Quick Folder Aliases with Hotkey

In Windows Explorer press Win + F2 or Win + ; to create a self-shortcut alias for the currently opened folder.

Now that folder can be located by either the original name or the aliases. Just hit Win and start searching by any of the terms.

Known limitations

If you rename the original folder the aliases will fall out of sync.

; Quick Folder Aliases in Windows Explorer
; Quickly generate a self-shortcut inside the currently opened folder
; Only active if class and control check match
; TODO Only when background is selected, not when some file is selected
#If WinActive("ahk_class CabinetWClass") && IsExplorerFilePane()
#F2:: ; Watch out for conflicts with ClipX > Paste last and pop
#;::
CreateShortcutOfWindow("A")
Return
#If
CreateShortcutOfWindow(pathOfWindow) {
; Get address of current window
; Windows 7 - ToolbarWindow322
ControlGetText, WindowAddress, ToolbarWindow322, % pathOfWindow
; Windows 8, Windows 10 - ToolbarWindow323
if not (WindowAddress) {
ControlGetText, WindowAddress, ToolbarWindow323, % pathOfWindow
}
WindowAddress := StrReplace(WindowAddress, "Address: ", "")
; Get folder name using SplitPath
SplitPath, WindowAddress, FolderName, FolderDir
; Construct .lnk path
LinkPath := WindowAddress "\Alias of " FolderName ".lnk"
FileCreateShortcut, %WindowAddress%, %LinkPath%, %WindowAddress%, , Alias of %FolderName%
; TODO Something more reliable than Sleep
Sleep, 800
ControlFocus, DirectUIHWND3, % pathOfWindow
; Select the newly created shortcut and enter rename mode
SendInput, Alias of %FolderName%.lnk{F2}
Return
}
IsExplorerFilePane() {
ControlGetFocus, fc, A
Return ((fc = "DirectUIHWND3") ? true : false)
}
@akaleeroy
Copy link
Author

Improvements contributed by /u/GroggyOtter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment