@bun-win32/uia 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AI.md +130 -0
- package/README.md +79 -0
- package/agent.ts +83 -0
- package/automation.ts +51 -0
- package/cache.ts +67 -0
- package/com.ts +62 -0
- package/condition.ts +132 -0
- package/constants.ts +233 -0
- package/element.ts +512 -0
- package/index.ts +40 -0
- package/input.ts +149 -0
- package/msaa.ts +99 -0
- package/package.json +86 -0
- package/patterns.ts +234 -0
- package/png.ts +75 -0
- package/reads.ts +66 -0
- package/tree.ts +95 -0
- package/window.ts +107 -0
package/constants.ts
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
// Verified UI Automation identifiers and COM vtable slots.
|
|
2
|
+
//
|
|
3
|
+
// IDs are extracted from the Windows SDK header UIAutomationClient.h (10.0.22000.0):
|
|
4
|
+
// pattern ids 10000+, property ids 30000+, control-type ids 50000+.
|
|
5
|
+
// Vtable SLOTs are header declaration order (IUnknown 0-2, then STDMETHOD order) AND
|
|
6
|
+
// runtime-verified on live elements — a wrong slot calls the wrong function pointer and
|
|
7
|
+
// segfaults. The classic miscount: ElementFromHandle is slot 6 (GetRootElement 5,
|
|
8
|
+
// ElementFromHandle 6, ElementFromPoint 7, GetFocusedElement 8, then the *BuildCache
|
|
9
|
+
// variants at 9-12), NOT slot 7. Proven via NativeWindowHandle round-trip.
|
|
10
|
+
|
|
11
|
+
export const S_OK = 0x0000_0000;
|
|
12
|
+
export const S_FALSE = 0x0000_0001;
|
|
13
|
+
/** An element pointer that has outlived its provider (apartment affinity / app closed). Tolerate it. */
|
|
14
|
+
export const UIA_E_ELEMENTNOTAVAILABLE = 0x8004_0201 | 0;
|
|
15
|
+
|
|
16
|
+
/** IUnknown::Release — vtable slot 2 on every COM interface. */
|
|
17
|
+
export const IUNKNOWN_RELEASE = 2;
|
|
18
|
+
|
|
19
|
+
/** CoCreateInstance class context: in-process server. */
|
|
20
|
+
export const CLSCTX_INPROC_SERVER = 0x0000_0001;
|
|
21
|
+
/** CoInitializeEx: single-threaded (STA) apartment — matches the proven out-of-process driver model. */
|
|
22
|
+
export const COINIT_APARTMENTTHREADED = 0x0000_0002;
|
|
23
|
+
|
|
24
|
+
export const CLSID_CUIAutomation = '{FF48DBA4-60EF-4201-AA87-54103EEF594E}';
|
|
25
|
+
export const IID_IUIAutomation = '{30CBE57D-D9D0-452A-AB13-7AC5AC4825EE}';
|
|
26
|
+
|
|
27
|
+
/** VARIANT discriminants used to build property conditions (value at byte offset 8). */
|
|
28
|
+
export const VT_I4 = 0x0003;
|
|
29
|
+
export const VT_R8 = 0x0005;
|
|
30
|
+
export const VT_BSTR = 0x0008;
|
|
31
|
+
export const VT_DISPATCH = 0x0009;
|
|
32
|
+
export const VT_BOOL = 0x000b;
|
|
33
|
+
|
|
34
|
+
export enum TreeScope {
|
|
35
|
+
TreeScope_None = 0x0000_0000,
|
|
36
|
+
TreeScope_Element = 0x0000_0001,
|
|
37
|
+
TreeScope_Children = 0x0000_0002,
|
|
38
|
+
TreeScope_Descendants = 0x0000_0004,
|
|
39
|
+
TreeScope_Parent = 0x0000_0008,
|
|
40
|
+
TreeScope_Ancestors = 0x0000_0010,
|
|
41
|
+
TreeScope_Subtree = 0x0000_0007,
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export enum PropertyConditionFlags {
|
|
45
|
+
PropertyConditionFlags_None = 0x0000_0000,
|
|
46
|
+
PropertyConditionFlags_IgnoreCase = 0x0000_0001,
|
|
47
|
+
PropertyConditionFlags_MatchSubstring = 0x0000_0002,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Control-type ids (UIA_*ControlTypeId). Numeric enum → reverse map (`ControlType[50000] === 'Button'`). */
|
|
51
|
+
export enum ControlType {
|
|
52
|
+
Button = 50000,
|
|
53
|
+
Calendar = 50001,
|
|
54
|
+
CheckBox = 50002,
|
|
55
|
+
ComboBox = 50003,
|
|
56
|
+
Edit = 50004,
|
|
57
|
+
Hyperlink = 50005,
|
|
58
|
+
Image = 50006,
|
|
59
|
+
ListItem = 50007,
|
|
60
|
+
List = 50008,
|
|
61
|
+
Menu = 50009,
|
|
62
|
+
MenuBar = 50010,
|
|
63
|
+
MenuItem = 50011,
|
|
64
|
+
ProgressBar = 50012,
|
|
65
|
+
RadioButton = 50013,
|
|
66
|
+
ScrollBar = 50014,
|
|
67
|
+
Slider = 50015,
|
|
68
|
+
Spinner = 50016,
|
|
69
|
+
StatusBar = 50017,
|
|
70
|
+
Tab = 50018,
|
|
71
|
+
TabItem = 50019,
|
|
72
|
+
Text = 50020,
|
|
73
|
+
ToolBar = 50021,
|
|
74
|
+
ToolTip = 50022,
|
|
75
|
+
Tree = 50023,
|
|
76
|
+
TreeItem = 50024,
|
|
77
|
+
Custom = 50025,
|
|
78
|
+
Group = 50026,
|
|
79
|
+
Thumb = 50027,
|
|
80
|
+
DataGrid = 50028,
|
|
81
|
+
DataItem = 50029,
|
|
82
|
+
Document = 50030,
|
|
83
|
+
SplitButton = 50031,
|
|
84
|
+
Window = 50032,
|
|
85
|
+
Pane = 50033,
|
|
86
|
+
Header = 50034,
|
|
87
|
+
HeaderItem = 50035,
|
|
88
|
+
Table = 50036,
|
|
89
|
+
TitleBar = 50037,
|
|
90
|
+
Separator = 50038,
|
|
91
|
+
SemanticZoom = 50039,
|
|
92
|
+
AppBar = 50040,
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Control-pattern ids (UIA_*PatternId), consumed by GetCurrentPattern / property availability. */
|
|
96
|
+
export enum PatternId {
|
|
97
|
+
Invoke = 10000,
|
|
98
|
+
Selection = 10001,
|
|
99
|
+
Value = 10002,
|
|
100
|
+
RangeValue = 10003,
|
|
101
|
+
Scroll = 10004,
|
|
102
|
+
ExpandCollapse = 10005,
|
|
103
|
+
Grid = 10006,
|
|
104
|
+
GridItem = 10007,
|
|
105
|
+
MultipleView = 10008,
|
|
106
|
+
Window = 10009,
|
|
107
|
+
SelectionItem = 10010,
|
|
108
|
+
Dock = 10011,
|
|
109
|
+
Table = 10012,
|
|
110
|
+
TableItem = 10013,
|
|
111
|
+
Text = 10014,
|
|
112
|
+
Toggle = 10015,
|
|
113
|
+
Transform = 10016,
|
|
114
|
+
ScrollItem = 10017,
|
|
115
|
+
LegacyIAccessible = 10018,
|
|
116
|
+
ItemContainer = 10019,
|
|
117
|
+
VirtualizedItem = 10020,
|
|
118
|
+
SynchronizedInput = 10021,
|
|
119
|
+
ObjectModel = 10022,
|
|
120
|
+
Annotation = 10023,
|
|
121
|
+
Styles = 10025,
|
|
122
|
+
Spreadsheet = 10026,
|
|
123
|
+
SpreadsheetItem = 10027,
|
|
124
|
+
TextChild = 10029,
|
|
125
|
+
Drag = 10030,
|
|
126
|
+
DropTarget = 10031,
|
|
127
|
+
TextEdit = 10032,
|
|
128
|
+
CustomNavigation = 10033,
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Automation-element property ids (UIA_*PropertyId), used to build server-side conditions. */
|
|
132
|
+
export enum PropertyId {
|
|
133
|
+
RuntimeId = 30000,
|
|
134
|
+
BoundingRectangle = 30001,
|
|
135
|
+
ProcessId = 30002,
|
|
136
|
+
ControlType = 30003,
|
|
137
|
+
LocalizedControlType = 30004,
|
|
138
|
+
Name = 30005,
|
|
139
|
+
HasKeyboardFocus = 30008,
|
|
140
|
+
IsKeyboardFocusable = 30009,
|
|
141
|
+
IsEnabled = 30010,
|
|
142
|
+
AutomationId = 30011,
|
|
143
|
+
ClassName = 30012,
|
|
144
|
+
HelpText = 30013,
|
|
145
|
+
IsControlElement = 30016,
|
|
146
|
+
IsContentElement = 30017,
|
|
147
|
+
NativeWindowHandle = 30020,
|
|
148
|
+
IsOffscreen = 30022,
|
|
149
|
+
FrameworkId = 30024,
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* COM vtable slots, keyed by method name (names are unique across the interfaces the package
|
|
154
|
+
* binds, even where slot NUMBERS repeat across interfaces). Header declaration order, grouped
|
|
155
|
+
* by interface. Slots marked PROVEN were verified by running on a live element; the rest are
|
|
156
|
+
* header-derived and verified by running before first use in their phase.
|
|
157
|
+
*/
|
|
158
|
+
export const SLOT = {
|
|
159
|
+
// IUIAutomation
|
|
160
|
+
GetRootElement: 5, // PROVEN
|
|
161
|
+
ElementFromHandle: 6, // PROVEN (NativeWindowHandle round-trip; NOT slot 7 = ElementFromPoint)
|
|
162
|
+
ElementFromPoint: 7,
|
|
163
|
+
GetFocusedElement: 8,
|
|
164
|
+
CreateCacheRequest: 20,
|
|
165
|
+
CreateTrueCondition: 21, // PROVEN
|
|
166
|
+
CreateFalseCondition: 22,
|
|
167
|
+
CreatePropertyCondition: 23, // PROVEN (VARIANT-by-pointer; server-side filtering works)
|
|
168
|
+
CreatePropertyConditionEx: 24,
|
|
169
|
+
CreateAndCondition: 25, // PROVEN
|
|
170
|
+
CreateOrCondition: 28,
|
|
171
|
+
CreateNotCondition: 31,
|
|
172
|
+
get_ControlViewWalker: 14,
|
|
173
|
+
// IUIAutomationElement
|
|
174
|
+
SetFocus: 3,
|
|
175
|
+
GetRuntimeId: 4,
|
|
176
|
+
FindFirst: 5, // PROVEN
|
|
177
|
+
FindAll: 6, // PROVEN
|
|
178
|
+
FindFirstBuildCache: 7,
|
|
179
|
+
FindAllBuildCache: 8,
|
|
180
|
+
BuildUpdatedCache: 9,
|
|
181
|
+
GetCachedParent: 18,
|
|
182
|
+
GetCachedChildren: 19,
|
|
183
|
+
GetCurrentPattern: 16, // PROVEN
|
|
184
|
+
get_CurrentControlType: 21, // PROVEN
|
|
185
|
+
get_CurrentName: 23, // PROVEN
|
|
186
|
+
get_CurrentIsEnabled: 28, // PROVEN
|
|
187
|
+
get_CurrentAutomationId: 29, // PROVEN
|
|
188
|
+
get_CurrentClassName: 30, // PROVEN
|
|
189
|
+
get_CurrentNativeWindowHandle: 36, // PROVEN
|
|
190
|
+
get_CurrentBoundingRectangle: 43, // PROVEN (RECT = 4x LONG, 16 bytes; matches GetWindowRect)
|
|
191
|
+
get_CachedControlType: 53,
|
|
192
|
+
get_CachedName: 55,
|
|
193
|
+
get_CachedIsEnabled: 60,
|
|
194
|
+
get_CachedAutomationId: 61,
|
|
195
|
+
get_CachedClassName: 62,
|
|
196
|
+
get_CachedBoundingRectangle: 75,
|
|
197
|
+
// IUIAutomationCacheRequest
|
|
198
|
+
AddProperty: 3,
|
|
199
|
+
AddPattern: 4,
|
|
200
|
+
put_TreeScope: 7,
|
|
201
|
+
put_TreeFilter: 9,
|
|
202
|
+
put_AutomationElementMode: 11,
|
|
203
|
+
// IUIAutomationElementArray
|
|
204
|
+
get_Length: 3, // PROVEN
|
|
205
|
+
GetElement: 4, // PROVEN
|
|
206
|
+
// IUIAutomationTreeWalker
|
|
207
|
+
GetParentElement: 3,
|
|
208
|
+
// IUIAutomationInvokePattern
|
|
209
|
+
Invoke: 3, // PROVEN (Calculator 5+3=8)
|
|
210
|
+
// IUIAutomationValuePattern + IUIAutomationRangeValuePattern (SetValue/get_CurrentValue share slot numbers)
|
|
211
|
+
SetValue: 3,
|
|
212
|
+
get_CurrentValue: 4,
|
|
213
|
+
// IUIAutomationTogglePattern
|
|
214
|
+
Toggle: 3,
|
|
215
|
+
get_CurrentToggleState: 4,
|
|
216
|
+
// IUIAutomationExpandCollapsePattern
|
|
217
|
+
Expand: 3,
|
|
218
|
+
Collapse: 4,
|
|
219
|
+
get_CurrentExpandCollapseState: 5,
|
|
220
|
+
// IUIAutomationSelectionItemPattern
|
|
221
|
+
Select: 3,
|
|
222
|
+
get_CurrentIsSelected: 6,
|
|
223
|
+
// IUIAutomationScrollItemPattern
|
|
224
|
+
ScrollIntoView: 3,
|
|
225
|
+
// IUIAutomationWindowPattern
|
|
226
|
+
Close: 3,
|
|
227
|
+
WaitForInputIdle: 4,
|
|
228
|
+
SetWindowVisualState: 5,
|
|
229
|
+
get_CurrentWindowVisualState: 10,
|
|
230
|
+
// IUIAutomationTextPattern + IUIAutomationTextRange
|
|
231
|
+
get_DocumentRange: 7,
|
|
232
|
+
GetText: 12,
|
|
233
|
+
} as const;
|