Puoi accenderlo e spegnerlo manualmente nelle preferenze del sistema di notifiche.
Aggiornamentoaquestarisposta:
FunzionaabbastanzabenesulmioMac.Manonèlocalizzatoedèdavverounasceneggiaturavelocemessainsiemecomeprovadelconcetto..(questoèildisclaimer)
L'ideaèquelladiinserirequestoscriptnelmenuApplescriptedeseguirloquandosidesiderafarpassareillettoreiTunesdaPrincipaleaMiniPlayer.
Loscriptfaràloswitchperte,controllaqualefinestraèattivaepoiapriiprefsdisistemaprovaetrovalenotifichediiTunesepassaa"Nessuno" o "Banner" a seconda. Ho completamente ignorato gli "avvisi" in questo perché sono sicuro che la maggior parte delle persone non avrebbe selezionato quello!!
property delayTimeMax : 2
property windowTitle : ""
set windowTitle to ""
property delayCounter : 0
set delayCounter to 0
property theList : ""
tell application "System Events"
tell application "iTunes" to activate
delay 1
keystroke "m" using {command down, shift down} --//Toggle the itunes window
my windowTheTitle() --//-- try and get the window title
end tell
tell application "System Events"
if delayCounter > delayTimeMax then return --//-- too many trys, lets stop
set delayCounter to 0
my openSystemEvents() --//-- try and open the system prefs window
if delayCounter > delayTimeMax then return --//-- too many trys, lets stop
set delayCounter to 0
tell application process "System Preferences"
set this_item to ""
my findTable() --//-- try and find the app list in the system prefs window
if delayCounter > delayTimeMax then return --//-- too many trys, lets stop
set delayCounter to 0
set counter to 0 --// the counter will increment for each row that represents an app
--// find the correct one using it's static text which will be the app name
repeat with i from 1 to number of items in theList
set this_item to item i of theList
set counter to counter + 1
try
set theValue to value of static text of this_item
end try
if item 1 of theValue is equal to "iTunes" then
exit repeat --// found it exit repeat
end if
end repeat
select row counter of table 1 of scroll area 1 of window "Notifications" --// select the app in the table
set theRadiaGroup to radio group 1 of group 1 of window "Notifications" --// the Radio buttons for the Notification type
if windowTitle is "MiniPlayer" then
--// mini player is active
set theVal to value of radio button "None" of radio group 1 of group 1 of window "Notifications"
--// we do not want to click the button if it is already selected. Which may or may not deslect all of them. (poss bug)
if theVal is 0 then
--//select no alert
click radio button "None" of radio group 1 of group 1 of window "Notifications"
end if
else
--// MAIN window is active
set theVal to value of radio button "Banners" of radio group 1 of group 1 of window "Notifications"
if theVal is 0 then
--// we do not want to click the button if it is already selected. Which may or may not deslect all of them. (poss bug)
click radio button "Banners" of radio group 1 of group 1 of window "Notifications"
end if
end if
end tell
end tell
tell application "System Preferences" to quit
on windowTheTitle()
tell application "System Events"
try
tell application process "iTunes" to set windowTitle to get title of window 1 --//Get the window title : iTunes or MiniPlayer
on error
set delayCounter to delayCounter + 1
if delayCounter > delayTimeMax then return --//-- too many trys, lets stop
delay 1
my windowTheTitle()
end try
end tell
end windowTheTitle
on openSystemEvents()
tell application "System Events"
try
tell application "System Preferences"
activate
delay 1
set the current pane to pane id "com.apple.preference.notifications" --// Open System Events at the notifications prefs
if id of current pane is not "com.apple.preference.notifications" then
set delayCounter to delayCounter + 1
if delayCounter > delayTimeMax then return --//-- too many trys, lets stop
delay 1
my openSystemEvents()
end if
end tell
on error
set delayCounter to delayCounter + 1
if delayCounter > delayTimeMax then return --//-- too many trys, lets stop
delay 1
my openSystemEvents()
end try
end tell
end openSystemEvents
on findTable()
tell application "System Events"
try
tell application process "System Preferences"
set theList to (get group 1 of UI element 1 of every row of table 1 of scroll area 1 of window "Notifications") -- get all the radio groups : the Apps grouped icon and text it the table
end tell
on error
set delayCounter to delayCounter + 1
if delayCounter > delayTimeMax then return --//-- too many trys, lets stop
delay 1
my findTable()
end try
end tell
end findTable
Come ho detto proof of concept. Molto probabilmente lo puoi inserire in un servizio di automazione e utilizzare un tasto di scelta rapida con esso.
Nota anche: a seconda del sistema, potrebbe essere necessario aggiungere altri ritardi per attendere che l'interfaccia utente raggiunga
Aggiornamento 2
Funziona meglio in realtà come servizio di Automator con un tasto di scelta rapida.
In Automator usa un'azione Esegui Applescript e sostituiscilo con il codice del modello con il precedente ..
Imposta l'input su non. e qualsiasi applicazione. Salvalo.
Apri i pref di collegamento. Trova il tuo servizio sotto i Servizi e aggiungi un collegamento.
fatto.