forked from phuslu/pyMSAA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
inspect.py
53 lines (45 loc) · 1.61 KB
/
inspect.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
#!/usr/bin/env python
# coding:utf-8
import sys, os, re, logging, time
import ctypes, ctypes.wintypes
import msaa, comtypes.client
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)s %(message)s')
def GetCursorPos():
objPoint = ctypes.wintypes.POINT()
ctypes.windll.user32.GetCursorPos(ctypes.byref(objPoint))
return objPoint.x, objPoint.y
def GetCurrentElementInfo(objElement):
dictInfo = {}
dictInfo['ChildId'] = objElement.iObjectId
lstAttributeNameList = [
'accRoleName',
'accRole',
'accName',
'accValue',
'accState',
'accLocation',
'accDescription',
'accKeyboardShortcut',
'accDefaultAction',
'accHelp',
'accHelpTopic',
'accChildCount'
]
for attr in lstAttributeNameList:
try:
dictInfo[attr] = getattr(objElement, attr)()
except:
dictInfo[attr] = None
return '\n'.join('%s:\t%r' % (attr, dictInfo[attr]) for attr in lstAttributeNameList)
def main():
x_old, y_old = GetCursorPos()
while 1:
x, y = GetCursorPos()
if (x, y) != (x_old, y_old):
x_old, y_old = x, y
objElement = msaa.point(x, y)
os.system('cls')
print(GetCurrentElementInfo(objElement))
time.sleep(0.5)
if __name__ == '__main__':
main()