Platforms to show: All Mac Windows Linux Cross-Platform

/MacCocoa/AppleScript/DeterminePermissionToAutomateTarget


Required plugins for this example: MBS MacCocoa Plugin, MBS MacBase Plugin, MBS Main Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCocoa/AppleScript/DeterminePermissionToAutomateTarget

This example is the version from Wed, 27th Oct 2020.

Project "DeterminePermissionToAutomateTarget.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Const errAEEventNotPermitted = -1743
Const errAEEventWouldRequireUserConsent = -1744
Const errAETargetAddressNotPermitted = -1742
Const procNotFound = -600
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() dim target as NSAppleEventDescriptorMBS = NSAppleEventDescriptorMBS.descriptorWithBundleIdentifier("com.apple.Safari") // we ask for all apple events dim e as integer = NSAppleScriptMBS.DeterminePermissionToAutomateTarget(target, "****", "****", true) MsgBox str(e)+": "+errorToString(e) End EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() dim target as NSAppleEventDescriptorMBS = NSAppleEventDescriptorMBS.descriptorWithBundleIdentifier("com.apple.Finder") // we ask for restart apple events dim e as integer = NSAppleScriptMBS.DeterminePermissionToAutomateTarget(target, "MACS", "rest", true) MsgBox str(e)+": "+errorToString(e) End EventHandler
End Control
Function errorToString(e as Integer) As string Select case e case 0 return "OK" case errAEEventNotPermitted return "Not Permitted" case errAEEventWouldRequireUserConsent return "Would require user consent" case procNotFound return "Process not found or running" case errAETargetAddressNotPermitted return "Target address not permitted" end Select End Function
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
ExternalFile info
End ExternalFile
End Project

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


The biggest plugin in space...