This repository has been archived by the owner on Jun 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfind_test_element.py
45 lines (33 loc) · 1.84 KB
/
find_test_element.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
import pyia2
import inspect
from pyia2.constants import CHILDID_SELF, \
UNLOCALIZED_ROLE_NAMES, \
UNLOCALIZED_STATE_NAMES
from pyia2.utils import IA2Lib
from pyia2.utils import AccessibleDocument
doc = False
def event_cb(event):
global doc
if event.type == pyia2.IA2_EVENT_DOCUMENT_LOAD_COMPLETE:
ao = pyia2.accessibleObjectFromEvent(event)
doc = AccessibleDocument(ao)
print(doc)
else:
if doc:
if doc.addEvent(event.type):
doc.updateTestElements()
print(doc)
print("This program monitors document change events for MSAA and IAccessible2 and provides information about test elements.")
events_array = [pyia2.IA2_EVENT_DOCUMENT_LOAD_COMPLETE, pyia2.EVENT_OBJECT_FOCUS, pyia2.EVENT_OBJECT_STATECHANGE, pyia2.EVENT_OBJECT_SELECTION, pyia2.EVENT_OBJECT_SELECTIONREMOVE, pyia2.EVENT_OBJECT_NAMECHANGE, pyia2.EVENT_OBJECT_DESCRIPTIONCHANGE, pyia2.IA2_EVENT_ACTIVE_DESCENDANT_CHANGED, pyia2.IA2_EVENT_OBJECT_ATTRIBUTE_CHANGED]
for i in events_array:
pyia2.Registry.registerEventListener(event_cb, i)
# pyia2.Registry.registerEventListener(event_cb, pyia2.IA2_EVENT_DOCUMENT_LOAD_COMPLETE )
# pyia2.Registry.registerEventListener(event_cb, pyia2.EVENT_OBJECT_FOCUS)
# pyia2.Registry.registerEventListener(event_cb, pyia2.EVENT_OBJECT_STATECHANGE)
# pyia2.Registry.registerEventListener(event_cb, pyia2.EVENT_OBJECT_SELECTION)
# pyia2.Registry.registerEventListener(event_cb, pyia2.EVENT_OBJECT_SELECTIONREMOVE)
# pyia2.Registry.registerEventListener(event_cb, pyia2.EVENT_OBJECT_NAMECHANGE)
# pyia2.Registry.registerEventListener(event_cb, pyia2.EVENT_OBJECT_DESCRIPTIONCHANGE)
# pyia2.Registry.registerEventListener(event_cb, pyia2.IA2_EVENT_ACTIVE_DESCENDANT_CHANGED)
# pyia2.Registry.registerEventListener(event_cb, pyia2.IA2_EVENT_OBJECT_ATTRIBUTE_CHANGED)
pyia2.Registry.start()