NSAppleScriptMBS class

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

NSAppleScriptMBS class

Type Topic Plugin Version macOS Windows Linux iOS Targets
class Apple Script MBS MacCocoa Plugin 11.2 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
The NSAppleScriptMBS class provides the ability to load, compile, and execute scripts.
Example
dim source as string = "tell Application ""iTunes"" to pause"
dim n as new NSAppleScriptMBS(source)
call n.execute

Your application may need the NSAppleEventsUsageDescription entry in info.plist to do any AppleScript usage:
https://developer.apple.com/documentation/bundleresources/information_property_list/nsappleeventsusagedescription

If you use hardened runtime, which you need for notarization, you may need the entitlement for Apple Events, too:
https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_security_automation_apple-events

Important: You should access NSAppleScriptMBS only from the main thread.

This class provides applications with the ability to


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.

This class has no sub classes.

Some examples using this class:

Blog Entries

Xojo Developer Magazine

Release notes


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


NSAppleEventManagerSuspensionIDMBS   -   NSApplicationDelegateMBS


💬 Ask a question or report a problem