Jump to content

Custom 'Open with...' file action

Recommended Posts

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?



Link to comment

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 by deanishe
Link to comment

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

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