Jump to content

Pass clipboard to keyboard maestro

Recommended Posts

Does anyone know how would I go about passing the contents of the clipboard created in an Alfred workflow to another app, such as Keyboard Maestro? The last step of my Alfred workflow calls my Keyboard Maestro macro (via AppleScript), but nothing happens. I'm either not passing the clipboard correctly, or I'm not calling Keyboard Maestro correctly. (Basically, what I'm trying to do is search for a contact via Alfred, and then pass the email address of the contact over to a Keyboard Maestro workflow to apply some regex to it to convert it to a URL, which is then opened).


I've uploaded a screenshot of my workflow, along with the details of the 2nd and 4th steps. (Please ignore the Placeholder title, subtext, etc - I pilfered that from another workflow and haven't changed it yet). I admittedly am a complete novice when it comes to Alfred workflows, so my work is probably painfully bad.

Screen Shot 2017-07-17 at 1.59.48 PM.png

Screen Shot 2017-07-17 at 1.59.56 PM.png

Screen Shot 2017-07-17 at 2.00.12 PM.png

Edited by Cyberskier
Link to comment

Hello and welcome, @Cyberskier,


You should post your Workflow, as we can’t properly help you without access to it.

Debugging can already be hard with access to the code, and you’re asking us to guess yours from a description and screenshots. There are multiple places where you code or Workflow setup may be going wrong. Without looking at it we’re shooting in the dark, which is a waste of time for everyone involved (including you).

Read the Reporting Problems with Workflows topic, as it gives a nice overview on how to build an effective report.


In this case, there seem to be multiple problems. One is that you’re not actually taking advantage of any argument passed to the Run Script. You’re not referencing {query} or ${1} so Alfred can’t guess where you’d want to use the passed argument, if at all. But Copy to Clipboard isn’t supposed to output anything to another node, even, so that wouldn’t work either way. Assuming you really want the text in your clipboard, make the Script Filter connect to both Copy to Clipboard and Run Script; don’t chain them.

But as stated, without access to the Workflow there’s no way to verify that’s the actual problem.

Link to comment

Your workflow works, more or less.


The main issue is that your Run Script has Language set to /bin/bash but you have AppleScript in it. Change Language to /usr/bin/osascript (AS)


There's probably also a second issue, however. My MailTo workflow that you've based this on doesn't output a list of email addresses, it outputs a command.


That is to say, if you choose two recipients, e.g. bob@aol.com and dave@hotmail.com, the output won't be bob@aol.com, dave@hotmail.com, but rather compose 'bob@aol.com, dave@hotmail.com'.


You will probably also need to change line 241 of mailto.py to alter the output.


I imagine you'll want it to say arg=recipients,

Link to comment

Thanks deanishe and everyone else for your help with this, and especially to deanishe for the mailto Workflow that is at its heart. I have it working now (Aflred and Keyboard Maestro links at the end of this post). I did change line 241 of mailto.py, per your suggestion, but it was still passing "compose" to the clipboard. That turned out not to be a problem, as the regex in my Keyboard Maestro macro still found only the numeric digits (as an aside, I imagine I could probably do this whole thing in Alfred, but I had the regex working in Keyboard Maestro and had no idea how to do that in Alfred). To answer one of the questions, above, I did want to pass the text to the clipboard, as my Keyboard Maestro macro acts on the text on the system clipboard. So I needed to find a way to get the text to the clipboard, and run my KM macro.


Anyway, thanks again for the help. The links are below. They won't be directly relevant to anyone who doesn't use my firm's case management system, but maybe they'll be indirectly helpful to others.


Alfred workflow: http://d.pr/f/PgRbBv

Keyboard Maestro macro: http://d.pr/f/a5k3K0

Link to comment

Dude, pictures are no help (particularly when they say the exact same thing as your post). I refer you again to the "reporting problems" thread both Vítor and I linked to.


Post the log file. (Enter workflow:openlog as your query to see it.)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...