Keven Posted August 1, 2016 Share Posted August 1, 2016 I'm trying to combine this to my Quit All workflow (but tested it alone), since Finder windows stay open. I've been searching and trying things out for the past hour. I found this thread, but no matter what I do, it doesn't work. Is there a way to make it work? Or is there a working Applescript that can activate Finder and then do Option+Cmd+W? Doesn't work: tell application "Finder" to activate tell application "System Events" keystroke "w" using {command down, option down} end tell Regards. Link to comment
juliosecco Posted August 1, 2016 Share Posted August 1, 2016 (edited) did you try: tell application "Finder" to close every window ? Edited August 1, 2016 by juliosecco Link to comment
Keven Posted August 1, 2016 Author Share Posted August 1, 2016 did you try: tell application "Finder" to close every window ? Tried your line of kind with every combination (alone, with mine, with end tell), but it doesn't work. Link to comment
Keven Posted August 1, 2016 Author Share Posted August 1, 2016 I tried my code in my first post (copied below) in the Apple Script Editor. It works 100%. If I try it in Alfred, it doesn't work for some reason. Anyone know why? It's a basic hotkey to a NSAppleScript. A normal script does the same thing. tell application "Finder" to activate tell application "System Events" keystroke "w" using {command down, option down} end tell Link to comment
Keven Posted August 1, 2016 Author Share Posted August 1, 2016 Well, the above code works. It's just that adding it to an AppleScript in Alfred doesn't work for some reason. To make it work, I created a script with Script Editor, saved it, and then did an open file action in Alfred. Link to comment
juliosecco Posted August 1, 2016 Share Posted August 1, 2016 (edited) Tried your line of kind with every combination (alone, with mine, with end tell), but it doesn't work. that's very strange if I setup a workflow with a 'keyword' launcher, that calls a 'Run script' of type osascript(AS), and I put on it: on run argv tell application "Finder" to close every window end run it works just fine and all the finder windows are closed. did you try to check on the debugger? Edited August 1, 2016 by juliosecco Link to comment
Keven Posted August 1, 2016 Author Share Posted August 1, 2016 that's very strange if I setup a workflow with a 'keyword' launcher, that calls a 'Run script' of type osascript(AS), and I put on it: on run argv tell application "Finder" to close every window end run it works just fine and all the finder windows are closed. did you try to check on the debugger? Ah, it works. Sorry about that, I am having weird things with script running for some reason. Everything works fine in the Script Editor, but then it doesn't work, as a script file, a NASAppleScript or as a script. Link to comment
juliosecco Posted August 1, 2016 Share Posted August 1, 2016 well, OK if you are still curious, I could send you a workflow offlist, jest for a double check tell me Ciao, Giulio Link to comment
deanishe Posted August 1, 2016 Share Posted August 1, 2016 As a rule of thumb, don't use NSAppleScript without a good reason. Use a normal Run Script Action with Language = /usr/bin/osascript (AS) instead. The latter is run in the background like a normal script. NSAppleScript is run on Alfred's main thread, so it will block Alfred. Because you're calling from another application, rather than a GUI-less background command, it may also do weird things with focus etc. AppleScript is a weird beast, and some things fail utterly in a Run Script Action, but work in a Run NSAppleScript one. But try to get it to work as a Run Script Action with /usr/bin/osascript (AS) first. Link to comment
Keven Posted August 1, 2016 Author Share Posted August 1, 2016 well, OK if you are still curious, I could send you a workflow offlist, jest for a double check tell me Ciao, Giulio It's good. Thanks. Link to comment
Keven Posted August 1, 2016 Author Share Posted August 1, 2016 As a rule of thumb, don't use NSAppleScript without a good reason. Use a normal Run Script Action with Language = /usr/bin/osascript (AS) instead. The latter is run in the background like a normal script. NSAppleScript is run on Alfred's main thread, so it will block Alfred. Because you're calling from another application, rather than a GUI-less background command, it may also do weird things with focus etc. AppleScript is a weird beast, and some things fail utterly in a Run Script Action, but work in a Run NSAppleScript one. But try to get it to work as a Run Script Action with /usr/bin/osascript (AS) first. Cool. Thanks for the tip. 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