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 pathiuiautomationtreewalker.go
84 lines (73 loc) · 2.44 KB
/
iuiautomationtreewalker.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
package w32uiautomation
import (
"syscall"
"unsafe"
"github.com/go-ole/go-ole"
)
type IUIAutomationTreeWalker struct {
ole.IUnknown
}
type IUIAutomationTreeWalkerVtbl struct {
ole.IUnknownVtbl
GetParentElement uintptr
GetFirstChildElement uintptr
GetLastChildElement uintptr
GetNextSiblingElement uintptr
GetPreviousSiblingElement uintptr
NormalizeElement uintptr
GetParentElementBuildCache uintptr
GetFirstChildElementBuildCache uintptr
GetLastChildElementBuildCache uintptr
GetNextSiblingElementBuildCache uintptr
GetPreviousSiblingElementBuildCache uintptr
NormalizeElementBuildCache uintptr
Get_Condition uintptr
}
func (w *IUIAutomationTreeWalker) VTable() *IUIAutomationTreeWalkerVtbl {
return (*IUIAutomationTreeWalkerVtbl)(unsafe.Pointer(w.RawVTable))
}
func (w *IUIAutomationTreeWalker) GetParentElement(element *IUIAutomationElement) (first *IUIAutomationElement, err error) {
return getParentElement(w, element)
}
func (w *IUIAutomationTreeWalker) GetFirstChildElement(element *IUIAutomationElement) (first *IUIAutomationElement, err error) {
return getFirstChildElement(w, element)
}
func (w *IUIAutomationTreeWalker) GetNextSiblingElement(element *IUIAutomationElement) (next *IUIAutomationElement, err error) {
return getNextSiblingElement(w, element)
}
func getParentElement(w *IUIAutomationTreeWalker, element *IUIAutomationElement) (parent *IUIAutomationElement, err error) {
hr, _, _ := syscall.Syscall(
w.VTable().GetParentElement,
3,
uintptr(unsafe.Pointer(w)),
uintptr(unsafe.Pointer(element)),
uintptr(unsafe.Pointer(&parent)))
if hr != 0 {
err = ole.NewError(hr)
}
return
}
func getFirstChildElement(w *IUIAutomationTreeWalker, element *IUIAutomationElement) (first *IUIAutomationElement, err error) {
hr, _, _ := syscall.Syscall(
w.VTable().GetFirstChildElement,
3,
uintptr(unsafe.Pointer(w)),
uintptr(unsafe.Pointer(element)),
uintptr(unsafe.Pointer(&first)))
if hr != 0 {
err = ole.NewError(hr)
}
return
}
func getNextSiblingElement(w *IUIAutomationTreeWalker, element *IUIAutomationElement) (next *IUIAutomationElement, err error) {
hr, _, _ := syscall.Syscall(
w.VTable().GetNextSiblingElement,
3,
uintptr(unsafe.Pointer(w)),
uintptr(unsafe.Pointer(element)),
uintptr(unsafe.Pointer(&next)))
if hr != 0 {
err = ole.NewError(hr)
}
return
}