Jump to content

How to automatically pass the output file of a workflow back into Alfred?


Recommended Posts

Posted

I'm trying to replicate some functionality where I can trigger a screen capture using Alfred and then have the resulting file get piped back into Alfred as the selected result so that I can further operate on it e.g. email, rename, share, etc..

 

Desired flow:

  1. Open Alfred and trigger screen capture tool
  2. Take Screenshot
  3. Re-open Alfred with the screenshot file already selected

 

I've tried a number of different screen capture workflows (Screencapture, Various Screenshots, etc..) but haven't come across any that can do this.

 

Tony

Posted
1 hour ago, Alfred0 said:

have the resulting file get piped back into Alfred as the selected result so that I can further operate on it e.g. email, rename, share, etc..

 

Use Alfred’s browse AppleScript command (tell application id "com.runningwithcrayons.Alfred" to browse "/path/to/your/file") to select a file in Alfred, or the action command to go straight to File Actions.

Posted

Awesome, thx @deanishe!!

 

Now I just need to figure out how/if it's possible to add this AppleScript after this bash script is run?

 

I'm using the "alfred-various-screenshots" workflow, and I've created an issue in this repo as well, but any pointers/tips would be appreciated for this workflow or any other screenshot workflow to be honest 😁

 

DefaultLocalScreenshotFolder="${DefaultLocalScreenshotFolder:-$HOME/Desktop}"

# Expand ~, since it not works in Alfred
#
DefaultLocalScreenshotFolder=`echo "$DefaultLocalScreenshotFolder" | perl -pne 's/^~/$ENV{HOME}/'`

readonly filename=`date '+screenshot_%Y-%m-%d_%H-%M-%S.png'`
readonly filenamepath="$DefaultLocalScreenshotFolder/$filename"

if [ {query} = "area" ]; then
    screencapture -is "$filenamepath" >/dev/null 1>&2
elif [ {query} = "window" ]; then
    screencapture -iW "$filenamepath" >/dev/null 1>&2
else
    screencapture -S "$filenamepath" >/dev/null 1>&2
fi

if [ $? -eq 0 ]; then
    echo "OK"
fi

 

Posted (edited)

Add this before echo "OK":

 

osascript -e "tell application id \"com.runningwithcrayons.Alfred\" to action \"$filenamepath\""

 

Edited by deanishe
Posted (edited)

Hi @deanishe, follow-up question to your post above... is it possible to define and trigger a specific action using the osascript above e.g. automatically invoke the "Rename" action for the passed in file?

Edited by Alfred0
Posted
2 hours ago, Alfred0 said:

automatically invoke the "Rename" action for the passed in file?

 

The Alfred Rename action? Not in a reliable way, no. All you can do is simulate typing “rename” and then ↩ into Alfred after calling the action command.

 

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...