nikivi Posted December 17, 2017 Share Posted December 17, 2017 I have this code I very often use that @GuiB kindly shared once: # Alfred action function (pop the alfred action window) aw() { if [ $# -eq 0 ]; then # If no arguments, pop Alfred Action Window in the working directory osascript -e "tell application \"Alfred 3\" to action \"$(pwd)\"" else args="" argsAreAllPaths=true for arg in "$@" ; do filePath=$(realpath -s "$arg") if [[ -d $filePath ]] || [[ -f $filePath ]]; then # if the arg is a file of folder, append the path to the args string to build a list for the osascript command args+="\"$filePath\"," else argsAreAllPaths=false # if one argument is not a folder or file path, then pop Alfred with the standard search and try to access Alfred Action Window. This also makes it clear there's a problem with one of the passed paths break fi done if [ "$argsAreAllPaths" = true ] ; then # If all arguments are files or directories, open Alfred Action Window with the list args=${args%?} # remove the trailing comma osascript -e "tell application \"Alfred 3\" to action { $args }" else # If not all arguments are files or directories, search as is and try to access the Alfred Action Window. The Action Window should pop if it's possible, or the standard Alfred Search would be shown (ex: alfa activity monitor -> Would open the file action window of the Activity Monitor) actionKey="keystroke (ASCII character 29)" # (meaning: right arrow) Put your prefered action key (Alfred -> File Search -> Actions -> Show Actions) as applescript command for keystroke or key code (ex: "key code 98") delayBetweenEvents=0.1 # Play with the number if the action doesn't work correctly osascript -e "tell application \"Alfred 3\" to search \"$*\"" -e "delay $delayBetweenEvents" -e "tell application \"System Events\" to $actionKey" fi fi } This will activate a file action search on a passed in directory or file. I want to make it so that it would instantly open "Move to..." file action. Is it possible? I can think of a way to activate aw() and then simulate 'move' keystrokes and pressing enter but perhaps there is a better way than this. Link to comment
GuiB Posted December 17, 2017 Share Posted December 17, 2017 @nikivi, it's great seeing you're still using my code As for accessing the "Move to..." directly, I don't see another way at the moment, but using simulated keystrokes... @Andrew, maybe it would be great to make native Alfred's File Actions items accessible using External Triggers ? So that we could do something in the like: tell application "Alfred 3" to run trigger "Move to..." in workflow "Alfred's File Actions" with argument "/path/to/file". This way we could directly access those actions from anywhere. I think this could be great also from a Workflow point of view, so we don't recreate actions that are built-in like "Delete", "Copy To...", "Get Info", "Open With...", "Email To...", ... To get back to your question @nikivi, what I think I would do at the moment is something like: aw "/path/to/your/file" && osascript -e "delay 0.1" -e "tell application \"System Events\" to keystroke \"Move to...\" & return" I'll let you know if I find another idea! 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