Apple Script to dismiss UPS alert

I am using my Mac Mini as an entertainment center (no keyboard). I use Sofa Control & a Harmony one remote. Works great, except: I have a ups on the Mini, as in Fla we have daily power outages. As a result, often, when I turn on the PVR activity I am presented with the ups warning dialog box which overlays the video & turns off the sound. I can use the keyboard to dismiss the alert but it is quite inconvenient. I would like to have an apple script which I can install in Sofa Control to dismiss this alert, or just as useful would be having the alert not appear.


Any suggestions would be appreciated.

iMac Dual Core 2.4 ghz 2 gig mem, Mac OS X (10.5.5), XP on Bootcamp and Fusion

Posted on Jul 8, 2011 8:48 AM

Reply
33 replies

Jul 10, 2011 10:36 AM in response to twtwtw

Using the Mini as an entertainment center seldom brings up dialog boxes, other than software update, which is usually behind the TV picture. So if this action did an OK on both the UPS and software update dialog that would be a problem.

Maybe I should try looking at activity monitor to see what I can, although I have no clue what I'm looking for. If I turn everything off in the mini and then inspire the message (pull the plug) maybe I'll see something.

Also you mentioned a bug in a not yet posted reply. Could very well be, as my Wifes iMac running 10.5 does not exhibit this phenomena.

I'll reply again when I know more.

Jul 10, 2011 11:51 AM in response to Bill Mullen1

Coincidentally, something on the power grid this morning made my UPS go nuts, so I had about 10 of those dialogs come up while I was trying to do other stuff. If you can run a script from your remote, that may be the way to go, since the UserNotificationCenter.app handles other dialogs such as USB and FireWire stuff.


The following script will dismiss all of the dialogs currently put up by the UserNotificationCenter application, which is a background application that gets launched on demand:


tell application "System Events"
if "UserNotificationCenter" is in (get name of processes whose background only is true) then
get windows of process "UserNotificationCenter"
repeat (count result) times
tell application "UserNotificationCenter" to activate
keystroke return
end repeat
end if
return
end tell


Message was edited by: red_menace - grrr, this forum formatting (or lack thereof) is really starting to become annoying.

Jul 10, 2011 8:26 PM in response to Bill Mullen1

The script just "presses" the default button of whatever dialogs the UserNotificationCenter application has put up. I didn't see a way to identify a particular kind of dialog, so if your software update alert is also put up by the UserNotificationCenter application, it will perform whatever the default operation is - i.e. if the default button starts an update instead of just dismissing the dialog, then that is what will happen.


Hopefully you won't have a lot of different dialogs come up at the same time, but the script can be modified to just deal with the frontmost dialog by removing (or commenting) the beginning and ending repeat statements.

Jul 11, 2011 7:16 AM in response to red_menace

Looking at my Applescript for Dummies book I conclude that commenting out the repeat would look like this:


tell application "System Events"

if "UserNotificationCenter" is in (get name of processes whose background only is true) then

--get windows of process "UserNotificationCenter"

--repeat (count result) times

tell application "UserNotificationCenter" to activate

keystroke return

--end repeat

end if

return

end tell


Is this a good guess?


You're right the forum format makes it look as if more returns are added. Cutting and pasting the text into Text Editor clarifies that.

Jul 11, 2011 7:24 PM in response to Bill Mullen1

Does that include setting everything to -1 (turning power management off)? I'm asking because there's a Hail Mary option you can try if turning off PM stops the alert. turn off power management for the UPS, and then have a background script that watches for the system to go on UPS, and then turns on PM after the machine is already in UPS mode (then turns it back off when you go back to main power). The hope is that you can trick the machine - if it misses that moment where it switches to UPS, it might not think to throw up the alert.


alternately (if turning PM off stops the alerts) you can turn it off permanently for UPS and run a background process that tests time left manually. it probably won't be as reliable as the built in system (assuming the built in system were working correctly), but...

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Apple Script to dismiss UPS alert

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.