Documentation
¶
Overview ¶
Package scriptingbridge provides a fluent Go API over the macOS ScriptingBridge framework.
Each With… method sets one property and returns its receiver, so configuration calls can be chained.
Types ¶
Each base type below lists the concrete types you construct and pass where the base is accepted:
- Object: Application
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
- type ElementArray
- func (ea *ElementArray) Description() string
- func (ea *ElementArray) Get() []obj.Object
- func (ea *ElementArray) IsEqual(other obj.Object) bool
- func (ea *ElementArray) IsKind(className string) bool
- func (ea *ElementArray) ObjectAtLocation(location obj.Object) obj.Object
- func (ea *ElementArray) ObjectWithID(identifier obj.Object) obj.Object
- func (ea *ElementArray) ObjectWithName(name string) obj.Object
- func (ea *ElementArray) String() string
- type Object
- func (o *Object) Description() string
- func (o *Object) ElementArrayWithCode(code int) obj.Object
- func (o *Object) Get() obj.Object
- func (o *Object) IsEqual(other obj.Object) bool
- func (o *Object) IsKind(className string) bool
- func (o *Object) PropertyWithCode(code int) *Object
- func (o *Object) SetTo(value obj.Object)
- func (o *Object) String() string
- type ObjectProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application struct {
Object
}
Application is an idiomatic wrapper over the Objective-C class SBApplication.
It embeds Object, promoting that type's methods.
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.
func ApplicationFromID ¶
func ApplicationFromID(id objc.ID) *Application
ApplicationFromID adopts an existing Objective-C object as a Application (nil for 0), retaining it and registering a release finalizer.
func ApplicationWithBundleIdentifier ¶
func ApplicationWithBundleIdentifier(ident string) *Application
ApplicationWithBundleIdentifier returns the shared instance representing the target application specified by its bundle identifier.
func ApplicationWithProcessIdentifier ¶
func ApplicationWithProcessIdentifier(pid int) *Application
ApplicationWithProcessIdentifier returns the shared instance representing a target application specified by its process identifier.
func ApplicationWithURL ¶
func ApplicationWithURL(url string) *Application
ApplicationWithURL returns the shared instance representing a target application specified by the given URL.
func NewApplicationWithBundleIdentifier ¶
func NewApplicationWithBundleIdentifier(ident string) *Application
NewApplicationWithBundleIdentifier returns an instance of an SBApplication subclass that represents the target application identified by the given bundle identifier.
func NewApplicationWithProcessIdentifier ¶
func NewApplicationWithProcessIdentifier(pid int) *Application
NewApplicationWithProcessIdentifier returns an instance of an SBApplication subclass that represents the target application identified by the given process identifier.
func NewApplicationWithURL ¶
func NewApplicationWithURL(url string) *Application
NewApplicationWithURL returns an instance of an SBApplication subclass that represents the target application identified by the given URL.
func (*Application) Activate ¶
func (a *Application) Activate()
Activate moves the target application to the foreground immediately.
func (*Application) IsRunning ¶
func (a *Application) IsRunning() bool
IsRunning reports whether 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.
func (*Application) SendMode ¶
func (a *Application) SendMode() int
SendMode returns 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.
func (*Application) Timeout ¶
func (a *Application) Timeout() int
Timeout returns 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>.
func (*Application) WithSendMode ¶
func (a *Application) WithSendMode(sendMode int) *Application
WithSendMode sets the mode for sending Apple events to the target application.
func (*Application) WithTimeout ¶
func (a *Application) WithTimeout(timeout int) *Application
WithTimeout sets the period the application will wait to receive reply Apple events.
type ElementArray ¶
ElementArray is an idiomatic wrapper over the Objective-C class SBElementArray.
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.
func ElementArrayFromID ¶
func ElementArrayFromID(id objc.ID) *ElementArray
ElementArrayFromID adopts an existing Objective-C object as a ElementArray (nil for 0), retaining it and registering a release finalizer.
func NewElementArray ¶
func NewElementArray() *ElementArray
NewElementArray creates a new ElementArray.
func (*ElementArray) Description ¶ added in v0.10.0
func (ea *ElementArray) Description() string
Description returns the object's -description text.
func (*ElementArray) Get ¶
func (ea *ElementArray) Get() []obj.Object
Get returns forces evaluation of the receiver, causing the real object to be returned immediately.
func (*ElementArray) IsEqual ¶ added in v0.10.0
func (ea *ElementArray) IsEqual(other obj.Object) bool
IsEqual reports Objective-C equality (isEqual:) with another object.
func (*ElementArray) IsKind ¶ added in v0.10.0
func (ea *ElementArray) IsKind(className string) bool
IsKind reports whether the object is an instance of the named class or a subclass.
func (*ElementArray) ObjectAtLocation ¶
func (ea *ElementArray) ObjectAtLocation(location obj.Object) obj.Object
ObjectAtLocation returns the object at the given location in the receiver.
func (*ElementArray) ObjectWithID ¶
func (ea *ElementArray) ObjectWithID(identifier obj.Object) obj.Object
ObjectWithID returns the object in the array with the given identifier.
func (*ElementArray) ObjectWithName ¶
func (ea *ElementArray) ObjectWithName(name string) obj.Object
ObjectWithName returns the object in the array with the given name.
func (*ElementArray) String ¶ added in v0.10.0
func (ea *ElementArray) String() string
String returns the object's -description text, so a wrapper prints usefully under fmt.
type Object ¶
Object is an idiomatic wrapper over the Objective-C class SBObject.
Object is an abstract base — you do not construct it directly. Construct one of Application and pass it where a Object is accepted.
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.
func NewObjectWithData ¶
NewObjectWithData returns an instance of an SBObject subclass initialized with the given data.
func NewObjectWithElementCodePropertiesData ¶
func NewObjectWithElementCodePropertiesData(code int, properties obj.Object, data obj.Object) *Object
NewObjectWithElementCodePropertiesData returns an instance of an SBObject subclass initialized with the specified properties and data and added to the designated element array.
func NewObjectWithProperties ¶
NewObjectWithProperties returns an instance of an SBObject subclass initialized with the specified properties.
func ObjectFromID ¶
ObjectFromID adopts an existing Objective-C object as a Object (nil for 0), retaining it and registering a release finalizer.
func (*Object) Description ¶ added in v0.10.0
Description returns the object's -description text.
func (*Object) ElementArrayWithCode ¶
ElementArrayWithCode returns an array containing every child of the receiver with the given class-type code.
func (*Object) Get ¶
Get returns forces evaluation of the receiver, causing the real object to be returned immediately.
func (*Object) IsEqual ¶ added in v0.10.0
IsEqual reports Objective-C equality (isEqual:) with another object.
func (*Object) IsKind ¶ added in v0.10.0
IsKind reports whether the object is an instance of the named class or a subclass.
func (*Object) PropertyWithCode ¶
PropertyWithCode returns an object representing the specified property of the receiver.
type ObjectProvider ¶
ObjectProvider is accepted wherever a SBObject (or one of its subclasses) is expected.