Alfred0 Posted September 25, 2020 Posted September 25, 2020 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: Open Alfred and trigger screen capture tool Take Screenshot 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
deanishe Posted September 25, 2020 Posted September 25, 2020 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.
Alfred0 Posted September 25, 2020 Author Posted September 25, 2020 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
deanishe Posted September 26, 2020 Posted September 26, 2020 (edited) Add this before echo "OK": osascript -e "tell application id \"com.runningwithcrayons.Alfred\" to action \"$filenamepath\"" Edited September 26, 2020 by deanishe
Alfred0 Posted September 26, 2020 Author Posted September 26, 2020 Works perfectly!! Tku @deanishe 🙌🙌🙌
Alfred0 Posted September 29, 2020 Author Posted September 29, 2020 (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 September 29, 2020 by Alfred0
deanishe Posted September 29, 2020 Posted September 29, 2020 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.
Alfred0 Posted September 29, 2020 Author Posted September 29, 2020 Ok, thx! I hacked together something similar which isn’t pretty but it works 😄
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