Favorite Folders popup menu that you can change on the fly.
Favorite Shortcuts is probably a better name for it now.
Features:
- Popup menu is made up of standard Windows shortcut file types ( .lnk, .url and .pif )
- Shortcuts to folders, files, executables and web pages can all be displayed on the menu
- Subfolders within the base folder produce submenus only if they contain shortcuts ( no empty submenus are produced )
- The base folder will be created upon first run of the script if it does not exist
- Supported window types and their actions:
--- folder shortcuts will cause the directory to change in several window types:
----- Standard file-open or file-save dialogs
----- Explorer windows
----- Console (command prompt) windows
----- Microsoft Office file Open and Save As dialogs
----- Directory Opus and Console
--- file shortcuts will load the target into file-open dialogs
--- url shortcuts will redirect open browsers to their target
- (option) Outside of the supported windows all shortcuts will be run in their default way, as if you double clicked on the shortcut itself
- NEW (option) Windows Special folders and Virtual folders can be added to the menu
- Three items appear at the bottom of the popup menu:
--- Add Folder to Favorites - allows the user to add new folder shortcuts to the base folder
--- Add File to Favorites - allows the user to add new file shortcuts to the base folder
--- Edit Favorites Folder - conveniently opens an explorer window to the base folder
- Valid paths can be extracted from any window title ( if it shows the full path ) or from the clipboard or can be typed in manually
- Any shortcut that cannot be put in through the menu ( executables and urls ) can be drag and droped into the base folder or subfolders in the usual way
- You can order the menu and add seperator lines by adding a comment to the shortcut file: menu=(integer) [blank] example: "menu=2" or "menu=12 blank"
Tips:
- For AutoHotkey programmers whose editor shows the full path in the title bar:
Quickly test run scripts your working on by adding it through 'Add File to Favorites'.
Then select your script from the menu. AutoHotkey will start and run the script.
-
-To add a file or folder to the menu directly from an Explorer window:
Select the file or folder. Right-click->Copy. Minimize all windows. Bring up your favorites menu and use the 'Add' items at the bottom.
Tested only on WinXP with AutoHotkey 1.0.46.05
LAST UPDATED: Jan 13 2007
DOWNLOAD
Updates:
Jan 13/07
- fixed bug that stopped it from working with AHK ver 1.0.46
- added basic warning messages when a shortcut could not be run.
Oct 20/06
- added optional menu items for Windows special folders using their GUID
Oct 13/05
- fixed bug that didn't handle identical named shortcuts in different folders properly
- added better error checking for dynamic variable names that are too long
Oct 11/05
- fixed bug that read in the enviroment path variable when no valid path was found in window title or clipboard.
- added support for .pif files
- added support for ordering menu items (.lnk files only) and adding seperator lines, thru the comment field of the .lnk files
- added more error checking
Sept 24/05
- made static hotkey into dynamic hotkey
- made seperate option to show menu for unsupported windows ( not linked to ~ )
- fixed bug that caused long paths in the favorites folder to crash script
- fixed bug(s) that caused paths to be found for windows without focus sometimes
Sept 22/05
- moved static hotkey to end of autoexecute section
What I am trying to say here is - it is far more easier to keep all your favorite folders as shortcuts and store them in one easy-to-access folder
than storing them in an ini-file/registry/memory/USB card/tape drive or anywhere else (sorry for being offensive). Of course, you can then load your menu by listing all the shortcuts available in that folder.
There are several powerful advantages of using this approach:
# Reusbalility - First of all you & Windows can use this list let alone other zillion of uses.
# Manageability - I don't have to emphasize that Windows Explorer is a far better tool to manage files/folders/shortcuts then any other custom GUI that you may build. I know there are better file managers. The point is why recreate?
# Dynamic - If you move your favorite folders around, Windows automatically remap the shortcuts to point to the new location.
# Fewer lines of code - Your ahk script would not be more than 10-15 lines of code to implement this.
Should I emphasize more?
I have used "FavoriteFolders" script the way it was posted. Also, I have used it the way I said. I need not not say that I didn't revert back.
IMHO, it is worth switching to this method.
I can also post my script if you agree with this.
Sandeep
That problem doesn't occur on all browsers. For example, MSIE will correctly copy and paste the script above; that is, it will not add extra line-breaks everywhere the text wraps.Sorry about the broken up lines guys!
That's high on the to-do list.Does AHK have a way of continuing a command on more than one line.
That sounds pretty neat. It reminds me of how some FTP servers can store their links either in a text file or as shortcuts in the file system (i.e. shortcuts become real folders when seen by an FTP user).What I am trying to say here is - it is far more easier to keep all your favorite folders as shortcuts and store them in one easy-to-access folder than storing them in an ini-file/registry/memory/USB card/tape drive or anywhere else (sorry for being offensive). Of course, you can then load your menu by listing all the shortcuts available in that folder.
But how do you "read" the shortcut in a script to find out what it points to? Perhaps you're using the name of the shortcut as the menu item name, and then launching the shortcut when the user picks it on the menu. But that doesn't seem like it would work for the command prompt and for those standard file-open and file-save dialogs.
The reason for my revisions to the script were speed and convenience in adding to, and editing the menu list. It may and probably does have other shortcomings, or at least there may be better ways to achieve the same end.
That's what I have really enjoyed about this forum. We all contibute ideas and build on each other's work, creatively improving scripts.
Could you explain how this would work? Or perhaps it will become clear after I use your code.# Reusbalility - First of all you & Windows can use this list let alone other zillion of uses.
# Manageability - I don't have to emphasize that Windows Explorer is a far better tool to manage files/folders/shortcuts then any other custom GUI that you may build. I know there are better file managers. The point is why recreate?
True, we will probably never make anything as robust or all encompassing, or as full of options. But that sometimes is the problem. There are times when I want a tool for a repetitive task that is simple, quick, and can do just one thing but do it good. ( My Unix background is heavily affecting me here ) I will soon post another script that I think shows this. Something Windows can do, but not fast enough or convenient enough for my taste.
This one realy has merit! Definitely worth using.# Dynamic - If you move your favorite folders around, Windows automatically remap the shortcuts to point to the new location.
Always a good thing!# Fewer lines of code
Comment from moderator: Large script removed because the very first post of this topic contains these updates.It works the same way with following two problems:
# In Windows Explorer - it always open new window.
# In Command Window - it doesn't work at all (I have not removed the code though)
The problem is I couldn't find anyway to know the target of a shortcut. There is a way to do that in WSH, but I don't how to do this in AHK.
Chris: Would it be possible for you to add function to parse the .lnk in future releases? It would be quite handy.
Sandeep
I know adding .lnk parsing in AutoHotKey itself just for this purpose may not sound like a good idea. But, I couldn't find a better way.
It is actually very frustrating to see that .lnk file actually stores the target in plain text, only I couldn't use it.
Any suggestions or ideas are welcome.
Sandeep
I'll definitely look into that for the next release or the one after that. Thanks.Would it be possible for you to add function to parse the .lnk in future releases? It would be quite handy.
You are too fast Chris! Thanks!
Comment from moderator: Large script removed because the very first post of this topic contains these updates.Caution: It works only with the latest installer!
And now, Shortcut creation is added...it is not really far when we will be able to use AutoHotKey for a complete setup program.
Thanks Chris!
The reason I still have an .ini file is so the popup menu can be ordered the way I like it ( most used shortcut on top ) instead of which ever way "Loop, %f_shortcuts_folder%\*.lnk" reads in the shortcuts.
If you do drag and drop a link file into the f_shortcuts_folder it will still show up in the menu ( not absolute dependance on the .ini file ).
Things that are still needed:
- I can add shortcuts real easy, but not as easy to delete them.
Have to delete it from the .ini file and then delete the link file from f_shortcuts_folder.
I'm thinking maybe a right click over the popup menu item and select "Delete Favorite" from another popup menu.
Is this possible Chris?
Thanks to Sandeep for the link file idea and to Chris for implimenting it so fast!
Comment from moderator: Large script removed because the very first post of this topic contains these updates.
If you want your list sorted the way you like then put numbers in front of the shortcut. Loop, always gives the sorted list.
Moreover, if you have really big list, it is anyway best to show it sorted alphabetically.
I am insisting on shortcuts just because I can reuse this list in other ways and also all the reasons of dynamic, easy-to-manage.
By reusable I mean, since most new dialog boxes show a shortcut of My Documents on the left, you are only two clicks away to you favourite folders even if you do not have AHK or don't remember the shortcut to show popup or just want to do it differently. Same way if you create a shortcut(on desktop or anywhere) of the folder that contains shortcuts, you get instant access to all of your folders. BTW, if you keep this shortcut-to-favorite-folder in Favorites folder of IE, you can even access your folders directly within IE.
Lastly, I would never store two similar data elements in two different locations. In this case, ini file and folder with .lnk files.
What do you think?
This is true on NTFS, but not FAT/FAT32.Loop, always gives the sorted list
More details posted by others on the newsgroups:
I have added comments about this to the help file.The way to see if they will be sorted or not is to go to the directory you're interested in and type "dir" at the command prompt. "dir" without switches uses the results [without any sorting]
Files names are stored in a sorted b-tree in the NTFS file system. The sort happens when the file is created or renamed. Because of this, FindXxxx returns the file names in an order closely matching an alphabetical sort. I say "closely matching" because it does not use any of the standard collating features of the C standard library, and the order seems particularly funky on non-western european language systems.
I still think that storing in an ini file is not a good idea.