Platforms to show: All Mac Windows Linux Cross-Platform
Back to NSAppleScriptMBS class.
NSAppleScriptMBS.DeterminePermissionToAutomateTarget(target as NSAppleEventDescriptorMBS, theAEEventClass as string = "****", theAEEventID as String = "****", askUserIfNeeded as boolean) as Integer
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | Apple Script | MBS MacCocoa Plugin | 18.4 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Mac OS 10.14 and later impose additional requirements on applications when they send AppleEvents to other applications in order to insure that users are aware of and consent to allowing such control or information exchange. Generally this involves the user being prompted in a secure fashion the first time an application attempts to send an AppleEvent to another application. If the user consents then this application can send events to the target. If the user does not consent then any future attempts to send AppleEvents will result in a failure with errAEEventNotPermitted (-1743) being returned.
Certain AppleEvents are allowed to be sent without prompting the user. Pass typeWildCard for the eventClass and eventID to determine if every event is allowed to be sent from this application to the target.
Applications can determine, without sending an AppleEvent to a target application, whether they are allowed to send AppleEvents to the target with this function. If askUserIfNeeded is true, and this application does not yet have permission to send AppleEvents to the target, then the user will be asked if permission can be granted; if askUserIfNeeded is false and permission has not been granted, then errAEEventWouldRequireUserConsent (-1744) will be returned.
The target must refer to an already running application.
If the current application is permitted to send the given AppleEvent to the target, then noErr (0) will be returned. If the current application is not permitted to send the event, errAEEventNotPermitted (-1743) will be returned. If the target application is not running, then procNotFound (-600) will be returned. If askUserIfNeeded is false, and this application is not yet permitted to send AppleEvents to the target, then errAEEventWouldRequireUserConsent (-1744) will be returned.
Mac OS X threading: Thread safe since version 10.14. Do not call this function on your main thread because it may take arbitrarily long to return if the user needs to be prompted for consent.
target: The address descriptor. Before calling AEDeterminePermissionToAutomateTarget, you set the descriptor to identify the target application for the Apple event. The target address descriptor must refer to a running application. If the target application is on another machine, then Remote AppleEvents must be enabled on that machine for the user.
theAEEventClass: The event class of the Apple event to determine permission for.
theAEEventID: The event ID of the Apple event to determine permission for.
askUserIfNeeded: a Boolean; if true, and if this application does not yet have permission to send events to the target application, then prompt the user to obtain permission. If false, do not prompt the user.
Plugin returns -1 if the function is not available, e.g. older MacOS versions.
Some examples using this method:
NSAppleScriptMBS.NSAppleScriptErrorAppName as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | Apple Script | MBS MacCocoa Plugin | 11.2 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Value for this key is a string that specifies the name of the application that generated the error.
NSAppleScriptMBS.NSAppleScriptErrorBriefMessage as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | Apple Script | MBS MacCocoa Plugin | 11.2 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Value for this key is a string that provides a brief description of the error.
NSAppleScriptMBS.NSAppleScriptErrorMessage as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | Apple Script | MBS MacCocoa Plugin | 11.2 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Value for this key is a NSRangeMBS object.
Some examples using this method:
NSAppleScriptMBS.NSAppleScriptErrorNumber as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | Apple Script | MBS MacCocoa Plugin | 11.2 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Value for this key is a number that specifies the error number.
NSAppleScriptMBS.NSAppleScriptErrorRange as string
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
shared method | Apple Script | MBS MacCocoa Plugin | 11.2 | ✅ Yes | ❌ No | ❌ No | ❌ No | Desktop, Console & Web |
Value for this key is a string that supplies a detailed description of the error condition.
The items on this page are in the following plugins: MBS MacCocoa Plugin.