Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

rdijkgraaf

macrumors newbie
Original poster
Jan 29, 2016
27
4
Netherlands
I have Automator automatically open certain applications at a certain time in the evening. The next morning the windows are open. I would like to avoid having to close them by hand with cmd-w, I want Automator to do that for me automatically after opening the apps. Automator can open Apple Script, but what do I enter next?
 

bogdanw

macrumors 603
Mar 10, 2009
5,715
2,749
I’m not sure I understand, you want to open apps without visible windows?
Depending on the apps, you can use open -j
Example in AppleScript:
AppleScript:
do shell script "open -j /System/Applications/Calculator.app"

Related threads and apps
“I wrote an AppleScript that Quits all running apps at once!” https://forums.macrumors.com/thread...-that-quits-all-running-apps-at-once.2379603/
“Quit app by pressing the red dot?” https://forums.macrumors.com/threads/quit-app-by-pressing-the-red-dot.2395078/
Quick Action to Quit All Applications https://forums.macrumors.com/threads/how-to-close-apps-in-mission-control.2371321/post-31754914
Swift Quit "Close Mac Applications Automatically When Their Windows Close" https://swiftquit.com/
RedQuits "All programs now quit and close all open windows if you click the red button." http://www.carsten-mielke.com/redquits.html
 

rdijkgraaf

macrumors newbie
Original poster
Jan 29, 2016
27
4
Netherlands
I’m not sure I understand, you want to open apps without visible windows?
Depending on the apps, you can use open -j
Example in AppleScript:
AppleScript:
do shell script "open -j /System/Applications/Calculator.app"

Related threads and apps
“I wrote an AppleScript that Quits all running apps at once!” https://forums.macrumors.com/thread...-that-quits-all-running-apps-at-once.2379603/
“Quit app by pressing the red dot?” https://forums.macrumors.com/threads/quit-app-by-pressing-the-red-dot.2395078/
Quick Action to Quit All Applications https://forums.macrumors.com/threads/how-to-close-apps-in-mission-control.2371321/post-31754914
Swift Quit "Close Mac Applications Automatically When Their Windows Close" https://swiftquit.com/
RedQuits "All programs now quit and close all open windows if you click the red button." http://www.carsten-mielke.com/redquits.html
 
Last edited:

rdijkgraaf

macrumors newbie
Original poster
Jan 29, 2016
27
4
Netherlands
I tried to use your script with and without the '.app' but I get an error message. Apperently I am doing something wrong ... See attachments.
Automator.jpg
Error message.jpg
 

bogdanw

macrumors 603
Mar 10, 2009
5,715
2,749
Why use “Get Specified Finder Items”?
Simply “Run AppleScript”:
AppleScript:
do shell script "open -j /Applications/Indigo\\ 2023.1.app"
 

MacCheetah3

macrumors 68020
Nov 14, 2003
2,121
1,094
Central MN
It’s not simply closing windows, but you can quit applications, selective or all, using Automator or Shortcuts. Some quick example screenshots:


Automator_Quit-Apps.png Shortcuts_Quit-Apps.png
 

rdijkgraaf

macrumors newbie
Original poster
Jan 29, 2016
27
4
Netherlands
Thanks again, your suggestion to open app via automator and 'run script' works simpler than my previous system. But the – minor but a bit annoying – problem still remains: I have to close the window manually every day.
 

bogdanw

macrumors 603
Mar 10, 2009
5,715
2,749
Not all apps respect open -j, you could try to close the window with AppleScript
AppleScript:
tell application "Indigo 2023.1"
    activate
    close window 1
end tell
 

rdijkgraaf

macrumors newbie
Original poster
Jan 29, 2016
27
4
Netherlands
Thanks again. I would understand it if you have more important stuff to do, then just don't answer.

It should be simple I think, but I keep getting error messages. The app opens, but there's a problem with closing the window.
Screenshot 2024-01-24 at 22.04.09.jpg
Screenshot 2024-01-24 at 22.03.12.jpg
 

bogdanw

macrumors 603
Mar 10, 2009
5,715
2,749
If do shell script "open -j /Applications/Indigo\\ 2023.1.app" doesn’t open the app without any windows, don’t use it.

Try in ScriptEditor just

AppleScript:
tell application "Indigo 2023.1"
activate
close window 1
end tell

to see if it closes the window of the app.

If it doesn’t work, there could be other ways to close the window
MacScripter - Close the window https://www.macscripter.net/t/close-the-window/74468
Script for closing an application's window https://discussions.apple.com/thread/252048971
 

rdijkgraaf

macrumors newbie
Original poster
Jan 29, 2016
27
4
Netherlands
If do shell script "open -j /Applications/Indigo\\ 2023.1.app" doesn’t open the app without any windows, don’t use it.

Try in ScriptEditor just

AppleScript:
tell application "Indigo 2023.1"
activate
close window 1
end tell

to see if it closes the window of the app.

If it doesn’t work, there could be other ways to close the window
MacScripter - Close the window https://www.macscripter.net/t/close-the-window/74468
Script for closing an application's window https://discussions.apple.com/thread/252048971
Dear Bogdanw, thanks for all your supportfor this noob! Ultimately it is working properly, see the image.
(Indigo underwent an update, so 2023.2 instead of 2023.1).
Screenshot 2024-01-29 at 18.48.41.jpg
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.