PDA

View Full Version : Can someone make me a plugin?




sorryiwasdreami
Jun 22, 2006, 12:05 PM
I've been searching all over the place to find a way to add a contextual menu item to finder. It looks like they can be added using Applescript or via a finder plugin.

Anyway, I can't find the one I'm looking for anywhere. It already exists in os x and is under the "view" menu. It's the "Clean Up" function; it's the action that cleans up icons and aligns them to a grid. What I need is that exact same action under the menu when I right click in a finder windowójust a simple "Clean Up" under the contextual menu upon right clicking.

I really don't want an application to handle this or any complicated solution. The key is to simply right click and select it. It would work in any finder window's contextual menu. Having this would really speed up my workflow.

Does anyone know where to get such a plugin/Applescript? Does anyone know how write one (or know how to copy the existing one)? That would be exquisite.



XNine
Jun 22, 2006, 02:28 PM
Automator is your friend.

sorryiwasdreami
Jun 22, 2006, 02:35 PM
Can you tell me how to do this with automator? I must have skipped something.

XNine
Jun 22, 2006, 03:02 PM
Well, you build your actions in Automator, and then when you're done you SAVE AS... Finder Plugin and it puts it under the contextual menu. I'm pretty sure thsi can be done in automator, but I'm at work right now and don't have access to automator here.

IF need be I'll build the script and host it for you to DL.

sorryiwasdreami
Jun 22, 2006, 03:08 PM
I have used Automator to build several workflows such as setting my display to sleep or remain awake, rename, and combine pdfs. But, I used actions that were already present in automator to do this and then save as plugins.

So I understand how to save automator actions as finder plugins, but I don't know how to import an action in order to make it available for use.

Any help would be very much appreciated; I'm interested in learning how to do this.

robbieduncan
Jun 22, 2006, 03:40 PM
See attached (created in Automator). You need to unzip this and save it in ~/Library/Workflows/Applications/Finder/

So how did I do it?

To start with I looked at the available Automator actions and realised none of them would help.

So I fired up the script editor and opened the Finder dictionary and quickly find the Clean Up command.

So I wrote this script:


tell application "Finder"
tell front window to clean up
end tell


which seemed to work (it tells whatever the front-most Finder window is to clean up.

So I then looked into Automator and found the AppleScript action in the Automator section. A quick copy and paste of that code and I was done.

Enjoy :D

robbieduncan
Jun 22, 2006, 03:44 PM
OK I've found an annoyance: the Finder window you right click in looses focus :(

To fix this change the code in the action to


on run {input, parameters}

tell application "Finder"
tell front window to clean up
activate
end tell

return input
end run


(Note the activate line)

sorryiwasdreami
Jun 23, 2006, 11:18 AM
Wow awesome! I didn't know there were these "dictionaries." Thanks for all your help!

I am getting errors with the script, but I am looking into it and trying to figure out why.

Thanks again.

sorryiwasdreami
Jun 23, 2006, 11:32 AM
Where in the Finder dictionary can you see the actual scripting code for these things? How do you show it?

robbieduncan
Jun 23, 2006, 11:43 AM
Where in the Finder dictionary can you see the actual scripting code for these things? How do you show it?

What do you mean by "actual scripting code"? The dictionary tells you about the objects that are available and the properties and methods those objects expose. That's all you need.