Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Create a keyboard-shortcut for Show Package Contents Desktop
In case you're new to the Mac, let me give you a bit of a background. In the Mac OS X filing system, there are some special kinds of folders that are treated like files. These folders-treated-as-files are known as packages. A Pages document, for example, is actually a folder package. So are most applications.

At times, it can be advantageous to see the contents of these packages, and you can do that by control-clicking on the package and choosing 'Show Package Contents' from the pop-up menu, or by selecting the package and clicking on the Action button in the Finder's toolbar and selecting 'Show Package Contents.' Enter my dilemma. As a long-time Mac user, whenever I need to navigate through the filesystem, I usually use keyboard shortcuts such as starting to type the name of the file/folder I want to navigate to or through. However, there is no keyboard shortcut to reveal the contents of packages, and since the command is not found in the Finder's menu bar, I can't easily create one through System Preferences.

The solution: Automator and AppleScript with GUI Scripting.

Requirements:
  1. Apple Script GUI Scripting must be enabled. Open the AppleScript Utility, located in /Applications -> AppleScript. Make sure the 'Enable GUI Scripting' check box is checked.
  2. The Action button must be on the toolbar of your Finder windows. (It's the button that has the picture of a gear.) If it's not, open a Finder window and choose View -> Customize Toolbar from the Finder menu, and drag the "gear" button up to the toolbar from the resulting dialog sheet.
  3. This Automator application [macosxhints mirror] I created.
  4. A program that you can use to configure a keyboard shortcut to launch the application. Since Butler is one of my favorite programs, I used it to set up Control-Command-O as a trigger that only works in the Finder, and runs the Automator program.
A couple of notes. You should be able to use Automator to open up and view the actual workflow I created (just drag and drop it onto Automator). If you want to edit it and tweak it, feel free. If you do, you may notice it starts running in the Dock. See this hint to make it a faceless application again. Also, the first run will probably be slow, but successive runs should be run more quickly.

[robg adds: I use FolderGlance to drill into packages, but it's still not a hotkey-accessible solution. I tested the Automator app and it works as described.]
    •    
  • Currently 1.83 / 5
  You rated: 1 / 5 (6 votes cast)
 
[37,226 views]  

Create a keyboard-shortcut for Show Package Contents | 8 comments | Create New Account
Click here to return to the 'Create a keyboard-shortcut for Show Package Contents' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Create a keyboard-shortcut for Show Package Contents
Authored by: redsweater on Jul 25, '06 08:30:08AM
Here is an AppleScript that works on most types of packages (e.g. Apps) and is very, very fast. No UI Scripting required:

tell application "Finder"
	try
		set selectedItems to selection
		set selectedItem to item 1 of selectedItems as alias
		open folder ((selectedItem as string) & "Contents:")
	on error
		display dialog "You must select a package before running this script."
	end try
end tell

---
--
Daniel Jalkut
http://www.red-sweater.com/

[ Reply to This | # ]

Create a keyboard-shortcut for Show Package Contents
Authored by: bfad on Jul 25, '06 09:22:55AM

As you said, your AppleScript works great for Applications, but what about things like iWeb documents or Pages documents? Your AppleScript doesn't help if I want to see their contents.



[ Reply to This | # ]
Create a keyboard-shortcut for Show Package Contents
Authored by: wootest on Jul 25, '06 08:31:41AM

Not to be facetious or anything, but I quite like how it chose from my path button instead of my context action button just because my toolbar, like so many others, are not identical to the default configuration. ;) I do see that care has been taken to work around it when watching the source (in Contents/document.wflow of the downloadable Automator workflow), but it will need some particular nudging to get around my weird configuration, apparently.



[ Reply to This | # ]
Create a keyboard-shortcut for Show Package Contents
Authored by: bfad on Jul 25, '06 09:31:21AM

I did test the script with a variety of toolbar configurations, and I got it to work no matter what the configuration for my machine.

Here's what I discovered when writing the workflow:
The GUI Scripting command telling it which "group" was affected by three items being on the toolbar: the Spotlight Search field, the Path Button, and the Action Button.

If, of those three, the Action Button was the only one present, then it needed to be "group 1"
If the Action Button and one of the other elements were present, it needed to be "group 2"
If all three elements were present, it needed to be "group 3"

Originally I was going to have users configure the script themselves by changing "group x" to match the above configuration, but I figured if I started trying with 3, I could work my way down and not run into conflict with the Path Button. Apparently I was wrong.

How is your toolbar configured, so I can test it out on my computer?



[ Reply to This | # ]
Create a keyboard-shortcut for Show Package Contents
Authored by: wootest on Jul 25, '06 01:01:01PM

[back/forward], [view picker], [path popup], [action menu].



[ Reply to This | # ]
Create a keyboard-shortcut for Show Package Contents
Authored by: dan55304 on Jul 26, '06 06:56:42AM

What's wrong with right mouse button or contextual menu to "Show Package Contents"? That has to be faster than running a script.



[ Reply to This | # ]
Create a keyboard-shortcut for Show Package Contents
Authored by: bewebste on Jul 26, '06 07:56:16AM
I had similar problems getting the script to work with my toolbar config (I have back/forward, view, path, action, separator, delete, new folder, get info, flexible space, search), where it would select from the path menu. I made this mod to part of the script which searches for the action button based on its help text (doesn't have a proper "name" property unfortunately).

tell tool bar 1
	repeat with i from 1 to count of groups
		if help of group i begins with "Action" then
			set groupIndex to i
		end if
	end repeat
	try
		click menu button 1 of group groupIndex
	on error
		tell application "Finder" to display dialog "The action button needs to be on the toolboar"
		return "No Action"
	end try
end tell
Just replace the existing "tell tool bar 1" block in the script with this to apply. Does this work for others?

[ Reply to This | # ]
Create a keyboard-shortcut for Show Package Contents
Authored by: MJCube on Oct 09, '07 05:43:57PM

I love this site. I wanted to find this exact thing just now and this hint was the first Google hit. I decided to put the AppleScript from the first comment into a QuicKeys macro and assign my keystroke to that: works like a charm. Also, for curiosity, I tried adding the keystroke to my Finder .plist in the usual way. The result is that the keystroke shows up in the Action menu (the little gear), but not in the contextual menu (right-click), and it doesn't work. But it serves as a reminder of the keystroke I assigned in QuicKeys!



[ Reply to This | # ]