pbb Posted August 3, 2022 Share Posted August 3, 2022 (edited) I have been trying to make a workflow, and in one step it needs to close all windows. Currently, I have tried the following applescript: on alfred_script(q) tell application "Finder" set visible of every process to false end tell end alfred_script and also on alfred_script(q) tell application "Finder" set visible of every process to false if q contains "all" then tell application "Finder" close every window end tell end if end tell end alfred_script which are all found online. I don't know applescript particularly well, and both of them seem fine. But there's one trick thing keeps happening: sometimes some windows will not be hidden. And using a simple ShortCut seems to fix this issue: But I would like to avoid this since it hurts the distributivity. The complete workflow can be found here (with old script currently) if this helps debugging. Demo: this is with workflow: and the launch apps list only contains VSCode, so basically some apps like Telegram is not hidden. I'm open to any solutions which can close windows more stably. And I know two scripts I have tried are all using Finder's hide other functionality, which make finder shows up. If it's possible I would like to make Finer be hidden as well. Edit: To be clear, I know there exists apps like bunch: But what I'm trying to do is to just hide those apps, not completely quit them, since I have huge amount of pdf files in Preview and also default apps. So to quit and reopen them will be a waste of time. Edited August 3, 2022 by pbb Link to comment
andy4222 Posted August 3, 2022 Share Posted August 3, 2022 (edited) It's not clear if you want to quit all apps or hide them? If you want to hide them, here is a script that hides all apps. on alfred_script(q) tell application "Finder" to activate tell application "System Events" to keystroke "h" using {command down, option down} tell application "Finder" to activate tell application "System Events" to keystroke "m" using {command down, option down} end alfred_script If you want to quit them, Automation Tasks (❤️), the Alfred 5 comes with this out of the box 😁. See screenshot and this Edited August 3, 2022 by andy4222 Link to comment
pbb Posted August 3, 2022 Author Share Posted August 3, 2022 1 hour ago, andy4222 said: It's not clear if you want to quit all apps or hide them? If you want to hide them, here is a script that hides all apps. on alfred_script(q) tell application "Finder" to activate tell application "System Events" to keystroke "h" using {command down, option down} tell application "Finder" to activate tell application "System Events" to keystroke "m" using {command down, option down} end alfred_script I want to hide them. I think the first two lines in the alfred script box works well, but the last two lines make me quite nervous... So basically macOS treat Finder completely differently even for its hiding mechanism? Link to comment
andy4222 Posted August 3, 2022 Share Posted August 3, 2022 (edited) Why do those 2 script lines make you nervous ? I mean you could read the Apple docs if you want to deep dive, but it pretty much is self descriptive. To my knowledge, macOS default's to Finder app is everything is minimized. If you hide everything manually, you'd see that Finder becomes the active app (doesn't necessarily mean it is the front most app) Edited August 3, 2022 by andy4222 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