0

I have made a custom keyboard shortcut for Finder that runs a script that copies the full file path to the clipboard. The shortcut is Control + Alt + Command + C.

It has always worked, but today it suddenly stopped working. I tried sniffing for any program that activates when the shortcut is pressed using /usr/bin/sudo opensnoop in Terminal but to no success. I have not recently installed any new programs and I can't recall anything particular happening that could be the culprit.

How do I get my shortcut back?

My Automator workflow looks like this (the actions are in Swedish): enter image description here

  • 1
    a) Please upload the workflow for us to see; b) Does it work either with a different shortcut, and/or from within Automator ? c) Why don't you use the Finder built-in shortcut ++C, which does the same thing ? – CJK Jun 24 at 8:57
  • a) I took a screenshot of my workflow in Automator but I don't know how to upload it here. Could you please tell me? b) Yes, it works fine if I change the shortcut to e.g. Ctrl + Cmd + C, so something has hijacked or broken my previous shortcut :( c) Because it won't give me the "file:///" prefix; I want to be able to click on the link. – Solmyr87 Jun 24 at 10:19
  • You can edit your question and drag a screenshot into the editor. If you don’t have enough reputation for that, upload it to Dropbox and share the link. Better yet, upload the workflow itself. On the day it stopped working, what changes occurred to your system: apps installed, terminal commands run, preferences for any app changed, anything even small and unimportant? Edit your question to describe these if you can. – CJK Jun 24 at 21:45
1

This is an extended comment containing some suggestions of things to try and help you diagnose your problem, but I don't claim that any of these will definitely solve your issue:

Check defaults to look for clashing keyboard shortcuts

Your service runs with a different shortcut and inside Automator. So there is possibly a conflicting shortcut that has appeared and is blocking your original.

In Terminal (or other terminal emulator), you can retrieve all the active app-specific keyboard shortcuts:

defaults find NSUserKeyEquivalents

and your service workflow shortcuts:

defaults find NSServicesStatus 

The symbols used to represent modifier keys are:

  • @: command
  • $: shift
  • ~: alt/option
  • ^: ctrl

Thus, +++C is symbolised as @~^c (the c is lowercase).

You can do a general defaults search through all the preference files to look for that specific combination of characters:

defaults find '@~^c'

You can also search for matching preferences files:

grep -iE '@~\^c' ~/Library/Preferences/* /Library/Preferences/* 2>/dev/null

which, upon matching, will output something like:

Binary file /Users/CK/Library/Preferences/com.apple.ServicesMenu.Services.plist matches

and then you can target the specific domain to examine its defaults:

defaults read com.apple.ServicesMenu.Services

Third-party Application

There are third-party apps that allow you to see what keyboard shortcuts are being used by which applications on your system. The one I know of is KeyCue:

I'm not endorsing the product and have never used it myself, but I believe it would be very useful in finding out if there's interference from another application or from within Finder stopping you from using that shortcut combination.

It's a paid app (€19.99), but has a free evaluation period:

All our products are available for evaluation before purchase. As long as you do not have a license key, KeyCue operates in trial mode and occasionally displays a registration reminder instead of the shortcut table.


ADDENDUM : Your Workflow

Thanks for posting a screenshot of your workflow. There doesn't appear to be anything obstructive about it that would obviously cause it to stop responding to a shortcut.

However, I'm going to take the opportunity to suggest some edits to it, as I can see what your AppleScript is doing, but it's not doing it in the most optimal way.

Here is your current workflow:

The OP's current workflow

It starts by taking the files/folders passed to the service/quick action and copying them to the clipboard. There's no need to and it only makes Automator do more work than it has to. Instead, you can delete that first action, and have the files/folders pass directly into the AppleScript, where they will be stored in the variable input.

The AppleScript itself makes use of application "BBEdit" unnecessarily, so I suggest removing that and I'll show you how to make the changes you need without calling out to it.

If I'm interpreting your goal correctly from what you said and from what I see in your workflow, you wish to select some files or folders, press your shortcut key combination, and have file URL references to those files/folders copied to the clipboard, e.g. file:///Users/CK/Desktop/somefile.txt.

Your method works ok in some situations, but will produce incorrect results in a few other situations:

  • Any file/folder with a space in its name will not return a correct and clickable file URL link. For example, the file with path /Users/CK/Shared Items/myfile.ext will be copied to the clipboard as file:///Users/CK/Shared Items/myfile.ext, which is an incorrectly encoded URL string, thus the hyperlink will appear like this: file:///Users/CK/SharedItems/myfile.ext. (Technically, other character entities need to be percent encoded to form a valid URL, but I think they're less important if you're just looking to use them locally in Finder.)

  • Your present method replaces occurrences of "/Volumes" and occurrences of "/Users" with "file:///Volumes" and "file:///Users", respectively. This will cause problems for any file path that might look something like this:

    /Users/CK/Backup/Preferences/Volumesettings/Volumes.dat
    

    There are three replacements waiting to happen there, which would yield:

    file:///Users/CK/Backup/Preferencesfile:///Volumesettingsfile:///Volumes.dat
    

Having cleaned up the script, and deleted the superfluous action, here is what I am suggesting would be a smarter way to implement your service/quick action:

Suggested edit to workflow

The AppleScript:

property text item delimiters : linefeed


on run {FSItems}
    local FSItems

    tell application "System Events" to repeat with FSItem in FSItems
        set FSItem's contents to the URL of FSItem
    end repeat

    set the clipboard to FSItems as text
end run

It utilises System Events (which is a faceless, background application that can perform efficient file system operations) to take each file/folder passed into the workflow and obtain an AppleScript property named URL, which conveniently holds the perfectly-formatted, validated file URL reference for a file. Once it has a list of file URLs, it combines them into a single piece of text—one file URL per line—and places that on the clipboard.

Thus, selecting the following files/folder in Finder (if you imagine I selected three files and a folder, then pressed the hotkey to trigger the service):

/Users/CK/Desktop/NSImage.png
/Users/CK/Desktop/GIF Images
/Volumes/Lepton 1.5.2-alpha-2
/Users/CK/Desktop/mandelbrot.js

would yield the following clipboard contents (this is a live test):

file:///Users/CK/Desktop/NSImage.png
file:///Users/CK/Desktop/GIF%20Images/
file:///Volumes/Lepton%201.5.2-alpha-2/
file:///Users/CK/Desktop/mandelbrot.js

  • Thanks a lot for a very thorough answer! I have tried all the Terminal commands you suggested to no avail, I'm gonna try the program next. Also, I managed to edit my question with a screenshot of the workflow. – Solmyr87 Jun 25 at 5:30
  • @Solmyr87 I just added an addendum that I hope you find helpful. – CJK Jun 25 at 7:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .