accessibility

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAccessibilityPermissions

func CheckAccessibilityPermissions() bool

CheckAccessibilityPermissions checks if the app has accessibility permissions

func GetClickableRoles

func GetClickableRoles() []string

GetClickableRoles returns the configured clickable roles.

func GetScrollableRoles

func GetScrollableRoles() []string

GetScrollableRoles returns the configured scrollable roles.

func IsMissionControlActive added in v1.7.0

func IsMissionControlActive() bool

Check if is mission control is active Hopefully works on all OS versions Works on Tohoe 26.1 as of now

func PrintTree

func PrintTree(node *TreeNode, depth int)

NOTE: This is a debugging function that prints the entire accessibility tree structure. Print the entire tree structure for debugging

func ReleaseAll added in v1.6.0

func ReleaseAll(elements []*Element)

ReleaseAll releases all elements in a slice

func ScrollAtCursor added in v1.7.0

func ScrollAtCursor(deltaX, deltaY int) error

func SetClickableRoles

func SetClickableRoles(roles []string)

SetClickableRoles configures which accessibility roles are treated as clickable.

func SetScrollableRoles

func SetScrollableRoles(roles []string)

SetScrollableRoles configures which accessibility roles are treated as scrollable.

Types

type CachedInfo added in v1.5.0

type CachedInfo struct {
	Info      *ElementInfo
	ExpiresAt time.Time
}

CachedInfo wraps ElementInfo with expiration time

type Element

type Element struct {
	// contains filtered or unexported fields
}

Element represents an accessibility UI element

func GetAllWindows

func GetAllWindows() ([]*Element, error)

GetAllWindows returns all windows of the focused application

func GetApplicationByBundleID

func GetApplicationByBundleID(bundleID string) *Element

GetApplicationByBundleID returns an application element by bundle identifier

func GetApplicationByPID

func GetApplicationByPID(pid int) *Element

GetApplicationByPID returns an application element by its process ID

func GetElementAtPosition

func GetElementAtPosition(x, y int) *Element

GetElementAtPosition returns the element at the specified screen position

func GetFocusedApplication

func GetFocusedApplication() *Element

GetFocusedApplication returns the currently focused application

func GetFrontmostWindow

func GetFrontmostWindow() *Element

GetFrontmostWindow returns the frontmost window

func GetSystemWideElement

func GetSystemWideElement() *Element

GetSystemWideElement returns the system-wide accessibility element

func (*Element) DoubleClick

func (e *Element) DoubleClick(restoreCursor bool) error

DoubleClick performs a double-click action on the element

func (*Element) GetApplicationName

func (e *Element) GetApplicationName() string

GetApplicationName returns the application name

func (*Element) GetAttribute

func (e *Element) GetAttribute(name string) (string, error)

GetAttribute gets a custom attribute value

func (*Element) GetBundleIdentifier

func (e *Element) GetBundleIdentifier() string

GetBundleIdentifier returns the bundle identifier

func (*Element) GetChildren

func (e *Element) GetChildren() ([]*Element, error)

GetChildren returns all child elements with optional occlusion checking

func (*Element) GetInfo

func (e *Element) GetInfo() (*ElementInfo, error)

GetInfo returns information about the element

func (*Element) GetMenuBar

func (e *Element) GetMenuBar() *Element

GetMenuBar returns the menu bar element for the given application element

func (*Element) GetScrollBounds

func (e *Element) GetScrollBounds() image.Rectangle

GetScrollBounds returns the scroll area bounds

func (*Element) GoToPosition

func (e *Element) GoToPosition() error

GoToPosition performs a move mouse action to the element

func (*Element) IsClickable

func (e *Element) IsClickable() bool

IsClickable checks if the element is clickable

func (*Element) IsScrollable

func (e *Element) IsScrollable() bool

IsClickable checks if the element is clickable

func (*Element) LeftClick

func (e *Element) LeftClick(restoreCursor bool) error

LeftClick performs a click action on the element

func (*Element) LeftMouseDown added in v1.7.0

func (e *Element) LeftMouseDown() error

LeftMouseDown performs a left-mouse-down action on the element

func (*Element) LeftMouseUp added in v1.7.0

func (e *Element) LeftMouseUp(isExit bool) error

LeftMouseUp performs a left-mouse-up action on the element

func (*Element) MiddleClick

func (e *Element) MiddleClick(restoreCursor bool) error

MiddleClick performs a middle-click action on the element

func (*Element) Release

func (e *Element) Release()

Release releases the element reference

func (*Element) RightClick

func (e *Element) RightClick(restoreCursor bool) error

RightClick performs a right-click action on the element

func (*Element) SetFocus

func (e *Element) SetFocus() error

SetFocus sets focus to the element

func (*Element) TripleClick added in v1.7.0

func (e *Element) TripleClick(restoreCursor bool) error

TripleClick performs a triple-click action on the element

type ElementInfo

type ElementInfo struct {
	Position        image.Point
	Size            image.Point
	Title           string
	Role            string
	RoleDescription string
	IsEnabled       bool
	IsFocused       bool
	PID             int
}

ElementInfo contains information about a UI element

type InfoCache added in v1.5.0

type InfoCache struct {
	// contains filtered or unexported fields
}

InfoCache is a thread-safe cache with TTL

func NewInfoCache added in v1.5.0

func NewInfoCache(ttl time.Duration) *InfoCache

NewInfoCache creates a cache with the given TTL

func (*InfoCache) Clear added in v1.5.0

func (c *InfoCache) Clear()

Clear removes all entries

func (*InfoCache) Get added in v1.5.0

func (c *InfoCache) Get(elem *Element) *ElementInfo

Get retrieves a cached value if it exists and hasn't expired

func (*InfoCache) Set added in v1.5.0

func (c *InfoCache) Set(elem *Element, info *ElementInfo)

Set stores a value with TTL

func (*InfoCache) Size added in v1.5.0

func (c *InfoCache) Size() int

Size returns the number of cached entries

func (*InfoCache) Stop added in v1.5.0

func (c *InfoCache) Stop()

Stop stops the cleanup goroutine

type TreeNode

type TreeNode struct {
	Element  *Element
	Info     *ElementInfo
	Children []*TreeNode
	Parent   *TreeNode
}

TreeNode represents a node in the accessibility tree

func BuildTree

func BuildTree(root *Element, opts TreeOptions) (*TreeNode, error)

BuildTree builds an accessibility tree from the given root element

func GetClickableElements

func GetClickableElements() ([]*TreeNode, error)

GetClickableElements returns all clickable elements in the frontmost window

func GetClickableElementsFromBundleID added in v1.5.0

func GetClickableElementsFromBundleID(bundleID string) ([]*TreeNode, error)

func GetMenuBarClickableElements

func GetMenuBarClickableElements() ([]*TreeNode, error)

GetMenuBarClickableElements returns clickable elements from the focused app's menu bar

func GetScrollableElements

func GetScrollableElements() ([]*TreeNode, error)

GetScrollableElements returns all scrollable elements in the frontmost window

func (*TreeNode) FindClickableElements

func (n *TreeNode) FindClickableElements() []*TreeNode

FindClickableElements finds all clickable elements in the tree

func (*TreeNode) FindScrollableElements

func (n *TreeNode) FindScrollableElements() []*TreeNode

FindScrollableElements finds all scrollable elements in the tree

type TreeOptions

type TreeOptions struct {
	FilterFunc         func(*ElementInfo) bool
	IncludeOutOfBounds bool
	Cache              *InfoCache
	ParallelThreshold  int
	MaxParallelDepth   int
}

TreeOptions configures tree traversal

func DefaultTreeOptions

func DefaultTreeOptions() TreeOptions

DefaultTreeOptions returns default tree traversal options

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL