This repository has been archived by the owner on Mar 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathiuiautomationelement.go
287 lines (258 loc) · 7.92 KB
/
iuiautomationelement.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
package w32uiautomation
import (
"syscall"
"unsafe"
"github.com/go-ole/go-ole"
)
type RECT struct {
Left uint32
Top uint32
Right uint32
Bottom uint32
}
type IUIAutomationElement struct {
ole.IUnknown
}
type IUIAutomationElementVtbl struct {
ole.IUnknownVtbl
SetFocus uintptr
GetRuntimeId uintptr
FindFirst uintptr
FindAll uintptr
FindFirstBuildCache uintptr
FindAllBuildCache uintptr
BuildUpdatedCache uintptr
GetCurrentPropertyValue uintptr
GetCurrentPropertyValueEx uintptr
GetCachedPropertyValue uintptr
GetCachedPropertyValueEx uintptr
GetCurrentPatternAs uintptr
GetCachedPatternAs uintptr
GetCurrentPattern uintptr
GetCachedPattern uintptr
GetCachedParent uintptr
GetCachedChildren uintptr
Get_CurrentProcessId uintptr
Get_CurrentControlType uintptr
Get_CurrentLocalizedControlType uintptr
Get_CurrentName uintptr
Get_CurrentAcceleratorKey uintptr
Get_CurrentAccessKey uintptr
Get_CurrentHasKeyboardFocus uintptr
Get_CurrentIsKeyboardFocusable uintptr
Get_CurrentIsEnabled uintptr
Get_CurrentAutomationId uintptr
Get_CurrentClassName uintptr
Get_CurrentHelpText uintptr
Get_CurrentCulture uintptr
Get_CurrentIsControlElement uintptr
Get_CurrentIsContentElement uintptr
Get_CurrentIsPassword uintptr
Get_CurrentNativeWindowHandle uintptr
Get_CurrentItemType uintptr
Get_CurrentIsOffscreen uintptr
Get_CurrentOrientation uintptr
Get_CurrentFrameworkId uintptr
Get_CurrentIsRequiredForForm uintptr
Get_CurrentItemStatus uintptr
Get_CurrentBoundingRectangle uintptr
Get_CurrentLabeledBy uintptr
Get_CurrentAriaRole uintptr
Get_CurrentAriaProperties uintptr
Get_CurrentIsDataValidForForm uintptr
Get_CurrentControllerFor uintptr
Get_CurrentDescribedBy uintptr
Get_CurrentFlowsTo uintptr
Get_CurrentProviderDescription uintptr
Get_CachedProcessId uintptr
Get_CachedControlType uintptr
Get_CachedLocalizedControlType uintptr
Get_CachedName uintptr
Get_CachedAcceleratorKey uintptr
Get_CachedAccessKey uintptr
Get_CachedHasKeyboardFocus uintptr
Get_CachedIsKeyboardFocusable uintptr
Get_CachedIsEnabled uintptr
Get_CachedAutomationId uintptr
Get_CachedClassName uintptr
Get_CachedHelpText uintptr
Get_CachedCulture uintptr
Get_CachedIsControlElement uintptr
Get_CachedIsContentElement uintptr
Get_CachedIsPassword uintptr
Get_CachedNativeWindowHandle uintptr
Get_CachedItemType uintptr
Get_CachedIsOffscreen uintptr
Get_CachedOrientation uintptr
Get_CachedFrameworkId uintptr
Get_CachedIsRequiredForForm uintptr
Get_CachedItemStatus uintptr
Get_CachedBoundingRectangle uintptr
Get_CachedLabeledBy uintptr
Get_CachedAriaRole uintptr
Get_CachedAriaProperties uintptr
Get_CachedIsDataValidForForm uintptr
Get_CachedControllerFor uintptr
Get_CachedDescribedBy uintptr
Get_CachedFlowsTo uintptr
Get_CachedProviderDescription uintptr
GetClickablePoint uintptr
}
var IID_IUIAutomationElement = &ole.GUID{0xd22108aa, 0x8ac5, 0x49a5, [8]byte{0x83, 0x7b, 0x37, 0xbb, 0xb3, 0xd7, 0x59, 0x1e}}
func (elem *IUIAutomationElement) VTable() *IUIAutomationElementVtbl {
return (*IUIAutomationElementVtbl)(unsafe.Pointer(elem.RawVTable))
}
func (elem *IUIAutomationElement) SetFocus() (err error) {
return setFocus(elem)
}
func (elem *IUIAutomationElement) FindFirst(scope TreeScope, condition *IUIAutomationCondition) (found *IUIAutomationElement, err error) {
return findFirst(elem, scope, condition)
}
func (elem *IUIAutomationElement) GetCurrentPattern(patternId PATTERNID) (*ole.IUnknown, error) {
return getCurrentPattern(elem, patternId)
}
func (elem *IUIAutomationElement) Get_CurrentAutomationId() (string, error) {
return get_CurrentAutomationId(elem)
}
func (elem *IUIAutomationElement) Get_CurrentCurrentClassName() (string, error) {
return get_CurrentClassName(elem)
}
func (elem *IUIAutomationElement) Get_CurrentName() (string, error) {
return get_CurrentName(elem)
}
func (elem *IUIAutomationElement) Get_CurrentNativeWindowHandle() (syscall.Handle, error) {
return get_CurrentNativeWindowHandle(elem)
}
func (elem *IUIAutomationElement) Get_CurrentBoundingRectangle() (RECT, error) {
return get_CurrentBoundingRectangle(elem)
}
func (elem *IUIAutomationElement) Get_CurrentPropertyValue(propertyId PROPERTYID) (ole.VARIANT, error) {
return get_CurrentPropertyValue(elem, propertyId)
}
func setFocus(elem *IUIAutomationElement) (err error) {
hr, _, _ := syscall.Syscall(
elem.VTable().SetFocus,
1,
uintptr(unsafe.Pointer(elem)),
0,
0)
if hr != 0 {
err = ole.NewError(hr)
return
}
return
}
func findFirst(elem *IUIAutomationElement, scope TreeScope, condition *IUIAutomationCondition) (found *IUIAutomationElement, err error) {
hr, _, _ := syscall.Syscall6(
elem.VTable().FindFirst,
4,
uintptr(unsafe.Pointer(elem)),
uintptr(scope),
uintptr(unsafe.Pointer(condition)),
uintptr(unsafe.Pointer(&found)),
0,
0)
if hr != 0 {
err = ole.NewError(hr)
}
return
}
func getCurrentPattern(elem *IUIAutomationElement, patternId PATTERNID) (pattern *ole.IUnknown, err error) {
hr, _, _ := syscall.Syscall(
elem.VTable().GetCurrentPattern,
3,
uintptr(unsafe.Pointer(elem)),
uintptr(patternId),
uintptr(unsafe.Pointer(&pattern)))
if hr != 0 {
err = ole.NewError(hr)
return
}
return
}
func get_CurrentAutomationId(elem *IUIAutomationElement) (id string, err error) {
var bstrAutomationId *uint16
hr, _, _ := syscall.Syscall(
elem.VTable().Get_CurrentAutomationId,
2,
uintptr(unsafe.Pointer(elem)),
uintptr(unsafe.Pointer(&bstrAutomationId)),
0)
if hr != 0 {
err = ole.NewError(hr)
return
}
id = ole.BstrToString(bstrAutomationId)
return
}
func get_CurrentClassName(elem *IUIAutomationElement) (name string, err error) {
var bstrName *uint16
hr, _, _ := syscall.Syscall(
elem.VTable().Get_CurrentClassName,
2,
uintptr(unsafe.Pointer(elem)),
uintptr(unsafe.Pointer(&bstrName)),
0)
if hr != 0 {
err = ole.NewError(hr)
return
}
name = ole.BstrToString(bstrName)
return
}
func get_CurrentName(elem *IUIAutomationElement) (name string, err error) {
var bstrName *uint16
hr, _, _ := syscall.Syscall(
elem.VTable().Get_CurrentName,
2,
uintptr(unsafe.Pointer(elem)),
uintptr(unsafe.Pointer(&bstrName)),
0)
if hr != 0 {
err = ole.NewError(hr)
return
}
name = ole.BstrToString(bstrName)
return
}
func get_CurrentNativeWindowHandle(elem *IUIAutomationElement) (handle syscall.Handle, err error) {
hr, _, _ := syscall.Syscall(
elem.VTable().Get_CurrentNativeWindowHandle,
2,
uintptr(unsafe.Pointer(elem)),
uintptr(unsafe.Pointer(&handle)),
0)
if hr != 0 {
err = ole.NewError(hr)
return
}
return
}
func get_CurrentBoundingRectangle(elem *IUIAutomationElement) (rect RECT, err error) {
hr, _, _ := syscall.Syscall(
elem.VTable().Get_CurrentBoundingRectangle,
2,
uintptr(unsafe.Pointer(elem)),
uintptr(unsafe.Pointer(&rect)),
0)
if hr != 0 {
err = ole.NewError(hr)
return
}
return
}
func get_CurrentPropertyValue(elem *IUIAutomationElement, propertyid PROPERTYID) (ole.VARIANT, error) {
var v ole.VARIANT
ole.VariantInit(&v)
hr, _, _ := syscall.Syscall(
elem.VTable().GetCurrentPropertyValue,
3,
uintptr(unsafe.Pointer(elem)),
uintptr(propertyid),
uintptr(unsafe.Pointer(&v)))
if hr != 0 {
err := ole.NewError(hr)
return v, err
}
return v, nil
}