sudopeople Posted February 3, 2014 Share Posted February 3, 2014 (edited) I'd like to type a keyword and have a different Alfred keyword get executed. You can think of this as an alias or a shortcut. A practical example is with Victor Quinn's Volume Adjust workflow: I type "vol mute" dozens of times per day. I'd rather type "mute" into Alfred. I've been unable to find anything that accomplishes this literally or even really in practice. One of the stickies here talks about doing 'tell application "Alfred 2" to search "keyword args"' but that just presents an Alfred window and requires an enter press...or a keypress event to be fired which is A hard to get working correctly and B a horrible kludge. For now I've added the mute keyword and altered the AppleScript to mute the volume when there's no argument...but that means I can't set up another "alias" like "half" for "vol 50" (since Alfred doesn't pass the keyword to scripts). Obviously I could copy/paste the entire workflow (or AppleScript) for each "alias" but as a programmer I'm morally against that kind of thing. Any other ideas? Edited February 3, 2014 by sudopeople Link to comment
Vero Posted February 3, 2014 Share Posted February 3, 2014 I'd like to type a keyword and have a different Alfred keyword get executed. You can think of this as an alias or a shortcut. A practical example is with Victor Quinn's Volume Adjust workflow: I type "vol mute" dozens of times per day. I'd rather type "mute" into Alfred. Create a new workflow and have a look at the objects in the + in the top right. You can connect a keyword to an iTunes action to do exactly what you want (if I've understood you correctly) All I've done here is pick a keyword object (with no argument) and set the keyword as "up" and "down". I then connected each one with its respective action from the + button in the top right (Actions > iTunes Command and then select from the dropdown menu) Let me know if you'd like me to share the workflow above, but it'll only take a few seconds to create your own and you can set your own keywords as you go. Link to comment
Tyler Eich Posted February 3, 2014 Share Posted February 3, 2014 Vero's suggestion is the most elegant if you want to control iTunes. If you want to control the system volume, try my fork of @victorquinn's workflow. It uses a 'mute' keyword connected to the relevant code in the original AppleScript. I don't know of any general purpose way to do this. Each workflow is different, and there are several ways to process arguments. Link to comment
sudopeople Posted February 3, 2014 Author Share Posted February 3, 2014 (edited) Yeah, both are great ways for this specific example. I've got a few others I've had in mind and have been too lazy to implement Still holding out for a Keyword to execute keywords! Edited February 3, 2014 by sudopeople Link to comment
vitor Posted February 3, 2014 Share Posted February 3, 2014 There’s no option in Alfred to perform that action (you should add it as a feature suggestion). However, there is a way to accomplish what you want. It’s a hack, and it’s definitely not pretty, but it works. Expanding on the idea of telling Alfred to search for something, what you can do is tell application "Alfred 2" to search "vol mute" tell application "System Events" to key code 36 That will call Alfred’s window with your desired query, and the system will then take care of pressing ↩, which will effectively run the command. You’ll see Alfred’s window flash for a split second, and it is prone to possible undesired consequences (let’s say a dialog box pops in front, in that exact fraction of time — ↩ will not discriminate what app is in front), but it should work for the most part. Tyler Eich 1 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