Can someone make me a plugin?

Discussion in 'Mac Programming' started by sorryiwasdreami, Jun 22, 2006.

  1. macrumors 6502a

    sorryiwasdreami

    Joined:
    Apr 24, 2004
    Location:
    way out in the sticks
    #1
    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.
     
  2. macrumors 68040

    XNine

    Joined:
    Apr 7, 2005
    Location:
    Why are you wearing that stupid man suit?
    #2
    Automator is your friend.
     
  3. thread starter macrumors 6502a

    sorryiwasdreami

    Joined:
    Apr 24, 2004
    Location:
    way out in the sticks
    #3
    Can you tell me how to do this with automator? I must have skipped something.
     
  4. macrumors 68040

    XNine

    Joined:
    Apr 7, 2005
    Location:
    Why are you wearing that stupid man suit?
    #4
    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.
     
  5. thread starter macrumors 6502a

    sorryiwasdreami

    Joined:
    Apr 24, 2004
    Location:
    way out in the sticks
    #5
    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.
     
  6. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    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:

    Code:
    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
     

    Attached Files:

  7. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #7
    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

    Code:
    on run {input, parameters}
    	
    	tell application "Finder"
    		tell front window to clean up
    		activate
    	end tell
    	
    	return input
    end run
    
    (Note the activate line)
     
  8. thread starter macrumors 6502a

    sorryiwasdreami

    Joined:
    Apr 24, 2004
    Location:
    way out in the sticks
    #8
    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.
     
  9. thread starter macrumors 6502a

    sorryiwasdreami

    Joined:
    Apr 24, 2004
    Location:
    way out in the sticks
    #9
    Where in the Finder dictionary can you see the actual scripting code for these things? How do you show it?
     
  10. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #10
    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.
     

Share This Page