-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathaa hook.py
80 lines (65 loc) · 1.64 KB
/
aa hook.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
import wx
import pyHook
from pyAA import *
class myFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, 'My Frame')
self.hm = pyHook.HookManager()
self.hm.MouseAllButtonsDown = self.OnMouseEvent
self.hm.KeyDown = self.OnKeyboardEvent
self.hm.HookMouse()
self.hm.HookKeyboard()
wx.EVT_CLOSE(self, self.OnClose)
def OnGetAO(self, event):
if event.Type == 'keyboard':
ao = AccessibleObjectFromWindow(event.Window, OBJID_CLIENT)
elif event.Type == 'mouse':
ao = AccessibleObjectFromPoint(event.Position)
print
print '---------------------------'
print 'Event:'
print ' ',event.MessageName
print ' Window:', event.WindowName
if event.Type == 'keyboard':
print ' Key:',event.Key
print
print 'Object:'
try:
print ' Name:', ao.Name
except:
print
try:
print ' Value:', ao.Value
except:
print
try:
print ' Role:', ao.RoleText
except:
print
try:
print ' Description:', ao.Description
except:
print
try:
print ' State:', ao.StateText
except:
print
try:
print ' Shortcut:', ao.KeyboardShortcut
except:
print
def OnMouseEvent(self, event):
event.Type = 'mouse'
wx.CallAfter(self.OnGetAO, event)
def OnKeyboardEvent(self, event):
event.Type = 'keyboard'
wx.CallAfter(self.OnGetAO, event)
def OnClose(self, event):
del self.hm
self.Destroy()
if __name__ == '__main__':
app = wx.PySimpleApp(0)
frame = myFrame()
app.SetTopWindow(frame)
frame.Show()
app.MainLoop()