appium-novawindows2-driver 0.2.2 → 0.2.4
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/LICENSE +201 -201
- package/README.md +554 -554
- package/build/lib/commands/app.d.ts.map +1 -1
- package/build/lib/commands/app.js +35 -31
- package/build/lib/commands/app.js.map +1 -1
- package/build/lib/commands/extension.d.ts +1 -1
- package/build/lib/commands/extension.d.ts.map +1 -1
- package/build/lib/commands/extension.js +26 -26
- package/build/lib/commands/extension.js.map +1 -1
- package/build/lib/commands/file.js +22 -22
- package/build/lib/commands/functions.js +189 -189
- package/build/lib/commands/index.d.ts +1 -1
- package/build/lib/commands/index.d.ts.map +1 -1
- package/build/lib/commands/powershell.d.ts.map +1 -1
- package/build/lib/commands/powershell.js +164 -197
- package/build/lib/commands/powershell.js.map +1 -1
- package/build/lib/driver.d.ts +0 -1
- package/build/lib/driver.d.ts.map +1 -1
- package/build/lib/driver.js +7 -3
- package/build/lib/driver.js.map +1 -1
- package/build/lib/powershell/elements.js +738 -738
- package/build/lib/powershell/msaa.d.ts +10 -0
- package/build/lib/powershell/msaa.d.ts.map +1 -0
- package/build/lib/powershell/msaa.js +188 -0
- package/build/lib/powershell/msaa.js.map +1 -0
- package/build/lib/temp/MSAAHelper.dll +0 -0
- package/build/lib/winapi/uia.d.ts +163 -0
- package/build/lib/winapi/uia.d.ts.map +1 -0
- package/build/lib/winapi/uia.js +677 -0
- package/build/lib/winapi/uia.js.map +1 -0
- package/build/lib/xpath/native.d.ts +14 -0
- package/build/lib/xpath/native.d.ts.map +1 -0
- package/build/lib/xpath/native.js +329 -0
- package/build/lib/xpath/native.js.map +1 -0
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +64 -63
|
@@ -0,0 +1,677 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UIA_IsGridPatternAvailablePropertyId = exports.UIA_ItemTypePropertyId = exports.UIA_IsPasswordPropertyId = exports.UIA_IsControlElementPropertyId = exports.UIA_IsContentElementPropertyId = exports.UIA_FrameworkIdPropertyId = exports.UIA_OrientationPropertyId = exports.UIA_IsOffscreenPropertyId = exports.UIA_NativeWindowHandlePropertyId = exports.UIA_CulturePropertyId = exports.UIA_ClickablePointPropertyId = exports.UIA_HelpTextPropertyId = exports.UIA_ClassNamePropertyId = exports.UIA_AutomationIdPropertyId = exports.UIA_IsEnabledPropertyId = exports.UIA_IsKeyboardFocusablePropertyId = exports.UIA_HasKeyboardFocusPropertyId = exports.UIA_AccessKeyPropertyId = exports.UIA_AcceleratorKeyPropertyId = exports.UIA_NamePropertyId = exports.UIA_LocalizedControlTypePropertyId = exports.UIA_ControlTypePropertyId = exports.UIA_ProcessIdPropertyId = exports.UIA_BoundingRectanglePropertyId = exports.UIA_RuntimeIdPropertyId = exports.IUIAutomationVtbl = exports.IUIAutomationElementVtbl = exports.get_CurrentBoundingRectangleProto = exports.GetCurrentPropertyValueProto = exports.CreateTrueConditionProto = exports.CreatePropertyConditionProto = exports.GetElementProto = exports.get_LengthProto = exports.FindAllProto = exports.FindFirstProto = exports.GetRootElementProto = exports.VT_BOOL = exports.VT_BSTR = exports.VT_I4 = exports.VARIANT = exports.IID_IUIAutomationElement = exports.IID_IUIAutomation = exports.CLSID_CUIAutomation = exports.GUID = exports.SysFreeString = exports.SysAllocString = exports.RECT = exports.PVOID = exports.VOID = exports.HRESULT = void 0;
|
|
4
|
+
exports.UIAClient = exports.SysStringLen = exports.VariantClear = exports.CoCreateInstance = exports.CoInitializeEx = exports.TreeScope = exports.CLSCTX_INPROC_SERVER = exports.COINIT_APARTMENTTHREADED = exports.COINIT_MULTITHREADED = exports.UIA_AppBarControlTypeId = exports.UIA_SemanticZoomControlTypeId = exports.UIA_SeparatorControlTypeId = exports.UIA_TitleBarControlTypeId = exports.UIA_TableControlTypeId = exports.UIA_HeaderItemControlTypeId = exports.UIA_HeaderControlTypeId = exports.UIA_PaneControlTypeId = exports.UIA_WindowControlTypeId = exports.UIA_SplitButtonControlTypeId = exports.UIA_DocumentControlTypeId = exports.UIA_DataItemControlTypeId = exports.UIA_DataGridControlTypeId = exports.UIA_ThumbControlTypeId = exports.UIA_GroupControlTypeId = exports.UIA_CustomControlTypeId = exports.UIA_TreeItemControlTypeId = exports.UIA_TreeControlTypeId = exports.UIA_ToolTipControlTypeId = exports.UIA_ToolBarControlTypeId = exports.UIA_TextControlTypeId = exports.UIA_TabItemControlTypeId = exports.UIA_TabControlTypeId = exports.UIA_StatusBarControlTypeId = exports.UIA_SpinnerControlTypeId = exports.UIA_SliderControlTypeId = exports.UIA_ScrollBarControlTypeId = exports.UIA_RadioButtonControlTypeId = exports.UIA_ProgressBarControlTypeId = exports.UIA_MenuItemControlTypeId = exports.UIA_MenuBarControlTypeId = exports.UIA_MenuControlTypeId = exports.UIA_ListControlTypeId = exports.UIA_ListItemControlTypeId = exports.UIA_ImageControlTypeId = exports.UIA_HyperlinkControlTypeId = exports.UIA_EditControlTypeId = exports.UIA_ComboBoxControlTypeId = exports.UIA_CheckBoxControlTypeId = exports.UIA_CalendarControlTypeId = exports.UIA_ButtonControlTypeId = void 0;
|
|
5
|
+
exports.UIAElementArray = exports.UIAElement = exports.IUIAutomationElementArrayVtbl = void 0;
|
|
6
|
+
const koffi_1 = require("koffi");
|
|
7
|
+
const ole32 = (0, koffi_1.load)('ole32.dll');
|
|
8
|
+
const oleaut32 = (0, koffi_1.load)('oleaut32.dll');
|
|
9
|
+
// Basic Types
|
|
10
|
+
exports.HRESULT = (0, koffi_1.alias)('HRESULT', 'long');
|
|
11
|
+
exports.VOID = (0, koffi_1.opaque)();
|
|
12
|
+
exports.PVOID = (0, koffi_1.pointer)('PVOID', exports.VOID);
|
|
13
|
+
// RECT
|
|
14
|
+
exports.RECT = (0, koffi_1.struct)('RECT', {
|
|
15
|
+
left: 'long',
|
|
16
|
+
top: 'long',
|
|
17
|
+
right: 'long',
|
|
18
|
+
bottom: 'long',
|
|
19
|
+
});
|
|
20
|
+
// BSTR
|
|
21
|
+
exports.SysAllocString = oleaut32.func('void * __stdcall SysAllocString(str16 psz)');
|
|
22
|
+
exports.SysFreeString = oleaut32.func('void __stdcall SysFreeString(void * bstr)');
|
|
23
|
+
// GUID
|
|
24
|
+
exports.GUID = (0, koffi_1.struct)('GUID', {
|
|
25
|
+
Data1: 'uint32',
|
|
26
|
+
Data2: 'uint16',
|
|
27
|
+
Data3: 'uint16',
|
|
28
|
+
Data4: 'uint8[8]',
|
|
29
|
+
});
|
|
30
|
+
// CLSID & IID
|
|
31
|
+
exports.CLSID_CUIAutomation = {
|
|
32
|
+
Data1: 0xff48dba4,
|
|
33
|
+
Data2: 0x60ef,
|
|
34
|
+
Data3: 0x4201,
|
|
35
|
+
Data4: [0xaa, 0x87, 0x54, 0x10, 0x3e, 0xef, 0x59, 0x4e]
|
|
36
|
+
};
|
|
37
|
+
exports.IID_IUIAutomation = {
|
|
38
|
+
Data1: 0x30cbe57d,
|
|
39
|
+
Data2: 0xd9d0,
|
|
40
|
+
Data3: 0x452a,
|
|
41
|
+
Data4: [0xab, 0x13, 0x7a, 0xc5, 0xac, 0x48, 0x25, 0xee]
|
|
42
|
+
};
|
|
43
|
+
exports.IID_IUIAutomationElement = {
|
|
44
|
+
Data1: 0xd22108aa,
|
|
45
|
+
Data2: 0x8ac5,
|
|
46
|
+
Data3: 0x49a5,
|
|
47
|
+
Data4: [0x83, 0x7b, 0x37, 0xbb, 0xb3, 0xd7, 0x59, 0x1e]
|
|
48
|
+
};
|
|
49
|
+
// Basic VARIANT structure for pass-by-value compatibility
|
|
50
|
+
exports.VARIANT = (0, koffi_1.struct)('VARIANT', {
|
|
51
|
+
vt: 'uint16',
|
|
52
|
+
wReserved1: 'uint16',
|
|
53
|
+
wReserved2: 'uint16',
|
|
54
|
+
wReserved3: 'uint16',
|
|
55
|
+
llVal: 'int64',
|
|
56
|
+
pad: 'int64'
|
|
57
|
+
});
|
|
58
|
+
exports.VT_I4 = 3;
|
|
59
|
+
exports.VT_BSTR = 8;
|
|
60
|
+
exports.VT_BOOL = 11;
|
|
61
|
+
// Interfaces callbacks
|
|
62
|
+
const QueryInterfaceCallback = (0, koffi_1.proto)('HRESULT __stdcall (void *this, GUID *riid, void **ppvObject)');
|
|
63
|
+
const AddRefCallback = (0, koffi_1.proto)('uint32 __stdcall (void *this)');
|
|
64
|
+
const ReleaseCallback = (0, koffi_1.proto)('uint32 __stdcall (void *this)');
|
|
65
|
+
const IUnknownVtbl = (0, koffi_1.struct)('IUnknownVtbl', {
|
|
66
|
+
QueryInterface: (0, koffi_1.pointer)(QueryInterfaceCallback),
|
|
67
|
+
AddRef: (0, koffi_1.pointer)(AddRefCallback),
|
|
68
|
+
Release: (0, koffi_1.pointer)(ReleaseCallback),
|
|
69
|
+
});
|
|
70
|
+
// Helper for VTable methods
|
|
71
|
+
const method = (sig) => (0, koffi_1.pointer)((0, koffi_1.proto)(sig));
|
|
72
|
+
// Define Prototypes explicitly for usage in decoding
|
|
73
|
+
exports.GetRootElementProto = (0, koffi_1.proto)('HRESULT __stdcall (void *this, void **root)');
|
|
74
|
+
exports.FindFirstProto = (0, koffi_1.proto)('HRESULT __stdcall (void *this, int scope, void *condition, void **found)');
|
|
75
|
+
exports.FindAllProto = (0, koffi_1.proto)('HRESULT __stdcall (void *this, int scope, void *condition, void **found)');
|
|
76
|
+
exports.get_LengthProto = (0, koffi_1.proto)('HRESULT __stdcall (void *this, int *length)');
|
|
77
|
+
exports.GetElementProto = (0, koffi_1.proto)('HRESULT __stdcall (void *this, int index, void **element)');
|
|
78
|
+
exports.CreatePropertyConditionProto = (0, koffi_1.proto)('HRESULT __stdcall (void *this, int propertyId, VARIANT value, void **newCondition)');
|
|
79
|
+
exports.CreateTrueConditionProto = (0, koffi_1.proto)('HRESULT __stdcall (void *this, void **newCondition)');
|
|
80
|
+
exports.GetCurrentPropertyValueProto = (0, koffi_1.proto)('HRESULT __stdcall (void *this, int propertyId, VARIANT *retVal)');
|
|
81
|
+
exports.get_CurrentBoundingRectangleProto = (0, koffi_1.proto)('HRESULT __stdcall (void *this, RECT *retVal)');
|
|
82
|
+
// IUIAutomationElement Interface
|
|
83
|
+
exports.IUIAutomationElementVtbl = (0, koffi_1.struct)('IUIAutomationElementVtbl', {
|
|
84
|
+
// IUnknown
|
|
85
|
+
QueryInterface: (0, koffi_1.pointer)(QueryInterfaceCallback), // 0
|
|
86
|
+
AddRef: (0, koffi_1.pointer)(AddRefCallback), // 1
|
|
87
|
+
Release: (0, koffi_1.pointer)(ReleaseCallback), // 2
|
|
88
|
+
// IUIAutomationElement
|
|
89
|
+
SetFocus: method('HRESULT __stdcall (void *this)'), // 3
|
|
90
|
+
GetRuntimeId: method('HRESULT __stdcall (void *this, void **runtimeId)'), // 4
|
|
91
|
+
FindFirst: (0, koffi_1.pointer)(exports.FindFirstProto), // 5
|
|
92
|
+
FindAll: (0, koffi_1.pointer)(exports.FindAllProto), // 6
|
|
93
|
+
FindFirstBuildCache: method('HRESULT __stdcall (void *this, int scope, void *condition, void *cacheRequest, void **found)'), // 7
|
|
94
|
+
FindAllBuildCache: method('HRESULT __stdcall (void *this, int scope, void *condition, void *cacheRequest, void **found)'), // 8
|
|
95
|
+
BuildUpdatedCache: method('HRESULT __stdcall (void *this, void *cacheRequest, void **updatedElement)'), // 9
|
|
96
|
+
GetCurrentPropertyValue: (0, koffi_1.pointer)(exports.GetCurrentPropertyValueProto), // 10
|
|
97
|
+
GetCurrentPropertyValueEx: method('HRESULT __stdcall (void *this, int propertyId, int ignoreDefaultValue, VARIANT *retVal)'), // 11
|
|
98
|
+
// Padding/Placeholders for 12-40
|
|
99
|
+
GetCachedPropertyValue: method('HRESULT __stdcall (void *this, int propertyId, VARIANT *retVal)'), // 12
|
|
100
|
+
GetCachedPropertyValueEx: method('HRESULT __stdcall (void *this, int propertyId, int ignoreDefaultValue, VARIANT *retVal)'), // 13
|
|
101
|
+
GetCurrentPatternAs: method('HRESULT __stdcall (void *this, int patternId, GUID *riid, void **patternObject)'), // 14
|
|
102
|
+
GetCachedPatternAs: method('HRESULT __stdcall (void *this, int patternId, GUID *riid, void **patternObject)'), // 15
|
|
103
|
+
GetCurrentPattern: method('HRESULT __stdcall (void *this, int patternId, void **patternObject)'), // 16
|
|
104
|
+
GetCachedPattern: method('HRESULT __stdcall (void *this, int patternId, void **patternObject)'), // 17
|
|
105
|
+
Placeholder18: method('HRESULT __stdcall (void *this, void *p1, void *p2)'), // 18
|
|
106
|
+
Placeholder19: method('HRESULT __stdcall (void *this, void *p1)'), // 19
|
|
107
|
+
get_CurrentProcessId: method('HRESULT __stdcall (void *this, int *retVal)'), // 20
|
|
108
|
+
get_CurrentControlType: method('HRESULT __stdcall (void *this, int *retVal)'), // 21
|
|
109
|
+
get_CurrentLocalizedControlType: method('HRESULT __stdcall (void *this, void **retVal)'), // 22
|
|
110
|
+
get_CurrentName: method('HRESULT __stdcall (void *this, void **retVal)'), // 23
|
|
111
|
+
get_CurrentAcceleratorKey: method('HRESULT __stdcall (void *this, void **retVal)'), // 24
|
|
112
|
+
get_CurrentAccessKey: method('HRESULT __stdcall (void *this, void **retVal)'), // 25
|
|
113
|
+
get_CurrentHasKeyboardFocus: method('HRESULT __stdcall (void *this, int *retVal)'), // 26
|
|
114
|
+
get_CurrentIsKeyboardFocusable: method('HRESULT __stdcall (void *this, int *retVal)'), // 27
|
|
115
|
+
get_CurrentIsEnabled: method('HRESULT __stdcall (void *this, int *retVal)'), // 28
|
|
116
|
+
get_CurrentAutomationId: method('HRESULT __stdcall (void *this, void **retVal)'), // 29
|
|
117
|
+
get_CurrentClassName: method('HRESULT __stdcall (void *this, void **retVal)'), // 30
|
|
118
|
+
get_CurrentHelpText: method('HRESULT __stdcall (void *this, void **retVal)'), // 31
|
|
119
|
+
get_CurrentCulture: method('HRESULT __stdcall (void *this, int *retVal)'), // 32
|
|
120
|
+
get_CurrentIsControlElement: method('HRESULT __stdcall (void *this, int *retVal)'), // 33
|
|
121
|
+
get_CurrentIsContentElement: method('HRESULT __stdcall (void *this, int *retVal)'), // 34
|
|
122
|
+
get_CurrentIsPassword: method('HRESULT __stdcall (void *this, int *retVal)'), // 35
|
|
123
|
+
get_CurrentNativeWindowHandle: method('HRESULT __stdcall (void *this, void **retVal)'), // 36
|
|
124
|
+
get_CurrentItemType: method('HRESULT __stdcall (void *this, void **retVal)'), // 37
|
|
125
|
+
get_CurrentIsOffscreen: method('HRESULT __stdcall (void *this, int *retVal)'), // 38
|
|
126
|
+
get_CurrentOrientation: method('HRESULT __stdcall (void *this, int *retVal)'), // 39
|
|
127
|
+
get_CurrentFrameworkId: method('HRESULT __stdcall (void *this, void **retVal)'), // 40
|
|
128
|
+
get_CurrentIsRequiredForForm: method('HRESULT __stdcall (void *this, int *retVal)'), // 41
|
|
129
|
+
get_CurrentItemStatus: method('HRESULT __stdcall (void *this, void **retVal)'), // 42
|
|
130
|
+
get_CurrentBoundingRectangle: (0, koffi_1.pointer)(exports.get_CurrentBoundingRectangleProto), // 43
|
|
131
|
+
});
|
|
132
|
+
// IUIAutomation Interface
|
|
133
|
+
exports.IUIAutomationVtbl = (0, koffi_1.struct)('IUIAutomationVtbl', {
|
|
134
|
+
// IUnknown
|
|
135
|
+
QueryInterface: (0, koffi_1.pointer)(QueryInterfaceCallback),
|
|
136
|
+
AddRef: (0, koffi_1.pointer)(AddRefCallback),
|
|
137
|
+
Release: (0, koffi_1.pointer)(ReleaseCallback),
|
|
138
|
+
// IUIAutomation
|
|
139
|
+
CompareElements: method('HRESULT __stdcall (void *this, void *el1, void *el2, int *areSame)'), // 3
|
|
140
|
+
CompareRuntimeIds: method('HRESULT __stdcall (void *this, void *runId1, void *runId2, int *areSame)'), // 4
|
|
141
|
+
GetRootElement: (0, koffi_1.pointer)(exports.GetRootElementProto), // 5
|
|
142
|
+
GetRootElementBuildCache: method('HRESULT __stdcall (void *this, void *cacheRequest, void **root)'), // 6
|
|
143
|
+
ElementFromHandle: method('HRESULT __stdcall (void *this, void *hwnd, void **element)'), // 7
|
|
144
|
+
ElementFromPoint: method('HRESULT __stdcall (void *this, int64 pt, void **element)'), // 8
|
|
145
|
+
ElementFromIAccessible: method('HRESULT __stdcall (void *this, void *accessible, int childId, void **element)'), // 9
|
|
146
|
+
ElementFromIAccessibleBuildCache: method('HRESULT __stdcall (void *this, void *accessible, int childId, void *cacheRequest, void **element)'), // 10
|
|
147
|
+
GetFocusedElement: method('HRESULT __stdcall (void *this, void **element)'), // 11
|
|
148
|
+
GetFocusedElementBuildCache: method('HRESULT __stdcall (void *this, void *cacheRequest, void **element)'), // 12
|
|
149
|
+
GetRootElementEx: method('HRESULT __stdcall (void *this, int traversalOptions, void **root)'), // 13
|
|
150
|
+
CreateTreeWalker: method('HRESULT __stdcall (void *this, void *condition, void **walker)'), // 14
|
|
151
|
+
get_ControlViewWalker: method('HRESULT __stdcall (void *this, void **walker)'), // 15
|
|
152
|
+
get_ContentViewWalker: method('HRESULT __stdcall (void *this, void **walker)'), // 16
|
|
153
|
+
get_RawViewWalker: method('HRESULT __stdcall (void *this, void **walker)'), // 17
|
|
154
|
+
get_RawViewCondition: method('HRESULT __stdcall (void *this, void **condition)'), // 18
|
|
155
|
+
get_ControlViewCondition: method('HRESULT __stdcall (void *this, void **condition)'), // 19
|
|
156
|
+
get_ContentViewCondition: method('HRESULT __stdcall (void *this, void **condition)'), // 20
|
|
157
|
+
CreateCacheRequest: method('HRESULT __stdcall (void *this, void **cacheRequest)'), // 21
|
|
158
|
+
CreateTrueCondition: (0, koffi_1.pointer)(exports.CreateTrueConditionProto), // 22
|
|
159
|
+
CreateFalseCondition: method('HRESULT __stdcall (void *this, void **newCondition)'), // 23
|
|
160
|
+
CreatePropertyCondition: (0, koffi_1.pointer)(exports.CreatePropertyConditionProto), // 24
|
|
161
|
+
CreatePropertyConditionEx: method('HRESULT __stdcall (void *this, int propertyId, VARIANT value, int flags, void **newCondition)'), // 25
|
|
162
|
+
CreateAndCondition: method('HRESULT __stdcall (void *this, void *condition1, void *condition2, void **newCondition)'), // 26
|
|
163
|
+
CreateAndConditionFromArray: method('HRESULT __stdcall (void *this, void *conditions, void **newCondition)'), // 27
|
|
164
|
+
CreateAndConditionFromNativeArray: method('HRESULT __stdcall (void *this, void *conditions, int length, void **newCondition)'), // 28
|
|
165
|
+
CreateOrCondition: method('HRESULT __stdcall (void *this, void *condition1, void *condition2, void **newCondition)'), // 29
|
|
166
|
+
CreateOrConditionFromArray: method('HRESULT __stdcall (void *this, void *conditions, void **newCondition)'), // 30
|
|
167
|
+
CreateOrConditionFromNativeArray: method('HRESULT __stdcall (void *this, void *conditions, int length, void **newCondition)'), // 31
|
|
168
|
+
CreateNotCondition: method('HRESULT __stdcall (void *this, void *condition, void **newCondition)'), // 32
|
|
169
|
+
AddAutomationEventHandler: method('HRESULT __stdcall (void *this, int eventId, void *element, int scope, void *cacheRequest, void *handler)'), // 33
|
|
170
|
+
RemoveAutomationEventHandler: method('HRESULT __stdcall (void *this, int eventId, void *element, void *handler)'), // 34
|
|
171
|
+
});
|
|
172
|
+
// ... Property IDs ...
|
|
173
|
+
exports.UIA_RuntimeIdPropertyId = 30000;
|
|
174
|
+
exports.UIA_BoundingRectanglePropertyId = 30001;
|
|
175
|
+
exports.UIA_ProcessIdPropertyId = 30002;
|
|
176
|
+
exports.UIA_ControlTypePropertyId = 30003;
|
|
177
|
+
exports.UIA_LocalizedControlTypePropertyId = 30004;
|
|
178
|
+
exports.UIA_NamePropertyId = 30005;
|
|
179
|
+
exports.UIA_AcceleratorKeyPropertyId = 30006;
|
|
180
|
+
exports.UIA_AccessKeyPropertyId = 30007;
|
|
181
|
+
exports.UIA_HasKeyboardFocusPropertyId = 30008;
|
|
182
|
+
exports.UIA_IsKeyboardFocusablePropertyId = 30009;
|
|
183
|
+
exports.UIA_IsEnabledPropertyId = 30010;
|
|
184
|
+
exports.UIA_AutomationIdPropertyId = 30011;
|
|
185
|
+
exports.UIA_ClassNamePropertyId = 30012;
|
|
186
|
+
exports.UIA_HelpTextPropertyId = 30013;
|
|
187
|
+
exports.UIA_ClickablePointPropertyId = 30014;
|
|
188
|
+
exports.UIA_CulturePropertyId = 30015;
|
|
189
|
+
exports.UIA_NativeWindowHandlePropertyId = 30020;
|
|
190
|
+
exports.UIA_IsOffscreenPropertyId = 30022;
|
|
191
|
+
exports.UIA_OrientationPropertyId = 30023;
|
|
192
|
+
exports.UIA_FrameworkIdPropertyId = 30024;
|
|
193
|
+
exports.UIA_IsContentElementPropertyId = 30027;
|
|
194
|
+
exports.UIA_IsControlElementPropertyId = 30028;
|
|
195
|
+
exports.UIA_IsPasswordPropertyId = 30019;
|
|
196
|
+
exports.UIA_ItemTypePropertyId = 30021;
|
|
197
|
+
exports.UIA_IsGridPatternAvailablePropertyId = 30045;
|
|
198
|
+
exports.UIA_ButtonControlTypeId = 50000;
|
|
199
|
+
exports.UIA_CalendarControlTypeId = 50001;
|
|
200
|
+
exports.UIA_CheckBoxControlTypeId = 50002;
|
|
201
|
+
exports.UIA_ComboBoxControlTypeId = 50003;
|
|
202
|
+
exports.UIA_EditControlTypeId = 50004;
|
|
203
|
+
exports.UIA_HyperlinkControlTypeId = 50005;
|
|
204
|
+
exports.UIA_ImageControlTypeId = 50006;
|
|
205
|
+
exports.UIA_ListItemControlTypeId = 50007;
|
|
206
|
+
exports.UIA_ListControlTypeId = 50008;
|
|
207
|
+
exports.UIA_MenuControlTypeId = 50009;
|
|
208
|
+
exports.UIA_MenuBarControlTypeId = 50010;
|
|
209
|
+
exports.UIA_MenuItemControlTypeId = 50011;
|
|
210
|
+
exports.UIA_ProgressBarControlTypeId = 50012;
|
|
211
|
+
exports.UIA_RadioButtonControlTypeId = 50013;
|
|
212
|
+
exports.UIA_ScrollBarControlTypeId = 50014;
|
|
213
|
+
exports.UIA_SliderControlTypeId = 50015;
|
|
214
|
+
exports.UIA_SpinnerControlTypeId = 50016;
|
|
215
|
+
exports.UIA_StatusBarControlTypeId = 50017;
|
|
216
|
+
exports.UIA_TabControlTypeId = 50018;
|
|
217
|
+
exports.UIA_TabItemControlTypeId = 50019;
|
|
218
|
+
exports.UIA_TextControlTypeId = 50020;
|
|
219
|
+
exports.UIA_ToolBarControlTypeId = 50021;
|
|
220
|
+
exports.UIA_ToolTipControlTypeId = 50022;
|
|
221
|
+
exports.UIA_TreeControlTypeId = 50023;
|
|
222
|
+
exports.UIA_TreeItemControlTypeId = 50024;
|
|
223
|
+
exports.UIA_CustomControlTypeId = 50025;
|
|
224
|
+
exports.UIA_GroupControlTypeId = 50026;
|
|
225
|
+
exports.UIA_ThumbControlTypeId = 50027;
|
|
226
|
+
exports.UIA_DataGridControlTypeId = 50028;
|
|
227
|
+
exports.UIA_DataItemControlTypeId = 50029;
|
|
228
|
+
exports.UIA_DocumentControlTypeId = 50030;
|
|
229
|
+
exports.UIA_SplitButtonControlTypeId = 50031;
|
|
230
|
+
exports.UIA_WindowControlTypeId = 50032;
|
|
231
|
+
exports.UIA_PaneControlTypeId = 50033;
|
|
232
|
+
exports.UIA_HeaderControlTypeId = 50034;
|
|
233
|
+
exports.UIA_HeaderItemControlTypeId = 50035;
|
|
234
|
+
exports.UIA_TableControlTypeId = 50036;
|
|
235
|
+
exports.UIA_TitleBarControlTypeId = 50037;
|
|
236
|
+
exports.UIA_SeparatorControlTypeId = 50038;
|
|
237
|
+
exports.UIA_SemanticZoomControlTypeId = 50039;
|
|
238
|
+
exports.UIA_AppBarControlTypeId = 50040;
|
|
239
|
+
exports.COINIT_MULTITHREADED = 0x0;
|
|
240
|
+
exports.COINIT_APARTMENTTHREADED = 0x02;
|
|
241
|
+
exports.CLSCTX_INPROC_SERVER = 0x1;
|
|
242
|
+
exports.TreeScope = {
|
|
243
|
+
Element: 0x1,
|
|
244
|
+
Children: 0x2,
|
|
245
|
+
Descendants: 0x4,
|
|
246
|
+
Parent: 0x8,
|
|
247
|
+
Ancestors: 0x10,
|
|
248
|
+
Subtree: 0x7
|
|
249
|
+
};
|
|
250
|
+
exports.CoInitializeEx = ole32.func('HRESULT __stdcall CoInitializeEx(void *pvReserved, uint32 dwCoInit)');
|
|
251
|
+
exports.CoCreateInstance = ole32.func('HRESULT __stdcall CoCreateInstance(GUID *rclsid, void *pUnkOuter, uint32 dwClsContext, GUID *riid, void **ppv)');
|
|
252
|
+
exports.VariantClear = oleaut32.func('HRESULT __stdcall VariantClear(void *pvarg)');
|
|
253
|
+
exports.SysStringLen = oleaut32.func('uint32 __stdcall SysStringLen(void * bstr)');
|
|
254
|
+
class UIAClient {
|
|
255
|
+
automation; // Pointer to IUIAutomation object
|
|
256
|
+
constructor() {
|
|
257
|
+
// Initialize COM
|
|
258
|
+
(0, exports.CoInitializeEx)(null, exports.COINIT_APARTMENTTHREADED);
|
|
259
|
+
// Explicitly allocate GUIDs for safety (Koffi stability)
|
|
260
|
+
const clsidPtr = (0, koffi_1.alloc)(exports.GUID, 1);
|
|
261
|
+
(0, koffi_1.encode)(clsidPtr, exports.GUID, exports.CLSID_CUIAutomation);
|
|
262
|
+
const iidPtr = (0, koffi_1.alloc)(exports.GUID, 1);
|
|
263
|
+
(0, koffi_1.encode)(iidPtr, exports.GUID, exports.IID_IUIAutomation);
|
|
264
|
+
const ppvBuf = Buffer.alloc(8);
|
|
265
|
+
const result = (0, exports.CoCreateInstance)(clsidPtr, null, exports.CLSCTX_INPROC_SERVER, iidPtr, ppvBuf);
|
|
266
|
+
if (result < 0) {
|
|
267
|
+
throw new Error(`CoCreateInstance failed: ${result}`);
|
|
268
|
+
}
|
|
269
|
+
this.automation = (0, koffi_1.decode)(ppvBuf, exports.PVOID);
|
|
270
|
+
}
|
|
271
|
+
getDesktopWindow() {
|
|
272
|
+
try {
|
|
273
|
+
const user32 = (0, koffi_1.load)('user32.dll');
|
|
274
|
+
const GetDesktopWindow = user32.func('HWND __stdcall GetDesktopWindow()');
|
|
275
|
+
return GetDesktopWindow();
|
|
276
|
+
}
|
|
277
|
+
catch {
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
elementFromHandle(hwnd) {
|
|
282
|
+
const vtable = (0, koffi_1.decode)((0, koffi_1.decode)(this.automation, exports.PVOID), exports.IUIAutomationVtbl);
|
|
283
|
+
const func = (0, koffi_1.decode)(vtable.ElementFromHandle, (0, koffi_1.proto)('HRESULT __stdcall (void *this, void *hwnd, void **element)'));
|
|
284
|
+
const buf = Buffer.alloc(8);
|
|
285
|
+
const res = func(this.automation, hwnd, buf);
|
|
286
|
+
if (res < 0)
|
|
287
|
+
throw new Error(`ElementFromHandle failed: ${res}`);
|
|
288
|
+
return new UIAElement((0, koffi_1.decode)(buf, exports.PVOID));
|
|
289
|
+
}
|
|
290
|
+
getRootElement() {
|
|
291
|
+
if (!this.automation)
|
|
292
|
+
throw new Error('Automation object is null');
|
|
293
|
+
const vptr = (0, koffi_1.decode)(this.automation, exports.PVOID);
|
|
294
|
+
const vtable = (0, koffi_1.decode)(vptr, exports.IUIAutomationVtbl);
|
|
295
|
+
const func = (0, koffi_1.decode)(vtable.GetRootElement, exports.GetRootElementProto);
|
|
296
|
+
const rootPtrBuf = Buffer.alloc(8);
|
|
297
|
+
const res = func(this.automation, rootPtrBuf);
|
|
298
|
+
if (res < 0)
|
|
299
|
+
throw new Error(`GetRootElement failed: ${res}`);
|
|
300
|
+
const rootPtr = (0, koffi_1.decode)(rootPtrBuf, exports.PVOID);
|
|
301
|
+
return new UIAElement(rootPtr);
|
|
302
|
+
}
|
|
303
|
+
createTrueCondition() {
|
|
304
|
+
const vptr = (0, koffi_1.decode)(this.automation, exports.PVOID);
|
|
305
|
+
const vtable = (0, koffi_1.decode)(vptr, exports.IUIAutomationVtbl);
|
|
306
|
+
const func = (0, koffi_1.decode)(vtable.CreateTrueCondition, exports.CreateTrueConditionProto);
|
|
307
|
+
const condPtrBuf = Buffer.alloc(8);
|
|
308
|
+
const res = func(this.automation, condPtrBuf);
|
|
309
|
+
if (res < 0)
|
|
310
|
+
throw new Error(`CreateTrueCondition failed: ${res}`);
|
|
311
|
+
return (0, koffi_1.decode)(condPtrBuf, exports.PVOID);
|
|
312
|
+
}
|
|
313
|
+
// Temporarily disabled due to hard crashes with VARIANT pass-by-value on some environments.
|
|
314
|
+
// We use JS-based filtering in the engine instead.
|
|
315
|
+
createPropertyCondition(propertyId, value) {
|
|
316
|
+
throw new Error("Native CreatePropertyCondition is currently disabled for stability");
|
|
317
|
+
}
|
|
318
|
+
getRawViewCondition() {
|
|
319
|
+
const vtable = (0, koffi_1.decode)((0, koffi_1.decode)(this.automation, exports.PVOID), exports.IUIAutomationVtbl);
|
|
320
|
+
const func = (0, koffi_1.decode)(vtable.get_RawViewCondition, (0, koffi_1.proto)('HRESULT __stdcall (void *this, void **condition)'));
|
|
321
|
+
const buf = Buffer.alloc(8);
|
|
322
|
+
const res = func(this.automation, buf);
|
|
323
|
+
if (res < 0)
|
|
324
|
+
throw new Error(`get_RawViewCondition failed: ${res}`);
|
|
325
|
+
return (0, koffi_1.decode)(buf, exports.PVOID);
|
|
326
|
+
}
|
|
327
|
+
createAndCondition(c1, c2) {
|
|
328
|
+
const vtable = (0, koffi_1.decode)((0, koffi_1.decode)(this.automation, exports.PVOID), exports.IUIAutomationVtbl);
|
|
329
|
+
const func = (0, koffi_1.decode)(vtable.CreateAndCondition, (0, koffi_1.proto)('HRESULT __stdcall (void *this, void *c1, void *c2, void **res)'));
|
|
330
|
+
const buf = Buffer.alloc(8);
|
|
331
|
+
const res = func(this.automation, c1, c2, buf);
|
|
332
|
+
if (res < 0)
|
|
333
|
+
throw new Error(`CreateAndCondition failed: ${res}`);
|
|
334
|
+
return (0, koffi_1.decode)(buf, exports.PVOID);
|
|
335
|
+
}
|
|
336
|
+
createOrCondition(c1, c2) {
|
|
337
|
+
const vtable = (0, koffi_1.decode)((0, koffi_1.decode)(this.automation, exports.PVOID), exports.IUIAutomationVtbl);
|
|
338
|
+
const func = (0, koffi_1.decode)(vtable.CreateOrCondition, (0, koffi_1.proto)('HRESULT __stdcall (void *this, void *c1, void *c2, void **res)'));
|
|
339
|
+
const buf = Buffer.alloc(8);
|
|
340
|
+
const res = func(this.automation, c1, c2, buf);
|
|
341
|
+
if (res < 0)
|
|
342
|
+
throw new Error(`CreateOrCondition failed: ${res}`);
|
|
343
|
+
return (0, koffi_1.decode)(buf, exports.PVOID);
|
|
344
|
+
}
|
|
345
|
+
createNotCondition(c) {
|
|
346
|
+
const vtable = (0, koffi_1.decode)((0, koffi_1.decode)(this.automation, exports.PVOID), exports.IUIAutomationVtbl);
|
|
347
|
+
const func = (0, koffi_1.decode)(vtable.CreateNotCondition, (0, koffi_1.proto)('HRESULT __stdcall (void *this, void *c, void **res)'));
|
|
348
|
+
const buf = Buffer.alloc(8);
|
|
349
|
+
const res = func(this.automation, c, buf);
|
|
350
|
+
if (res < 0)
|
|
351
|
+
throw new Error(`CreateNotCondition failed: ${res}`);
|
|
352
|
+
return (0, koffi_1.decode)(buf, exports.PVOID);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
exports.UIAClient = UIAClient;
|
|
356
|
+
// IUIAutomationElementArray Interface
|
|
357
|
+
exports.IUIAutomationElementArrayVtbl = (0, koffi_1.struct)('IUIAutomationElementArrayVtbl', {
|
|
358
|
+
// IUnknown
|
|
359
|
+
QueryInterface: (0, koffi_1.pointer)(QueryInterfaceCallback),
|
|
360
|
+
AddRef: (0, koffi_1.pointer)(AddRefCallback),
|
|
361
|
+
Release: (0, koffi_1.pointer)(ReleaseCallback),
|
|
362
|
+
// IUIAutomationElementArray
|
|
363
|
+
get_Length: (0, koffi_1.pointer)((0, koffi_1.proto)('HRESULT __stdcall (void *this, int *length)')),
|
|
364
|
+
GetElement: (0, koffi_1.pointer)((0, koffi_1.proto)('HRESULT __stdcall (void *this, int index, void **element)')),
|
|
365
|
+
});
|
|
366
|
+
class UIAElement {
|
|
367
|
+
element; // Pointer to IUIAutomationElement
|
|
368
|
+
constructor(ptr) {
|
|
369
|
+
this.element = ptr;
|
|
370
|
+
}
|
|
371
|
+
getVTable() {
|
|
372
|
+
const vptr = (0, koffi_1.decode)(this.element, exports.PVOID);
|
|
373
|
+
return (0, koffi_1.decode)(vptr, exports.IUIAutomationElementVtbl);
|
|
374
|
+
}
|
|
375
|
+
setFocus() {
|
|
376
|
+
const vtable = this.getVTable();
|
|
377
|
+
const func = (0, koffi_1.decode)(vtable.SetFocus, (0, koffi_1.proto)('HRESULT __stdcall (void *this)'));
|
|
378
|
+
const res = func(this.element);
|
|
379
|
+
if (res < 0)
|
|
380
|
+
throw new Error(`SetFocus failed: ${res}`);
|
|
381
|
+
}
|
|
382
|
+
getBoundingRectangle() {
|
|
383
|
+
const vtable = this.getVTable();
|
|
384
|
+
const func = (0, koffi_1.decode)(vtable.get_CurrentBoundingRectangle, exports.get_CurrentBoundingRectangleProto);
|
|
385
|
+
const rectBuf = Buffer.alloc(16); // 4 * 4 bytes
|
|
386
|
+
const res = func(this.element, rectBuf);
|
|
387
|
+
if (res < 0)
|
|
388
|
+
throw new Error(`get_CurrentBoundingRectangle failed: ${res}`);
|
|
389
|
+
const rect = (0, koffi_1.decode)(rectBuf, exports.RECT);
|
|
390
|
+
return rect;
|
|
391
|
+
}
|
|
392
|
+
probe(index) {
|
|
393
|
+
const vptr = (0, koffi_1.decode)(this.element, exports.PVOID);
|
|
394
|
+
const ptrArray = (0, koffi_1.decode)(vptr, 'void*[100]');
|
|
395
|
+
const funcPtr = ptrArray[index];
|
|
396
|
+
if (!funcPtr)
|
|
397
|
+
return "NULL";
|
|
398
|
+
const func = (0, koffi_1.decode)(funcPtr, (0, koffi_1.proto)('HRESULT __stdcall (void *this, void *retVal)'));
|
|
399
|
+
const buf = Buffer.alloc(16);
|
|
400
|
+
try {
|
|
401
|
+
const res = func(this.element, buf);
|
|
402
|
+
if (res < 0)
|
|
403
|
+
return `Error:${res}`;
|
|
404
|
+
const bstrPtr = (0, koffi_1.decode)(buf.subarray(0, 8), exports.PVOID);
|
|
405
|
+
if (!bstrPtr)
|
|
406
|
+
return "EmptyPtr";
|
|
407
|
+
// Safety Check: if pointer is low value (likely int), don't treat as address
|
|
408
|
+
const addr = (0, koffi_1.address)(bstrPtr);
|
|
409
|
+
if (addr < 65536)
|
|
410
|
+
return `Int:${addr}`;
|
|
411
|
+
try {
|
|
412
|
+
const len = (0, exports.SysStringLen)(bstrPtr);
|
|
413
|
+
if (len > 0 && len < 1000) {
|
|
414
|
+
const bytes = (0, koffi_1.decode)(bstrPtr, 'uint8', len * 2);
|
|
415
|
+
const str = Buffer.from(bytes).toString('utf16le');
|
|
416
|
+
if (/^[\\w\\s\\.]+$/.test(str) || str.includes("Taskbar")) {
|
|
417
|
+
return `STR:${str}`;
|
|
418
|
+
}
|
|
419
|
+
return `PossibleStr:${str.substring(0, 20)}`;
|
|
420
|
+
}
|
|
421
|
+
return `Len:${len}`;
|
|
422
|
+
}
|
|
423
|
+
catch {
|
|
424
|
+
return "NotString";
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
catch (e) {
|
|
428
|
+
return "Crash";
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
getName() {
|
|
432
|
+
const vtable = this.getVTable();
|
|
433
|
+
// Index 23
|
|
434
|
+
const func = (0, koffi_1.decode)(vtable.get_CurrentName, (0, koffi_1.proto)('HRESULT __stdcall (void *this, void **retVal)'));
|
|
435
|
+
const ptrBuf = Buffer.alloc(8);
|
|
436
|
+
const res = func(this.element, ptrBuf);
|
|
437
|
+
if (res < 0)
|
|
438
|
+
throw new Error(`get_CurrentName failed: ${res}`);
|
|
439
|
+
const bstrPtr = (0, koffi_1.decode)(ptrBuf, exports.PVOID);
|
|
440
|
+
if (!bstrPtr)
|
|
441
|
+
return "";
|
|
442
|
+
try {
|
|
443
|
+
const len = (0, exports.SysStringLen)(bstrPtr);
|
|
444
|
+
if (len > 0) {
|
|
445
|
+
const bytes = (0, koffi_1.decode)(bstrPtr, 'uint8', len * 2);
|
|
446
|
+
return Buffer.from(bytes).toString('utf16le');
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
finally {
|
|
450
|
+
(0, exports.SysFreeString)(bstrPtr);
|
|
451
|
+
}
|
|
452
|
+
return "";
|
|
453
|
+
}
|
|
454
|
+
getClassName() {
|
|
455
|
+
const vtable = this.getVTable();
|
|
456
|
+
// Index 30
|
|
457
|
+
const func = (0, koffi_1.decode)(vtable.get_CurrentClassName, (0, koffi_1.proto)('HRESULT __stdcall (void *this, void **retVal)'));
|
|
458
|
+
const ptrBuf = Buffer.alloc(8);
|
|
459
|
+
const res = func(this.element, ptrBuf);
|
|
460
|
+
if (res < 0)
|
|
461
|
+
throw new Error(`get_CurrentClassName failed: ${res}`);
|
|
462
|
+
const bstrPtr = (0, koffi_1.decode)(ptrBuf, exports.PVOID);
|
|
463
|
+
if (!bstrPtr)
|
|
464
|
+
return "";
|
|
465
|
+
try {
|
|
466
|
+
const len = (0, exports.SysStringLen)(bstrPtr);
|
|
467
|
+
if (len > 0) {
|
|
468
|
+
const bytes = (0, koffi_1.decode)(bstrPtr, 'uint8', len * 2);
|
|
469
|
+
return Buffer.from(bytes).toString('utf16le');
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
finally {
|
|
473
|
+
(0, exports.SysFreeString)(bstrPtr);
|
|
474
|
+
}
|
|
475
|
+
return "";
|
|
476
|
+
}
|
|
477
|
+
findFirst(scope, conditionPtr) {
|
|
478
|
+
const vtable = this.getVTable();
|
|
479
|
+
const func = (0, koffi_1.decode)(vtable.FindFirst, exports.FindFirstProto);
|
|
480
|
+
const foundPtr = Buffer.alloc(8);
|
|
481
|
+
const res = func(this.element, scope, conditionPtr, foundPtr);
|
|
482
|
+
if (res < 0)
|
|
483
|
+
throw new Error(`FindFirst failed: ${res}`);
|
|
484
|
+
const ptr = (0, koffi_1.decode)(foundPtr, exports.PVOID);
|
|
485
|
+
if (!ptr)
|
|
486
|
+
return null;
|
|
487
|
+
return new UIAElement(ptr);
|
|
488
|
+
}
|
|
489
|
+
findAll(scope, conditionPtr) {
|
|
490
|
+
const vtable = this.getVTable();
|
|
491
|
+
const func = (0, koffi_1.decode)(vtable.FindAll, exports.FindAllProto);
|
|
492
|
+
const foundPtr = Buffer.alloc(8);
|
|
493
|
+
const res = func(this.element, scope, conditionPtr, foundPtr);
|
|
494
|
+
if (res < 0)
|
|
495
|
+
throw new Error(`FindAll failed: ${res}`);
|
|
496
|
+
const ptr = (0, koffi_1.decode)(foundPtr, exports.PVOID);
|
|
497
|
+
if (!ptr)
|
|
498
|
+
return null;
|
|
499
|
+
return new UIAElementArray(ptr);
|
|
500
|
+
}
|
|
501
|
+
getCurrentPropertyValue(propertyId) {
|
|
502
|
+
const vtable = this.getVTable();
|
|
503
|
+
const func = (0, koffi_1.decode)(vtable.GetCurrentPropertyValue, exports.GetCurrentPropertyValueProto);
|
|
504
|
+
const variantBuf = Buffer.alloc(24);
|
|
505
|
+
const res = func(this.element, propertyId, variantBuf);
|
|
506
|
+
if (res < 0)
|
|
507
|
+
throw new Error(`GetCurrentPropertyValue failed: ${res}`);
|
|
508
|
+
const vt = variantBuf.readUInt16LE(0);
|
|
509
|
+
let value = null;
|
|
510
|
+
try {
|
|
511
|
+
switch (vt) {
|
|
512
|
+
case exports.VT_I4:
|
|
513
|
+
value = variantBuf.readInt32LE(8);
|
|
514
|
+
break;
|
|
515
|
+
case exports.VT_BOOL:
|
|
516
|
+
value = variantBuf.readInt16LE(8) !== 0;
|
|
517
|
+
break;
|
|
518
|
+
case exports.VT_BSTR:
|
|
519
|
+
const bstrPtr = (0, koffi_1.decode)(variantBuf.subarray(8, 16), exports.PVOID);
|
|
520
|
+
if (bstrPtr) {
|
|
521
|
+
try {
|
|
522
|
+
const len = (0, exports.SysStringLen)(bstrPtr);
|
|
523
|
+
if (len > 0) {
|
|
524
|
+
const bytes = (0, koffi_1.decode)(bstrPtr, 'uint8', len * 2);
|
|
525
|
+
value = Buffer.from(bytes).toString('utf16le');
|
|
526
|
+
}
|
|
527
|
+
else {
|
|
528
|
+
value = "";
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
catch (e) {
|
|
532
|
+
console.error('Error decoding BSTR:', e);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
else {
|
|
536
|
+
value = "";
|
|
537
|
+
}
|
|
538
|
+
break;
|
|
539
|
+
case 0x2003: // VT_ARRAY | VT_I4
|
|
540
|
+
const safeArrayPtr = (0, koffi_1.decode)(variantBuf.subarray(8, 16), exports.PVOID);
|
|
541
|
+
if (safeArrayPtr) {
|
|
542
|
+
try {
|
|
543
|
+
const SafeArrayGetVartype = oleaut32.func('HRESULT __stdcall SafeArrayGetVartype(void *, uint16 *)');
|
|
544
|
+
const SafeArrayGetLBound = oleaut32.func('HRESULT __stdcall SafeArrayGetLBound(void *, uint, long *)');
|
|
545
|
+
const SafeArrayGetUBound = oleaut32.func('HRESULT __stdcall SafeArrayGetUBound(void *, uint, long *)');
|
|
546
|
+
const SafeArrayAccessData = oleaut32.func('HRESULT __stdcall SafeArrayAccessData(void *, void **)');
|
|
547
|
+
const SafeArrayUnaccessData = oleaut32.func('HRESULT __stdcall SafeArrayUnaccessData(void *)');
|
|
548
|
+
let lboundBuf = Buffer.alloc(4);
|
|
549
|
+
let uboundBuf = Buffer.alloc(4);
|
|
550
|
+
SafeArrayGetLBound(safeArrayPtr, 1, lboundBuf);
|
|
551
|
+
SafeArrayGetUBound(safeArrayPtr, 1, uboundBuf);
|
|
552
|
+
const lbound = lboundBuf.readInt32LE(0);
|
|
553
|
+
const ubound = uboundBuf.readInt32LE(0);
|
|
554
|
+
const count = ubound - lbound + 1;
|
|
555
|
+
if (count > 0) {
|
|
556
|
+
let dataPtrBuf = Buffer.alloc(8);
|
|
557
|
+
SafeArrayAccessData(safeArrayPtr, dataPtrBuf);
|
|
558
|
+
const dataPtr = (0, koffi_1.decode)(dataPtrBuf, exports.PVOID);
|
|
559
|
+
const ints = (0, koffi_1.decode)(dataPtr, 'int32', count);
|
|
560
|
+
value = Array.from(ints);
|
|
561
|
+
SafeArrayUnaccessData(safeArrayPtr);
|
|
562
|
+
}
|
|
563
|
+
else {
|
|
564
|
+
value = [];
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
catch (e) {
|
|
568
|
+
console.error('Error decoding SafeArray:', e);
|
|
569
|
+
value = [];
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
value = [];
|
|
574
|
+
}
|
|
575
|
+
break;
|
|
576
|
+
case 0: // VT_EMPTY
|
|
577
|
+
value = null;
|
|
578
|
+
break;
|
|
579
|
+
default:
|
|
580
|
+
console.warn(`Unsupported VARIANT type: ${vt}`);
|
|
581
|
+
value = null;
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
catch (e) {
|
|
585
|
+
console.error('Error parsing variant:', e);
|
|
586
|
+
}
|
|
587
|
+
finally {
|
|
588
|
+
const hr = (0, exports.VariantClear)(variantBuf);
|
|
589
|
+
if (hr < 0)
|
|
590
|
+
console.error(`VariantClear failed: ${hr}`);
|
|
591
|
+
}
|
|
592
|
+
return value;
|
|
593
|
+
}
|
|
594
|
+
// JS-side fallback for finding elements by property since CreatePropertyCondition crashes.
|
|
595
|
+
findFirstByProperty(scope, propertyId, value, client) {
|
|
596
|
+
// Only TreeScope.Children is efficiently supported by this fallback for now.
|
|
597
|
+
// Descendants would require recursive traversal.
|
|
598
|
+
// Use CreateTrueCondition to get all items
|
|
599
|
+
const trueCond = client.createTrueCondition();
|
|
600
|
+
const children = this.findAll(scope, trueCond);
|
|
601
|
+
if (!children)
|
|
602
|
+
return null;
|
|
603
|
+
const count = children.length;
|
|
604
|
+
for (let i = 0; i < count; i++) {
|
|
605
|
+
// Access element directly without creating full JS wrapper logic overhead if possible?
|
|
606
|
+
// children.getElement(i) returns UIAElement.
|
|
607
|
+
const el = children.getElement(i);
|
|
608
|
+
try {
|
|
609
|
+
const propVal = el.getCurrentPropertyValue(propertyId);
|
|
610
|
+
// Simple equality check
|
|
611
|
+
if (propVal === value) {
|
|
612
|
+
return el;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
catch (e) {
|
|
616
|
+
// Ignore error reading property
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
return null;
|
|
620
|
+
}
|
|
621
|
+
findAllByProperty(scope, propertyId, value, client) {
|
|
622
|
+
const result = [];
|
|
623
|
+
let cond;
|
|
624
|
+
try {
|
|
625
|
+
cond = client.createPropertyCondition(propertyId, value);
|
|
626
|
+
}
|
|
627
|
+
catch (e) {
|
|
628
|
+
// Fallback to JS filtering if native condition creation fails
|
|
629
|
+
const trueCond = client.createTrueCondition();
|
|
630
|
+
const children = this.findAll(scope, trueCond);
|
|
631
|
+
if (!children)
|
|
632
|
+
return result;
|
|
633
|
+
for (const el of children.toArray()) {
|
|
634
|
+
if (el.getCurrentPropertyValue(propertyId) === value)
|
|
635
|
+
result.push(el);
|
|
636
|
+
}
|
|
637
|
+
return result;
|
|
638
|
+
}
|
|
639
|
+
const array = this.findAll(scope, cond);
|
|
640
|
+
return array ? array.toArray() : [];
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
exports.UIAElement = UIAElement;
|
|
644
|
+
class UIAElementArray {
|
|
645
|
+
array;
|
|
646
|
+
constructor(ptr) { this.array = ptr; }
|
|
647
|
+
get length() {
|
|
648
|
+
const vptr = (0, koffi_1.decode)(this.array, exports.PVOID);
|
|
649
|
+
const vtable = (0, koffi_1.decode)(vptr, exports.IUIAutomationElementArrayVtbl);
|
|
650
|
+
const func = (0, koffi_1.decode)(vtable.get_Length, exports.get_LengthProto);
|
|
651
|
+
const lenBuf = Buffer.alloc(4);
|
|
652
|
+
const res = func(this.array, lenBuf);
|
|
653
|
+
if (res < 0)
|
|
654
|
+
throw new Error(`get_Length failed: ${res}`);
|
|
655
|
+
return (0, koffi_1.decode)(lenBuf, 'int');
|
|
656
|
+
}
|
|
657
|
+
getElement(index) {
|
|
658
|
+
const vptr = (0, koffi_1.decode)(this.array, exports.PVOID);
|
|
659
|
+
const vtable = (0, koffi_1.decode)(vptr, exports.IUIAutomationElementArrayVtbl);
|
|
660
|
+
const func = (0, koffi_1.decode)(vtable.GetElement, exports.GetElementProto);
|
|
661
|
+
const elPtrBuf = Buffer.alloc(8);
|
|
662
|
+
const res = func(this.array, index, elPtrBuf);
|
|
663
|
+
if (res < 0)
|
|
664
|
+
throw new Error(`GetElement failed: ${res}`);
|
|
665
|
+
const ptr = (0, koffi_1.decode)(elPtrBuf, exports.PVOID);
|
|
666
|
+
return new UIAElement(ptr);
|
|
667
|
+
}
|
|
668
|
+
toArray() {
|
|
669
|
+
const len = this.length;
|
|
670
|
+
const result = [];
|
|
671
|
+
for (let i = 0; i < len; i++)
|
|
672
|
+
result.push(this.getElement(i));
|
|
673
|
+
return result;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
exports.UIAElementArray = UIAElementArray;
|
|
677
|
+
//# sourceMappingURL=uia.js.map
|