Documentation
¶
Overview ¶
Package scriptingbridge provides a fluent Go API over the macOS ScriptingBridge framework.
Index ¶
- type Application
- func ApplicationFromID(id objc.ID) *Application
- func ApplicationWithBundleIdentifier(ident string) *Application
- func ApplicationWithProcessIdentifier(pid int) *Application
- func ApplicationWithURL(url string) *Application
- func NewApplicationWithBundleIdentifier(ident string) *Application
- func NewApplicationWithProcessIdentifier(pid int) *Application
- func NewApplicationWithURL(url string) *Application
- func (x *Application) Activate()
- func (x *Application) ClassForScriptingClass(className string) objc.Class
- func (x *Application) Delegate() raw.SBApplicationDelegate
- func (x *Application) ID() objc.ID
- func (x *Application) IsRunning() bool
- func (x *Application) LaunchFlags() launchservices.LSLaunchFlags
- func (x *Application) SendMode() int
- func (x *Application) SetDelegate(delegate raw.SBApplicationDelegate)
- func (x *Application) SetLaunchFlags(launchFlags launchservices.LSLaunchFlags)
- func (x *Application) SetSendMode(sendMode int)
- func (x *Application) SetTimeout(timeout int)
- func (x *Application) Timeout() int
- func (x *Application) Unwrap() *raw.SBApplication
- func (x *Application) WithDelegate(delegate raw.SBApplicationDelegate) *Application
- func (x *Application) WithLaunchFlags(launchFlags launchservices.LSLaunchFlags) *Application
- func (x *Application) WithSendMode(sendMode int) *Application
- func (x *Application) WithTimeout(timeout int) *Application
- type Applicationable
- type ElementArray
- func (x *ElementArray) ArrayByApplyingSelector(selector objc.SEL) *foundation.NSArray[objc.ID]
- func (x *ElementArray) ArrayByApplyingSelectorWithObject(aSelector objc.SEL, argument objc.ID) *foundation.NSArray[objc.ID]
- func (x *ElementArray) Get() *foundation.NSArray[objc.ID]
- func (x *ElementArray) ID() objc.ID
- func (x *ElementArray) ObjectAtLocation(location objc.ID) objc.ID
- func (x *ElementArray) ObjectWithID(identifier objc.ID) objc.ID
- func (x *ElementArray) ObjectWithName(name string) objc.ID
- func (x *ElementArray) Unwrap() *raw.SBElementArray[objc.ID]
- type ElementArrayable
- type Object
- func (x *Object) ElementArrayWithCode(code uint) *raw.SBElementArray[objc.ID]
- func (x *Object) Get() objc.ID
- func (x *Object) ID() objc.ID
- func (x *Object) LastError() unsafe.Pointer
- func (x *Object) PropertyWithClassCode(cls objc.Class, code uint) *Object
- func (x *Object) PropertyWithCode(code uint) *Object
- func (x *Object) SetTo(value objc.ID)
- func (x *Object) Unwrap() *raw.SBObject
- type ObjectProvider
- type Objectable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
The SBApplication class provides a mechanism enabling an Objective-C program to send Apple events to a scriptable application and receive Apple events in response. It thereby makes it possible for that program to control the application and exchange data with it. Scripting Bridge works by bridging data types between Apple event descriptors and Cocoa objects.
Application wraps raw.SBApplication with a fluent Go API.
func ApplicationFromID ¶
func ApplicationFromID(id objc.ID) *Application
ApplicationFromID adopts an existing object pointer as a Application (nil for 0).
func ApplicationWithBundleIdentifier ¶
func ApplicationWithBundleIdentifier(ident string) *Application
ApplicationWithBundleIdentifier calls the underlying SBApplicationApplicationWithBundleIdentifier.
func ApplicationWithProcessIdentifier ¶
func ApplicationWithProcessIdentifier(pid int) *Application
ApplicationWithProcessIdentifier calls the underlying SBApplicationApplicationWithProcessIdentifier.
func ApplicationWithURL ¶
func ApplicationWithURL(url string) *Application
ApplicationWithURL calls the underlying SBApplicationApplicationWithURL.
func NewApplicationWithBundleIdentifier ¶
func NewApplicationWithBundleIdentifier(ident string) *Application
Returns an instance of an SBApplication subclass that represents the target application identified by the given bundle identifier.
NewApplicationWithBundleIdentifier creates a new Application.
func NewApplicationWithProcessIdentifier ¶
func NewApplicationWithProcessIdentifier(pid int) *Application
Returns an instance of an SBApplication subclass that represents the target application identified by the given process identifier.
NewApplicationWithProcessIdentifier creates a new Application.
func NewApplicationWithURL ¶
func NewApplicationWithURL(url string) *Application
Returns an instance of an SBApplication subclass that represents the target application identified by the given URL.
NewApplicationWithURL creates a new Application.
func (*Application) Activate ¶
func (x *Application) Activate()
Moves the target application to the foreground immediately.
Activate calls the underlying Activate.
func (*Application) ClassForScriptingClass ¶
func (x *Application) ClassForScriptingClass(className string) objc.Class
Returns a class object that represents a particular class in the target application.
ClassForScriptingClass calls the underlying ClassForScriptingClass.
func (*Application) Delegate ¶
func (x *Application) Delegate() raw.SBApplicationDelegate
The error-handling delegate of the receiver. The delegate should implement the “SBApplicationDelegate/eventDidFail:withError:“ method of the “SBApplicationDelegate“ informal protocol.
Delegate calls the underlying Delegate.
func (*Application) ID ¶
func (x *Application) ID() objc.ID
ID returns the underlying Objective-C object pointer (objc.ID), for passing to C APIs that take an object or CFTypeRef pointer.
func (*Application) IsRunning ¶
func (x *Application) IsRunning() bool
A Boolean that indicates whether the target application represented by the receiver is running. <doc://com.apple.documentation/documentation/swift/true> if the application is running, <doc://com.apple.documentation/documentation/swift/false> otherwise. This may be <doc://com.apple.documentation/documentation/swift/true> for instances initialized with a bundle identifier or URL because `SBApplication` launches the application only when it's necessary to send it an event.
IsRunning calls the underlying IsRunning.
func (*Application) LaunchFlags ¶
func (x *Application) LaunchFlags() launchservices.LSLaunchFlags
The launch flags for the application represented by the receiver. For more information, see <doc://com.apple.documentation/documentation/coreservices/launch_services>.
LaunchFlags calls the underlying LaunchFlags.
func (*Application) SendMode ¶
func (x *Application) SendMode() int
The mode for sending Apple events to the target application. For more information, see <doc://com.apple.documentation/documentation/applicationservices/apple_event_manager>. The default send mode is <doc://com.apple.documentation/documentation/coreservices/1542914-anonymous/kaewaitreply>. If the send mode is something other than `kAEWaitReply`, the receiver might not correctly handle reply events from the target application.
SendMode calls the underlying SendMode.
func (*Application) SetDelegate ¶
func (x *Application) SetDelegate(delegate raw.SBApplicationDelegate)
SetDelegate calls the underlying SetDelegate.
func (*Application) SetLaunchFlags ¶
func (x *Application) SetLaunchFlags(launchFlags launchservices.LSLaunchFlags)
SetLaunchFlags calls the underlying SetLaunchFlags.
func (*Application) SetSendMode ¶
func (x *Application) SetSendMode(sendMode int)
SetSendMode calls the underlying SetSendMode.
func (*Application) SetTimeout ¶
func (x *Application) SetTimeout(timeout int)
SetTimeout calls the underlying SetTimeout.
func (*Application) Timeout ¶
func (x *Application) Timeout() int
The period the application will wait to receive reply Apple events. For more information, see <doc://com.apple.documentation/documentation/applicationservices/apple_event_manager>. The default timeout value is <doc://com.apple.documentation/documentation/coreservices/1542814-timeout_constants/kaedefaulttimeout>, which is about a minute. If you want the receiver to wait indefinitely for reply Apple events, use <doc://com.apple.documentation/documentation/coreservices/1542814-timeout_constants/knotimeout>. For more information, see <doc://com.apple.documentation/documentation/applicationservices/apple_event_manager>.
Timeout calls the underlying Timeout.
func (*Application) Unwrap ¶
func (x *Application) Unwrap() *raw.SBApplication
Unwrap returns the underlying raw.SBApplication.
func (*Application) WithDelegate ¶
func (x *Application) WithDelegate(delegate raw.SBApplicationDelegate) *Application
The error-handling delegate of the receiver.
WithDelegate sets the delegate property and returns the receiver for chaining.
func (*Application) WithLaunchFlags ¶
func (x *Application) WithLaunchFlags(launchFlags launchservices.LSLaunchFlags) *Application
The launch flags for the application represented by the receiver.
WithLaunchFlags sets the launchFlags property and returns the receiver for chaining.
func (*Application) WithSendMode ¶
func (x *Application) WithSendMode(sendMode int) *Application
The mode for sending Apple events to the target application.
WithSendMode sets the sendMode property and returns the receiver for chaining.
func (*Application) WithTimeout ¶
func (x *Application) WithTimeout(timeout int) *Application
The period the application will wait to receive reply Apple events.
WithTimeout sets the timeout property and returns the receiver for chaining.
type Applicationable ¶
type Applicationable interface {
Unwrap() *raw.SBApplication
WithDelegate(delegate raw.SBApplicationDelegate) *Application
WithLaunchFlags(launchFlags launchservices.LSLaunchFlags) *Application
WithSendMode(sendMode int) *Application
WithTimeout(timeout int) *Application
ClassForScriptingClass(className string) objc.Class
Activate()
IsRunning() bool
Delegate() raw.SBApplicationDelegate
SetDelegate(delegate raw.SBApplicationDelegate)
LaunchFlags() launchservices.LSLaunchFlags
SetLaunchFlags(launchFlags launchservices.LSLaunchFlags)
SendMode() int
SetSendMode(sendMode int)
Timeout() int
SetTimeout(timeout int)
}
Applicationable is the interface implemented by Application, for mocking and DI.
type ElementArray ¶
type ElementArray struct {
// contains filtered or unexported fields
}
SBElementArray is subclass of NSMutableArray that manages collections of related SBObject objects. For example, when you ask the Finder for a list of disks, or ask iTunes for a list of playlists, you get the result back as an SBElementArray containing Scripting Bridge objects representing those items.
ElementArray wraps raw.SBElementArray with a fluent Go API.
func ElementArrayFromID ¶
func ElementArrayFromID(id objc.ID) *ElementArray
ElementArrayFromID adopts an existing object pointer as a ElementArray (nil for 0).
func NewElementArray ¶
func NewElementArray() *ElementArray
NewElementArray creates a new ElementArray.
func (*ElementArray) ArrayByApplyingSelector ¶
func (x *ElementArray) ArrayByApplyingSelector(selector objc.SEL) *foundation.NSArray[objc.ID]
Returns an array containing the results of sending the specified message to each object in the receiver.
ArrayByApplyingSelector calls the underlying ArrayByApplyingSelector.
func (*ElementArray) ArrayByApplyingSelectorWithObject ¶
func (x *ElementArray) ArrayByApplyingSelectorWithObject(aSelector objc.SEL, argument objc.ID) *foundation.NSArray[objc.ID]
Returns an array containing the results of sending the specified message to each object in the receiver.
ArrayByApplyingSelectorWithObject calls the underlying ArrayByApplyingSelectorWithObject.
func (*ElementArray) Get ¶
func (x *ElementArray) Get() *foundation.NSArray[objc.ID]
Forces evaluation of the receiver, causing the real object to be returned immediately.
Get calls the underlying Get.
func (*ElementArray) ID ¶
func (x *ElementArray) ID() objc.ID
ID returns the underlying Objective-C object pointer (objc.ID), for passing to C APIs that take an object or CFTypeRef pointer.
func (*ElementArray) ObjectAtLocation ¶
func (x *ElementArray) ObjectAtLocation(location objc.ID) objc.ID
Returns the object at the given location in the receiver.
ObjectAtLocation calls the underlying ObjectAtLocation.
func (*ElementArray) ObjectWithID ¶
func (x *ElementArray) ObjectWithID(identifier objc.ID) objc.ID
Returns the object in the array with the given identifier.
ObjectWithID calls the underlying ObjectWithID.
func (*ElementArray) ObjectWithName ¶
func (x *ElementArray) ObjectWithName(name string) objc.ID
Returns the object in the array with the given name.
ObjectWithName calls the underlying ObjectWithName.
func (*ElementArray) Unwrap ¶
func (x *ElementArray) Unwrap() *raw.SBElementArray[objc.ID]
Unwrap returns the underlying raw.SBElementArray.
type ElementArrayable ¶
type ElementArrayable interface {
Unwrap() *raw.SBElementArray[objc.ID]
ObjectWithName(name string) objc.ID
ObjectWithID(identifier objc.ID) objc.ID
ObjectAtLocation(location objc.ID) objc.ID
ArrayByApplyingSelector(selector objc.SEL) *foundation.NSArray[objc.ID]
ArrayByApplyingSelectorWithObject(aSelector objc.SEL, argument objc.ID) *foundation.NSArray[objc.ID]
Get() *foundation.NSArray[objc.ID]
}
ElementArrayable is the interface implemented by ElementArray, for mocking and DI.
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
The SBObject class declares methods that can be invoked on any object in a scriptable application. It defines methods for getting elements and properties of an object, as well as setting a given object to a new value.
Object wraps raw.SBObject with a fluent Go API.
func NewObjectWithData ¶
Returns an instance of an SBObject subclass initialized with the given data.
NewObjectWithData creates a new Object.
func NewObjectWithElementCodePropertiesData ¶
func NewObjectWithElementCodePropertiesData(code uint, properties purego.IDer, data objc.ID) *Object
Returns an instance of an SBObject subclass initialized with the specified properties and data and added to the designated element array.
NewObjectWithElementCodePropertiesData creates a new Object.
func NewObjectWithProperties ¶
Returns an instance of an SBObject subclass initialized with the specified properties.
NewObjectWithProperties creates a new Object.
func ObjectFromID ¶
ObjectFromID adopts an existing object pointer as a Object (nil for 0).
func (*Object) ElementArrayWithCode ¶
Returns an array containing every child of the receiver with the given class-type code.
ElementArrayWithCode calls the underlying ElementArrayWithCode.
func (*Object) Get ¶
Forces evaluation of the receiver, causing the real object to be returned immediately.
Get calls the underlying Get.
func (*Object) ID ¶
ID returns the underlying Objective-C object pointer (objc.ID), for passing to C APIs that take an object or CFTypeRef pointer.
func (*Object) LastError ¶
The error from the last event this object sent, or nil if it succeeded.
LastError calls the underlying LastError.
func (*Object) PropertyWithClassCode ¶
Returns an object of the designated scripting class representing the specified property of the receiver
PropertyWithClassCode calls the underlying PropertyWithClassCode.
func (*Object) PropertyWithCode ¶
Returns an object representing the specified property of the receiver.
PropertyWithCode calls the underlying PropertyWithCode.
type ObjectProvider ¶
type ObjectProvider interface {
// contains filtered or unexported methods
}
ObjectProvider is implemented by Object and any idiomatic type wrapping a SBObject subclass.
type Objectable ¶
type Objectable interface {
Unwrap() *raw.SBObject
Get() objc.ID
LastError() unsafe.Pointer
PropertyWithCode(code uint) *Object
PropertyWithClassCode(cls objc.Class, code uint) *Object
ElementArrayWithCode(code uint) *raw.SBElementArray[objc.ID]
SetTo(value objc.ID)
}
Objectable is the interface implemented by Object, for mocking and DI.