sirdavidoff Posted October 13, 2017 Share Posted October 13, 2017 I'd like to make my own version of the 'Open with...' file action (that opens the last-modified file in a directory with an application of the user's choice). The built-in 'Open with...' file action has a second screen where you choose the application that you want to use. How can I use such functionality in my own workflow? Thanks! Link to comment
deanishe Posted October 13, 2017 Share Posted October 13, 2017 52 minutes ago, sirdavidoff said: How can I use such functionality in my own workflow? Which functionality? Do you want to pass your own file to Alfred’s application list or do you want to show you own list when someone actions a File Action? Link to comment
sirdavidoff Posted October 16, 2017 Author Share Posted October 16, 2017 Thanks for your reply, deanishe. I would be happy to use Alfred's application list and just pass a file to it. Link to comment
deanishe Posted October 16, 2017 Share Posted October 16, 2017 (edited) Pass the path to Alfred's action command via AppleScript, e.g.: tell application "Alfred 3" to action "~/Downloads" That's the closest you can get to calling Open With… directly. After that, you need to start simulating keystrokes, which may or may not work: tell application "Alfred 3" to action "~/Downloads" delay 0.2 -- Give Alfred time to react tell application "System Events" keystroke "Open W" delay 0.2 key code 36 -- Enter end tell Edited October 16, 2017 by deanishe Link to comment
sirdavidoff Posted October 16, 2017 Author Share Posted October 16, 2017 Thanks, deanishe. Is there any way to get this to work in Alfred 2? Link to comment
deanishe Posted October 16, 2017 Share Posted October 16, 2017 Yeah, probably. Alfred 2 only supports the search command (tell application "Alfred 2" to search "~/Downloads"), which will browse the path in Alfred instead of opening the File Actions. As a result, you'll also have to simulate the keypress for your Actions key. If you're using → (right arrow), add key code 124 before the other simulated keypresses. 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