forked from illinois-dres-aitg/pyia2
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest-callback.py
143 lines (111 loc) · 3.73 KB
/
test-callback.py
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
import pyia2
from pyia2.constants import CHILDID_SELF, \
UNLOCALIZED_ROLE_NAMES, \
UNLOCALIZED_STATE_NAMES
from pyia2.utils import IA2Lib
def event_cb(event):
# print(event)
ao = pyia2.accessibleObjectFromEvent(event)
print("\nMSAA ROLE: " + ao.accRoleName())
try:
print("NAME: " + ao.accName(CHILDID_SELF))
except:
print("NAME: undefined")
try:
print("VALUE: " + ao.accValue(CHILDID_SELF))
except:
print("VALUE: undefined")
try:
print("DESCRIPTION: " + ao.accDescription(CHILDID_SELF))
except:
print("DESCRITPION: undefined")
try:
print("PARENT: " + str(ao.accParent))
except:
print("PARENT: undefined")
try:
print("CHILD: " + str(ao.accChild(0)))
except:
print("CHILD: undefined")
try:
print("CHILD COUNT: " + str(ao.accChildCount))
except:
print("CHILD COUNT: undefined")
try:
print("LAST CHILD: " + str(ao.accChild(ao.accChildCount-1)))
except:
print("LAST CHILD: undefined")
try:
print("MSAA STATE: " + str(ao.accState(CHILDID_SELF)))
except:
print("MSAA STATE: undefined")
try:
print("MSAA STATE(SET): " + str(ao.accStateSet(CHILDID_SELF)))
except:
print("MSAA STATE(SET): undefined")
try:
print("MSAA ROWINDEX: " + str(ao.rowindex))
except:
print("MSAA ROWINDEX: undefined")
ao2 = pyia2.accessible2FromAccessible(ao, CHILDID_SELF)
if isinstance(ao2, IA2Lib.IAccessible2):
# print("IAccessible2 Values: %s"%ao)
print('\n---- IAccessibleTableCell -----')
try:
ia2_role = str(ao2.role())
print("IA2 ROLE(int): " + ia2_role);
except:
print("IA2 ROLE(int): undefined")
try:
ia2_role = pyia2.accessible2RoleName(ao2)
print("IA2 ROLE: " + ia2_role);
except:
print("IA2 ROLE: undefined")
try:
print("IA2 STATES(bits): " + str(ao2.states))
except:
print("IA2 STATES(bits): undefined")
try:
print("IA2 STATES: " + pyia2.accessible2States(ao2))
except:
print("IA2 STATES: undefined")
try:
y = pyia2.accessibleRelationFromAccessible2(ao2)
print("IA2 RELATIONS: " + str(y))
except:
print("IA2 RELATIONS: undefined")
try:
print("UNIQUE ID: " + str(ao2.uniqueID))
except:
print("UNIQUE ID: undefined")
try:
print("ATTRIBUTES: " + str(ao2.attributes))
except:
print("ATTRIBUTES: undefined")
try:
print("GROUP POSITION: " + str(ao2.groupPosition))
except:
print("GROUP POSITION: undefined")
aot = pyia2.accessibleTableCellFromAccessible(ao, CHILDID_SELF)
if isinstance(aot, IA2Lib.IAccessibleTableCell):
print('\n---- IAccessibleTableCell -----')
try:
print("IA2 ROWINDEX: " + str(aot.rowIndex))
except:
print("IA2 ROWINDEX: undefined")
try:
print("IA2 COLINDEX: " + str(aot.columnIndex))
except:
print("IA2 COLINDEX: undefined")
try:
print("IA2 ISSELECTED: " + str(aot.isSelected()))
except:
print("IA2 ISSELECTED: undefined")
else:
print("Not IA2 Object")
print("This program monitors document and focus changes events for MSAA and IAccessible2 and provides information about the event.")
event_id = pyia2.IA2_EVENT_DOCUMENT_LOAD_COMPLETE
pyia2.Registry.registerEventListener(event_cb, event_id )
event_id = pyia2.EVENT_OBJECT_FOCUS
pyia2.Registry.registerEventListener(event_cb, event_id )
pyia2.Registry.start()