Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Favorite Folders popup menu that you can change on the fly.


  • Please log in to reply
172 replies to this topic
ChrisM
  • Members
  • 58 posts
  • Last active: Oct 25 2006 05:56 PM
  • Joined: 28 Nov 2004
Here's my latest version of this handy shortcut menu.
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

Sandeep
  • Guests
  • Last active:
  • Joined: --
What is the benefit of creating a file to store favorite folders over storing them as shortcuts itself in a specific folder in let's say "My Documents" folder?
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

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

Sorry about the broken up lines guys!

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.

Does AHK have a way of continuing a command on more than one line.

That's high on the to-do list.

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.

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).

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.

ChrisM
  • Members
  • 58 posts
  • Last active: Oct 25 2006 05:56 PM
  • Joined: 28 Nov 2004
Please post your script. The proof is in the using. What you say certainly sounds reasonable. I had not considered that possibility.

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.


# Reusbalility - First of all you & Windows can use this list let alone other zillion of uses.

Could you explain how this would work? Or perhaps it will become clear after I use your code.

# 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.

# Dynamic - If you move your favorite folders around, Windows automatically remap the shortcuts to point to the new location.

This one realy has merit! Definitely worth using.

# Fewer lines of code

Always a good thing!

  • Guests
  • Last active:
  • Joined: --
Here is my script
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

Sandeep
  • Guests
  • Last active:
  • Joined: --
Yes! You are right Chris, I faced the same problems as you mentioned, but it works well in file open dialog boxes. If only I could get the target from .lnk file within the script itself, it would have been quite usable solution in all cases.
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

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

Would it be possible for you to add function to parse the .lnk in future releases? It would be quite handy.

I'll definitely look into that for the next release or the one after that. Thanks.

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Thanks to Holger, the code was available to easily implement this feature. It has been added to today's updated installer.

Thanks for the suggestion.

Sandeep
  • Members
  • 10 posts
  • Last active: Dec 01 2004 12:29 PM
  • Joined: 29 Nov 2004
Now it does work exactly as the original FavoriteFolder script.
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!
Sandeep

Sandeep
  • Members
  • 10 posts
  • Last active: Dec 01 2004 12:29 PM
  • Joined: 29 Nov 2004
Since we already had Registry functions, File operations, GUI creation, Built-in variables.
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!
Sandeep

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Your script above looks good; thanks for posting it. If anyone feels this should be the preferred/showcase way to use Favorite Folders, please post here. We could also have a poll, or simply leave things the way they are for a while.

ChrisM
  • Members
  • 58 posts
  • Last active: Oct 25 2006 05:56 PM
  • Joined: 28 Nov 2004
I made an attempt at merging the two scripts from above. It seems to be stable. I post it for comments, ideas, criticism.

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.


Sandeep
  • Members
  • 10 posts
  • Last active: Dec 01 2004 12:29 PM
  • Joined: 29 Nov 2004
I don't think sorting is good enough reason to have an ini file.
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?
Sandeep

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004

Loop, always gives the sorted list

This is true on NTFS, but not FAT/FAT32.

More details posted by others on the newsgroups:

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 have added comments about this to the help file.

Sandeep
  • Members
  • 10 posts
  • Last active: Dec 01 2004 12:29 PM
  • Joined: 29 Nov 2004
But, then I would transfer the result into delimited string and then sort the string and do a loop to show the list in sorted order. And, if I want some particular folders in the top order, I would prefix them with numbers.
I still think that storing in an ini file is not a good idea.
Sandeep