How can I keep System Events from deactivating?
Save this plist as ~/Library/LaunchAgents/systemevents.plist:

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
  &lt;key&gt;Label&lt;/key&gt;
  &lt;string&gt;systemevents&lt;/string&gt;
  &lt;key&gt;Program&lt;/key&gt;
  &lt;string&gt;/System/Library/CoreServices/System Events.app/Contents/MacOS/System Events&lt;/string&gt;
  &lt;key&gt;RunAtLoad&lt;/key&gt;
  &lt;true/&gt;
  &lt;key&gt;KeepAlive&lt;/key&gt;
  &lt;true/&gt;
&lt;/dict&gt;
&lt;/plist&gt;


Then run launchctl load ~/Library/LaunchAgents/systemevents.plist.

It doesn't fix the glitches in the QuickHue script though. I was probably wrong when I said that the error was caused by System Events not being open.