Monday, March 18, 2019

#1 2018-12-25 11:06:02 pm

Umberto
Member
Registered: 2018-12-25
Posts: 1

Hide Mail at startup

I have a very narrow issue to do with Mail.
I am running Mojave on a 2017 27inch iMac.
My preferred setting for Mail is to have it open at login and remain hidden.  That function in Preferences/Accounts/login items/hide checkbox ticked, does not work so the Mail launches and the main page is displayed.
I have removed Mail as a login item.
Instead I have created applications from Script Editor scripts and included one of them as a login item.
All of them have failed except 2.  They are al variants of this:
tell application "Mail" to [run/launch/activate]
tell application "System Events"
    set visible of process "Mail" to false
end tell
The run version fails after a few restarts.
The others cause Mail to flash open before hiding.
I am currently using this login application, but expect it to fail.
tell application "System Events"
    set visible of process "Mail" to false
tell application "Mail" to run
end tell
Any suggestions?  Perhaps you or Apple has identified and fixed the bug?


Filed under: Hide Mail

Offline

 

#2 2019-01-01 04:44:09 am

Joy
Member
From:: South Tirol
Registered: 2008-07-04
Posts: 603
Website

Re: Hide Mail at startup

Hi Umberto
And welcome on Macscripter!
Don't use "Activate" if you want Mail to run in background. Activate fires mail up tongue

Stick with this code:

Applescript:

tell app "Mail" to run

Or:

Applescript:

tell app "Mail" to launch

Pay attention, some events need a timeout :

Applescript:

delay 0.5 #half second

Therefore:

Applescript:

tell app "Mail" to run
delay 0.5 #half second
tell application "System Events"
set visible of process "Mail" to false
end tell

Usually hiding applications isn't smooth but I can be wrong as my system runs am older Osx. Try.
Remember to format your text by using the formatting button "Applescript" . As that helps us to read your question

Felice anno nuovo  2019

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)