accessibility_sys/
ui_element.rs1#![allow(non_upper_case_globals, non_camel_case_types)]
2use std::ffi::{c_uchar, c_void};
3
4use core_foundation_sys::{
5 array::CFArrayRef,
6 base::{CFIndex, CFTypeID, CFTypeRef},
7 dictionary::CFDictionaryRef,
8 runloop::CFRunLoopSourceRef,
9 string::CFStringRef,
10};
11
12use crate::AXError;
13
14pub enum __AXUIElement {}
15pub type AXUIElementRef = *mut __AXUIElement;
16
17pub enum __AXObserver {}
18pub type AXObserverRef = *mut __AXObserver;
19
20pub type AXCopyMultipleAttributeOptions = u32;
21pub const kAXCopyMultipleAttributeOptionStopOnError: u32 = 0x1;
22
23pub type CGKeyCode = u16;
25pub type CGCharCode = u16;
26
27pub type pid_t = i32;
29
30#[link(name = "ApplicationServices", kind = "framework")]
31extern "C" {
32 pub fn AXAPIEnabled() -> bool;
33 pub fn AXIsProcessTrustedWithOptions(options: CFDictionaryRef) -> bool;
34 pub static kAXTrustedCheckOptionPrompt: CFStringRef;
35 pub fn AXIsProcessTrusted() -> bool;
36 pub fn AXMakeProcessTrusted(executablePath: CFStringRef) -> AXError;
37
38 pub fn AXUIElementGetTypeID() -> CFTypeID;
39 pub fn AXUIElementCopyAttributeNames(
40 element: AXUIElementRef,
41 names: *mut CFArrayRef,
42 ) -> AXError;
43 pub fn AXUIElementCopyAttributeValue(
44 element: AXUIElementRef,
45 attribute: CFStringRef,
46 value: *mut CFTypeRef,
47 ) -> AXError;
48 pub fn AXUIElementGetAttributeValueCount(
49 element: AXUIElementRef,
50 attribute: CFStringRef,
51 count: *mut CFIndex,
52 ) -> AXError;
53 pub fn AXUIElementCopyAttributeValues(
54 element: AXUIElementRef,
55 attribute: CFStringRef,
56 index: CFIndex,
57 maxValues: CFIndex,
58 values: *mut CFArrayRef,
59 ) -> AXError;
60 pub fn AXUIElementIsAttributeSettable(
61 element: AXUIElementRef,
62 attribute: CFStringRef,
63 settable: *mut c_uchar,
64 ) -> AXError;
65 pub fn AXUIElementSetAttributeValue(
66 element: AXUIElementRef,
67 attribute: CFStringRef,
68 value: CFTypeRef,
69 ) -> AXError;
70 pub fn AXUIElementCopyMultipleAttributeValues(
71 element: AXUIElementRef,
72 attributes: CFArrayRef,
73 options: AXCopyMultipleAttributeOptions,
74 values: *mut CFArrayRef,
75 ) -> AXError;
76 pub fn AXUIElementCopyParameterizedAttributeNames(
77 element: AXUIElementRef,
78 names: *mut CFArrayRef,
79 ) -> AXError;
80 pub fn AXUIElementCopyParameterizedAttributeValue(
81 element: AXUIElementRef,
82 parameterizedAttribute: CFStringRef,
83 parameter: CFTypeRef,
84 result: *mut CFTypeRef,
85 ) -> AXError;
86 pub fn AXUIElementCopyActionNames(element: AXUIElementRef, names: *mut CFArrayRef) -> AXError;
87 pub fn AXUIElementCopyActionDescription(
88 element: AXUIElementRef,
89 action: CFStringRef,
90 description: *mut CFStringRef,
91 ) -> AXError;
92 pub fn AXUIElementPerformAction(element: AXUIElementRef, action: CFStringRef) -> AXError;
93 pub fn AXUIElementCopyElementAtPosition(
94 application: AXUIElementRef,
95 x: f32,
96 y: f32,
97 element: *mut AXUIElementRef,
98 ) -> AXError;
99 pub fn AXUIElementCreateApplication(pid: pid_t) -> AXUIElementRef;
100 pub fn AXUIElementCreateSystemWide() -> AXUIElementRef;
101 pub fn AXUIElementGetPid(element: AXUIElementRef, pid: *mut pid_t) -> AXError;
102 pub fn AXUIElementSetMessagingTimeout(
103 element: AXUIElementRef,
104 timeoutInSeconds: f32,
105 ) -> AXError;
106 pub fn AXUIElementPostKeyboardEvent(
107 application: AXUIElementRef,
108 keyChar: CGCharCode,
109 virtualKey: CGKeyCode,
110 keyDown: bool,
111 ) -> AXError;
112 pub fn AXObserverGetTypeID() -> CFTypeID;
113 pub fn AXObserverCreate(
114 application: pid_t,
115 callback: AXObserverCallback,
116 outObserver: *mut AXObserverRef,
117 ) -> AXError;
118 pub fn AXObserverCreateWithInfoCallback(
119 application: pid_t,
120 callback: AXObserverCallbackWithInfo,
121 outObserver: *mut AXObserverRef,
122 ) -> AXError;
123 pub fn AXObserverAddNotification(
124 observer: AXObserverRef,
125 element: AXUIElementRef,
126 notification: CFStringRef,
127 refcon: *mut c_void,
128 ) -> AXError;
129 pub fn AXObserverRemoveNotification(
130 observer: AXObserverRef,
131 element: AXUIElementRef,
132 notification: CFStringRef,
133 ) -> AXError;
134 pub fn AXObserverGetRunLoopSource(observer: AXObserverRef) -> CFRunLoopSourceRef;
135}
136
137pub type AXObserverCallback = unsafe extern "C" fn(
138 observer: AXObserverRef,
139 element: AXUIElementRef,
140 notification: CFStringRef,
141 refcon: *mut c_void,
142);
143pub type AXObserverCallbackWithInfo = unsafe extern "C" fn(
144 observer: AXObserverRef,
145 element: AXUIElementRef,
146 notification: CFStringRef,
147 info: CFDictionaryRef,
148 refcon: *mut c_void,
149);