eusi Posted May 22, 2016 Share Posted May 22, 2016 (edited) Hey, first of all: what I want to do, is to call a ScriptFilter via another. Lets say we do "workflow soccerclubs" that gives us a list of soccer clubs. After we clicked on one of em, Alfred updates to e.g. "workflow soccerclub Real Madrid", which lists every player of the team. Currently I do this via a "Run NSApple Script": on alfred_script(q) tell application "Alfred 2" to search "workflow soccerclub " & q end alfred_script Now, when Alfred 3 is released, this doesn't work for everyone. My first solution is a workaround, that checks every time, if Alfred 3 is installed, then use Alfred 3, otherwise use Alfred 2. To use such call everytime, is a bad approach. What I need is something like this_alfred in AppleScript or another possibility to call a ScriptFilter via another ScriptFilter (compatible in Alfred 2 + 3) Best regards, eusi Edited May 22, 2016 by eusi Link to comment
deanishe Posted May 24, 2016 Share Posted May 24, 2016 Fundamentally, this is very tricky to do with AppleScript. At least as far as I can tell. And it's even more difficult from within Run NSAppleScript. AppleScript has a really weird execution model. You can't get an application object based on a name in a variable, and you can't even mention an application that isn't installed, or a box will pop up asking the user to location the application, which is a huge issue in this particular case. As a result, to keep using AppleScript, you're probably going to need to have separate scripts for Alfred 2 and Alfred 3. You should really switch to JavaScript. Swap out your Run NSAppleScript Action for a normal Run Script action with "Language = /usr/bin/osascript (JS) with input as argv" and try this: ObjC.import('stdlib'); function run(argv) { // Get major version number var v = $.getenv('alfred_version').split('.')[0]; Application('Alfred ' + v).search('workflow soccerclub ' + argv[0]); } Link to comment
eusi Posted October 4, 2016 Author Share Posted October 4, 2016 Oh, I missed thing here... Well better late than never ;-) I works well, thank you very much! Link to comment
deanishe Posted October 4, 2016 Share Posted October 4, 2016 I think someone smarter than me figured out how to do it with AppleScript. I can't remember exactly, but it involves asking System Events if there's a program named "Alfred X" running Link to comment
eusi Posted October 4, 2016 Author Share Posted October 4, 2016 (edited) Doesn't matter. I just needed a way to get rid of "Alfred 2" in tell application "Alfred 2" to search "workflow soccerclub " & q AppleScript wasn't required. Another script also fine. It was a simple issue: If a user uses Alfred 3, he cannot use the workflow, because of this line. In far future, there could be a Alfred 2- 3- and 4-user that is using the workflow. It would be crazy if everyone needs to modify this line to make the workflow work ;-) So thanks again for fixing *beer ahoy* Edited October 4, 2016 by eusi deanishe 1 Link to comment
deanishe Posted October 4, 2016 Share Posted October 4, 2016 1 hour ago, eusi said: In far future, there could be a Alfred 2- 3- and 4-user that is using the workflow Heh, you're right. I'd forgotten what my solution was, and it is nicely forward compatible. (FWIW, I think Andrew is looking into just using "Alfred" as the app name in AppleScript.) 1 hour ago, eusi said: *beer ahoy* I started hours ago… 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