|class||Apple Script||MBS MacCocoa Plugin||11.2||✅ Yes||❌ No||❌ No||❌ No||Desktop, Console & Web|
dim source as string = "tell Application ""iTunes"" to pause"
dim n as new NSAppleScriptMBS(source)
Your application may need the NSAppleEventsUsageDescription entry in info.plist to do any AppleScript usage:
If you use hardened runtime, which you need for notarization, you may need the entitlement for Apple Events, too:
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.
- 4 properties
- 14 methods
- method compile as boolean
- method compile(byref error as dictionary) as boolean
- method Constructor(file as folderitem, byref error as Dictionary)
- method Constructor(source as string)
- method Constructor(sourceLines() as string)
- method Constructor(URL as string, byref error as Dictionary)
- method copy as NSAppleScriptMBS
- method execute as NSAppleEventDescriptorMBS
- method execute(byref error as dictionary) as NSAppleEventDescriptorMBS
- method executeAppleEvent(event as NSAppleEventDescriptorMBS, byref error as dictionary) as NSAppleEventDescriptorMBS
- method executeSubroutine(Name as String, parameters() as NSAppleEventDescriptorMBS, byref error as dictionary) as NSAppleEventDescriptorMBS
- method properties as string()
- method setValueDescriptorForProperty(propertyName as string, value as NSAppleEventDescriptorMBS) as boolean
- method valueDescriptorForProperty(propertyName as string) as NSAppleEventDescriptorMBS
- 6 shared methods
- shared method DeterminePermissionToAutomateTarget(target as NSAppleEventDescriptorMBS, theAEEventClass as string = "****", theAEEventID as String = "****", askUserIfNeeded as boolean) as Integer
- shared method NSAppleScriptErrorAppName as string
- shared method NSAppleScriptErrorBriefMessage as string
- shared method NSAppleScriptErrorMessage as string
- shared method NSAppleScriptErrorNumber as string
- shared method NSAppleScriptErrorRange as string
This class has no sub classes.
Some examples using this class:
- /MacCocoa/AppleScript/AppleScript Editor Cocoa
- /MacCocoa/AppleScript/NSAppleScriptMBS query Mail mailboxes
- /MacCocoa/AppleScript/NSAppleScriptMBS with properties
- /MacControls/Listbox and TableView Demos/NSOutlineView/Disk Browser
- MonkeyBread Software Releases the MBS Xojo Plugins in version 18.4
- MBS Xojo Plugins, version 18.4pr7
- MBS Xojo / Real Studio Plugins, version 15.5pr1
- MBS Xojo / Real Studio Plugins, version 15.0pr7
- MBS Real Studio Plugins, version 13.0pr5
- MBS Real Studio Plugins, version 12.3pr16
- MBS Real Studio Plugins, version 12.1pr10
- MBS Real Studio Plugins, version 11.3pr4
- MBS Real Studio Plugins, version 11.2pr11
- MBS Real Studio Plugins, version 11.2pr9
Xojo Developer Magazine
The items on this page are in the following plugins: MBS MacCocoa Plugin.
Feedback: Report problem or ask question.