Cyberskier Posted July 17, 2017 Share Posted July 17, 2017 (edited) 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. Edited July 17, 2017 by Cyberskier Link to comment
deanishe Posted July 17, 2017 Share Posted July 17, 2017 As it says in the stickied thread on getting help with errors, share your broken workflow, not just pictures of it. We can't tell what's wrong just from a picture or two. Link to comment
vitor Posted July 17, 2017 Share Posted July 17, 2017 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
Cyberskier Posted July 17, 2017 Author Share Posted July 17, 2017 Thank you both for the reply. I'll digest the info, but in the meantime I've uploaded my very broken workflow here: http://d.pr/f/kgwY9u Thank you. Link to comment
deanishe Posted July 17, 2017 Share Posted July 17, 2017 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, Cyberskier 1 Link to comment
Cyberskier Posted July 17, 2017 Author Share Posted July 17, 2017 Thank you. That makes sense, as it is in the final step that things grind to a halt. Stupid question, but where can I find mailto.py? Link to comment
vitor Posted July 17, 2017 Share Posted July 17, 2017 52 minutes ago, Cyberskier said: where can I find mailto.py? Right click the Workflow in the sidebar in Alfred Preferences and pick Open in Finder. Cyberskier 1 Link to comment
Cyberskier Posted July 18, 2017 Author Share Posted July 18, 2017 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
deanishe Posted July 18, 2017 Share Posted July 18, 2017 Oops. You'd also need to change line 271. Link to comment
Cyberskier Posted July 18, 2017 Author Share Posted July 18, 2017 Thanks. So now I'm getting "App cache not yet initialized" when I type my trigger key (see attached). I've waited several minutes and rebooted, and the message persists. Link to comment
deanishe Posted July 18, 2017 Share Posted July 18, 2017 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
Cyberskier Posted July 18, 2017 Author Share Posted July 18, 2017 Sorry about that. Log is below. I've deleted the lines containing my contacts' email addresses, and left two dummy lines in. Log: http://d.pr/f/p3Hdo8 And here is the debugger: http://d.pr/f/QqmByz Link to comment
deanishe Posted July 18, 2017 Share Posted July 18, 2017 Looks like the process is hanging. Open the workflow directory in Terminal (or iTerm) and run /usr/bin/python update_apps.py See what the app update script does. Link to comment
Cyberskier Posted July 18, 2017 Author Share Posted July 18, 2017 Thanks for sticking with me on this. I opened the workflow's directory in Terminal, ran the command, and I still have the issue. Text from Terminal: http://d.pr/f/By4Agy Log: http://d.pr/f/3dkdVD (picking up where last one left off) Debugging: http://d.pr/f/9GYr7O Link to comment
deanishe Posted July 18, 2017 Share Posted July 18, 2017 The script is working properly. Try resetting the workflow cache with the query "workflow:delcache" Cyberskier 1 Link to comment
deanishe Posted July 18, 2017 Share Posted July 18, 2017 In any case, you're not using the app cache in your workflow, so you can rip all that stuff out. Link to comment
Cyberskier Posted July 18, 2017 Author Share Posted July 18, 2017 How do I rip it out? I reset the cache, and the problem persists. You're definitely right that the script is fine, as I just tried the workflow on my iMac, and it works fine there. It's just my MacBook Pro that has the problem. Link to comment
Cyberskier Posted July 18, 2017 Author Share Posted July 18, 2017 So I just tried "workflow:reset" and now things seem to be working. Thanks for the help! Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now