Displaying the Running Processes in a list Box and Optionally Closing Some of Them

The “CloseApps” script of the next example displays a list in a dialog window that the user may choose from. The list contains the names of all of the application processes that are running on the computer. These include the programs that have a user interface (e.g., windows and menus that you can interact with) and faceless background applications (FBAs) such as Time Synchronizer or File Sharing Extension. FBAs are programs that work invisibly in the background without interacting with the user. CloseApps is similar to one of the functions of the Windows NT Task Manager utility, which lets you select and shut down a process. Figure 14-5 shows the dialog window displayed by this script. Users may choose one or more processes, and the script will quit the selected programs.

A dialog window displays running processes
Figure 14-5. A dialog window displays running processes

The script shown in Example 14-3 uses the choose from list scripting addition and a list of application processes. An application process is an element of the Finder’s application class. You can get a list of all of the currently running app processes simply by requesting all of the Finder’s application processes, as in:

tell app "Finder" to application processes

This phrase does not sound syntactically pleasing, but it does the job. The script gets a list of all application processes ...

Get AppleScript in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.