Contextual Menu Items/Services

This is the second one that has stumped me.

I use Better Finder Renamer a lot and I often highlight a list of files and the right click and go to the service “Better Renamer 9…” which sends it there. It would be awesome to be able to hit a trigger instead of going to the right click–>service, but I haven’t found any info in the documentation or the forum on how to do this. Does anyone have hints?

Thanks, Richard

1 Like

Service Workflows are not related to Keyboard Maestro. To add shortcuts (key triggers) go to System Preferences > Keyboard > Shortcuts:

1 Like

This is awesome! I had no idea this was available. This is so cool! Thanks!

(Did I mention this is awesome?)

For anyone looking for this app, it's called "A Better Finder Rename" and can be found at http://www.publicspace.net/ABetterFinderRename/. This is one of those application that I don't use a lot, but when I do, it's worth every penny I paid for it.

Highly, highly recommended.

2 Likes

An alternative —which I personally prefer— is Name Mangler.

1 Like

You actually can do this in KM also:

I have a palette I use with Finder, so this is my preferred method.

2 Likes

Before you start adding tons of shortcuts in that clumsy little window, have a look at this tool.

1 Like

Thanks so much guys. Looking forward to trying these. The services app looks awesome too.

For what ever reason the shortcut won’t work on my system when I do it straight from the keyboard system preferences. That was my first thing I tried a while ago.

@tom nothing left to do but smile smile smile.

I’m psyched bout this. Thank you @DanThomas

Good. Hand me my old guitar, pass the whiskey round :blush:

All too often, the shortcuts assigned in "Keyboard Shortcuts" panel don't work. I came up with this as a fix and it always works.

1 Like

Thanks for sharing. Your macro looks interesting.

Some questions:

  1. Do you actually use "APPLICATION" in the Menu Title, or is that just a placeholder?
  2. Where did you get the service "Create Formatted Link for Front Safari Document"?

True, sometimes a shortcut doesn’t work immediately after assigning it. However, in my experience it will work, either after quitting/reopening the application, or —at latest— after a restart or re-login. In fact, I don’t have a Service shortcut that doesn’t work.

It expands to the current application name. See this Wiki article.

1 Like

LOL. Hey @JMichaelTX - perhaps you should check the Wiki before you post questions, huh? g,d&r.

1 Like

#1 Yes I use “APPLICATION” in the menu title

#2 It is a simple Automator workflow that I made which runs an AppleScript. I just spent 20 minutes looking for from whom or where I got the AppleScript, but I didn’t find it. It might be from macautomation.com - Sal’s site.

The AppleScript:

on run {input, parameters}
  
  tell application "Safari"
    try
      if not (exists document 1) then error "No document is open."
      set theURL to URL of document 1
      try
        get theURL
      on error
        error "The front document has no URL."
      end try
      set thisTitle to name of document 1
      
      repeat
        if thisTitle is not "" then exit repeat
      end repeat
      
      -- encode every character to unicode: ᇗ
      repeat with i from 1 to the length of thisTitle
        set thisID to the id of (character i of thisTitle)
        if i is 1 then
          set theTitle to "&#" & thisID & ";"
        else
          set theTitle to theTitle & "&#" & thisID & ";"
        end if
      end repeat
      
      set startEcho to "echo "
      set echoDelimiter to "'"
      
      set html_1 to "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">
  <html>
  <head>
    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
    <meta http-equiv=\"Content-Style-Type\" content=\"text/css\">
    <title>"
      set html_2 to "</title>
    <meta name=\"Generator\" content=\"Cocoa HTML Writer\">
    <meta name=\"CocoaVersion\" content=\"1038.11\">
      <style type=\"text/css\">
        p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
      </style>
    </head>
  <body>
  <p class=\"p1\"><a href=\""
      set html_3 to "\">"
      set html_4 to "</a></p>
  </body>
  </html>"
      
      set echoCommand to startEcho & echoDelimiter & html_1 & theTitle & html_2 & theURL & html_3 & theTitle & html_4 & echoDelimiter
      set textutilCommand to " | textutil -convert rtf -inputencoding UTF-8 -format html -stdin -stdout"
      set pbcopyCommand to " | pbcopy -Prefer rtf"
      
      set entireCommand to echoCommand & textutilCommand & pbcopyCommand
      
      do shell script entireCommand
      tell application "System Events" to keystroke "v" using {command down}
      set the target_file to the quoted form of the POSIX path of (((path to "ssnd") as string) & "Pop.aiff")
      do shell script "afplay " & target_file
      
    on error error_message
      activate
      display alert "Error Running Service" message error_message
    end try
  end tell
  
  return input
end run

2 Likes

I would, except I'm too busy debugging macros and scripts by the infamous Macro Master Dan. LOL

Besides, I think I probably just asked a question that many future readers would ask.

1 Like

@plutonite, thanks for sharing the answers to my questions.

The APPLICATION special case was added to the Select Menu Action more or less specifically so you could access the Services menu. It has other purposes, but that is the most obvious one.

1 Like