Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Platforms to show: All Mac Windows Linux Cross-Platform

NSAppleScriptMBS class

Type Topic Plugin Version macOS Windows Linux Console & Web iOS
class Apple Script MBS Cocoa Plugin 11.2 Yes No No Yes, macOS only No
Function: The NSAppleScriptMBS class provides the ability to load, compile, and execute scripts.
dim source as string = "tell Application ""iTunes"" to pause"
dim n as new NSAppleScriptMBS(source)
call n.execute
Important: You should access NSAppleScriptMBS only from the main thread.

This class provides applications with the ability to

  • load a script from a URL or from a text string
  • compile or execute a script or an individual Apple event
  • obtain an NSAppleEventDescriptorMBS containing the reply from an executed script or event
  • obtain an attributed string for a compiled script, suitable for display in a script editor
  • obtain various kinds of information about any errors that may occur

Important: NSAppleScriptMBS provides the execute method so that you can send an Apple event to invoke a handler in a script. (In an AppleScript script, a handler is the equivalent of a function.) However, you cannot use this method to send Apple events to other applications.

When you create an instance of NSAppleScriptMBS object, you can use a URL or a folderitem to specify a script that can be in either text or compiled form, or you can supply the script as a string. Should an error occur when compiling or executing the script, several of the methods return a dictionary containing error information. The keys for obtaining error information, such as NSAppleScriptErrorMessage, are described in the Constants section.

Feedback, Comments & Corrections

This class has no sub classes.

Some examples which use this class:

The items on this page are in the following plugins: MBS Cocoa Plugin.

NSAppleEventManagerSuspensionIDMBS   -   NSApplicationDelegateMBS

MBS Xojo Plugins