Last edited · 6 revisions  

 


System Events (DRAFT)

updated  2017-10-27 16:44 GMT-0500

Placeholder

This is just a placeholder while we are gathering information and preparing the text for this page.


Background

From Shane Stanley: 3 For a long time Apple has been discouraging scripting additions, and the advice at the time was to use faceless background applications -- which is what System Events is -- instead. So as time went on, new functionality that might otherwise have been added to Standard Additions was added to System Events. They followed their own advice.

System Events exists only for Mac Automation (AppleScript and other OSA Languages and Automator). GUI scripting is only a part of it.

Some Features/Tools of System Events

(based on post by Ed Stockly)

  • GUI Scripting
  • Alternate to (and often better than) the Finder for dealing with:
    • Windows, Files, and Folders
  • Manipulate image, audio and movie files
  • Manipulate QuickTime settings
  • Work with CDs and DVDs
  • Manipulate the dock
  • plist access
  • XML commands
  • Progress indicators
  • Info on Running Apps/Processes
  • Get/Set Preferences

Using System Events In Lieu Of info for Command

ASLG: info for 1
Special Considerations Because info for returns so much information, it can be slow, and because it only works on one file at a time, it can be difficult to use. The recommended technique is to use System Events or Finder to ask for the particular properties you want.

Using System Events to Access UI Elements

Whenever possible, it is generally best to use an App's scripting terms to achieve your objectives. However, sometimes this is not possible, and we must resort to System Events. ❗️ Caution: Scripts using this method may be easily broke if an App changes its UI elements, which often happens with major updates.

MASG: Automating the User Interface 2
Using System Events to Access UI Elements

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.

References

1.  AppleScript Language Guide (ASLG)
2.  Mac Automation Scripting Guide (MASG)
3.  Shane Stanley. (Oct 2017). AppleScript-Users mailing list (ASUL)