System Events App Mac

  

Every system access, security change, operating system twitch, hardware failure, and driver hiccup all end up in one or another Event Log. The Event Viewer scans those text log files, aggregates them, and puts a pretty interface on a deathly dull, voluminous set of machine-generated data. System events.app In the process of installing new Office 2011 on my MacBook Pro, then a screen comes up with the following: 'Where is System Events.app?' I don't know what to select, so I press cancel, then the installation fails.

Automating the User Interface

Unfortunately, not every Mac app has scripting support, and those that do may not always have scripting support for every task you want to automate. You can often work around such limitations, however, by writing a user interface script, commonly called a UI or GUI script. A user interface script simulates user interaction, such as mouse clicks and keystrokes, allowing the script to select menu items, push buttons, enter text into text fields, and more.

The file system events API provides a way for your application to ask for notification when the contents of a directory hierarchy are modified. For example, your application can use this to quickly detect when the user modifies a file within a project bundle using another application.

Enabling User Interface Scripting

User interface scripting relies upon the OS X accessibility frameworks that provide alternative methods of querying and controlling the interfaces of apps and the system. By default, accessibility control of apps is disabled. For security and privacy reasons, the user must manually enable it on an app-by-app (including script apps) basis.

  1. Launch System Preferences and click Security & Privacy.

  2. Click Accessibility.

  3. Choose an app and click Open.

System Events App Mac

When running an app that requires accessibility control for the first time, the system prompts you to enable it. See Figure 37-1.

Attempting to run an app that has not been given permission to use accessibility features results in an error. See Figure 37-2.

Note

To run a user interface script in Script Editor, you must enable accessibility for Script Editor.

Admin credentials are required to perform enable user interface scripting.

Events

Targeting an App

Mac Event Log

User interface scripting terminology is found in the Processes Suite of the System Events scripting dictionary. This suite includes terminology for interacting with most types of user interface elements, including windows, buttons, checkboxes, menus, radio buttons, text fields, and more. In System Events, the process class represents a running app. Listing 37-1 shows how to target an app using this class.

APPLESCRIPT

Listing 37-1AppleScript: Targeting an app for user interface scripting
  1. tell application 'System Events'
  2. tell process 'Safari'
  3. -- Perform user interface scripting tasks
  4. end tell
  5. end tell

To control the user interface of an app, you must first inspect the app and determine its element hierarchy. This can be done by querying the app. For example, Listing 37-2 asks Safari for a list of menus in the menu bar.

APPLESCRIPT

Listing 37-2AppleScript: Querying an app for user interface element information
  1. tell application 'System Events'
  2. tell process 'Safari'
  3. name of every menu of menu bar 1
  4. end tell
  5. end tell
  6. --> Result: {'Apple', 'Safari', 'File', 'Edit', 'View', 'History', 'Bookmarks', 'Develop', 'Window', 'Help'}

Accessibility Inspector (Figure 37-3) makes it even easier to identify user interface element information. This app is included with Xcode. To use it, open Xcode and select Xcode > Open Developer Tool > Accessibility Inspector.

Once you know how an element fits into an interface, you target it within that hierarchy. For example, button X of window Y of process Z.

Clicking a Button

Use the click command to click a button. Listing 37-3 clicks a button in the Safari toolbar to toggle the sidebar between open and closed.

APPLESCRIPT

Listing 37-3AppleScript: Clicking a button
  1. tell application 'System Events'
  2. tell process 'Safari'
  3. tell toolbar of window 1
  4. click (first button where its accessibility description = 'Sidebar')
  5. end tell
  6. end tell
  7. end tell
  8. --> Result: {button 1 of toolbar 1 of window 'AppleScript: Graphic User Interface (GUI) Scripting' of application process 'Safari' of application 'System Events'}

Choosing a Menu Item

Menu items can have a fairly deep hierarchy within the interface of an app. A menu item generally resides within a menu, which resides within a menu bar. In scripting, they must be addressed as such. Listing 37-4 selects the Pin Tab menu item in the Window menu of Safari.

APPLESCRIPT

Listing 37-4AppleScript: Choosing a menu item
  1. tell application 'System Events'
  2. tell process 'Safari'
  3. set frontmost to true
  4. click menu item 'Pin Tab' of menu 'Window' of menu bar 1
  5. end tell
  6. end tell
  7. --> Result: menu item 'Pin Tab' of menu 'Window' of menu bar item 'Window' of menu bar 1 of application process 'Safari' of application 'System Events'

Note

Scripting the user interface of an app can be tedious and repetitious. To streamline the process, consider creating handlers to perform common functions. For example, Listing 37-5 shows a handler that can be used to choose any menu item of any menu in any running app.

APPLESCRIPT

Listing 37-5AppleScript: A handler that chooses a menu item
  1. on chooseMenuItem(theAppName, theMenuName, theMenuItemName)
  2. try
  3. -- Bring the target app to the front
  4. tell application theAppName
  5. activate
  6. end tell
  7. -- Target the app
  8. tell application 'System Events'
  9. tell process theAppName
  10. -- Target the menu bar
  11. tell menu bar 1
  12. -- Target the menu by name
  13. tell menu bar item theMenuName
  14. tell menu theMenuName
  15. -- Click the menu item
  16. click menu item theMenuItemName
  17. end tell
  18. end tell
  19. end tell
  20. end tell
  21. end tell
  22. return true
  23. on error
  24. return false
  25. end try
  26. end chooseMenuItem

Listing 37-6 calls the handler in Listing 37-5 to select the Pin Tab menu item in the Window menu of Safari.

APPLESCRIPT

Listing 37-6AppleScript: Calling a handler to choose a menu item

Choosing a Submenu Item

Some menus contain other menus. In these cases, it may be necessary to select a menu item in a submenu of a menu. Listing 37-7 demonstrates how this would be done by selecting a submenu item in Safari.

Mac Apps Download

APPLESCRIPT

Listing 37-7AppleScript: Selecting a submenu item
  1. tell application 'System Events'
  2. tell process 'Safari'
  3. set frontmost to true
  4. click menu item 'Email This Page' of menu of menu item 'Share' of menu 'File' of menu bar 1
  5. end tell
  6. end tell
  7. --> Result: {menu item 'Email This Page' of menu 'Share' of menu item 'Share' of menu 'File' of menu bar item 'File' of menu bar 1 of application process 'Safari' of application 'System Events'}

Copyright © 2018 Apple Inc. All rights reserved. Terms of Use | Privacy Policy | Updated: 2016-06-13

Keeping your software up to date is one of the most important things you can do to maintain the security of your Mac. That includes installing all available macOS software updates, including security updates and the background updates described in this article.

Background updates include security-configuration updates and system data files, which are automatically installed by default. They don't cause your Mac to restart, but some take effect only after you restart.

Background updates include:

  • Security-configuration updates, which help make your Mac more secure by identifying malicious software and preventing its installation. When you restart your Mac, these updates also remove any malicious software that is identified but already installed.
  • System data files, which provide new word lists, speech-recognition assets, voice assets, better suggestions for contacts and events, and more. Some system data files are installed only when you turn on or use features that require them.

To make sure that you always get these background updates promptly, keep the “Install system data files and security updates” setting enabled in Software Update preferences. Go to System Preferences > Software Update, then click Advanced.

View background updates on your Mac

System Information lists most Apple and third-party software that has been installed manually or automatically.

Choose Apple menu () > About This Mac then click the System Report button. From the Software section of the sidebar, select Installations and click the Install Date column to sort by date.

Security-configuration updates

These security-configuration updates are installed in the background:

  • Core Services Application Configuration Data: Blocks incompatible apps from being launched
  • EFICheck AllowListAll: Verifies that Apple provided the firmware for your Mac
  • Gatekeeper Configuration Data: Helps protect your Mac from apps created by unidentified developers
  • Incompatible Kernel Extension Configuration Data: Blocks incompatible kernel extensions that may adversely affect your Mac
  • MRTConfigData: Removes known malware
  • TCC Configuration Data: Improves compatibility of specified software with macOS security features
  • XProtectPlistConfigData: Prevents known malware from running

System data files

These system data files are installed in the background:

System Events App Mac Computer

  • Updated fonts
  • Updated system voice-dictation services
  • New or updated vocabulary words for the Dictionary app
  • Improved language models, autocorrect, spell check, input methods, transliteration of Roman to international characters, and more
  • Enhanced suggestions for adding new contacts and calendar events in macOS apps, and improved time-to-leave alerts
  • Improved discovery of Bluetooth devices and communication with them
  • Improved automatic routing of network requests based on traffic
  • Improved updating of iCloud Keychain credentials and passwords across your Apple devices
  • Support for new top-level domains in Safari
  • New and improved website suggestions, available as you type in the Smart Search field in Safari
  • Updated definitions for SSL certificate types
  • System-level support for more digital camera RAW formats
  • Improved tuning of Portrait mode images captured on iOS devices and viewed in the Photos app on Mac
  • Updated instructional videos in System Preferences
  • Updated information about support for media formats
  • Firmware updates for built-in trackpads and external trackpads, mice, keyboards, and displays
  • Firmware updates for Apple power adapters
  • Firmware updates for Siri Remote development in Xcode
  • Updated information to help automatically block incompatible kernel extensions (kexts)
  • Updated information to help automatically identify and block incompatible apps from opening or being migrated to a new Mac