1. Choose Apple menu > System Preferences and click Accounts.
2. Click Login Items and then click Add (+).
3. Select an application or document and click Add.
4. Drag items in the list to change the order in which they open.
5. Click the Hide checkbox next to an application if you don't want a window for the application to open.
Make sure the "Hide" box is checked for the apps in your "Login Items" list... that should do it.
tell application "Finder"
launch application "Mail"
end tell
delay 1
tell application "Mail"
close window 1
end tell
tell application "Finder" to launch application "Mail"
tell application "System Events"
set ProceedOK to false
repeat while ProceedOK is false
set ProceedOK to (name of processes) contains "Mail"
delay 1
end repeat
end tell
tell application "Mail" to close window 1
So there's a problem (of course) with my previous suggestion: What if the application takes longer than a second or so to open? So here's an updated version of the script which waits until the applications is in fact running:
Code:tell application "Finder" to launch application "Mail" tell application "System Events" set ProceedOK to false repeat while ProceedOK is false set ProceedOK to (name of processes) contains "Mail" delay 1 end repeat end tell tell application "Mail" to close window 1
Yes, this is nothing more than a work-around for Mail. If you want to specifically Hide the app (so that you can select "Show" from the Dock pop-up menu for example) instead of closing the window you could change the last line of the script to something like:Does that not cause the window to be closed, rather than simply hiding it? What is desired is for apps told to start at login to start in the state with their windows hidden rather than visible. Most apps will do this, but Mail seems to ignore the request.
tell application "System Events" to set visible of process "Mail" to false