import pythoncom
import pyHook
def onMouseEvent(event):
print "MessageName:",event.MessageName
print "Message:", event.Message
print "Time:", event.Time
print "Window:", event.Window
print "WindowName:", event.WindowName
print "Position:", event.Position
print "Wheel:", event.Wheel
print "Injected:", event.Injected
print "---"
return True
def onKeyboardEvent(event):
print "MessageName:", event.MessageName
print "Message:", event.Message
print "Time:", event.Time
print "Window:", event.Window
print "WindowName:", event.WindowName
print "Ascii:", event.Ascii, chr(event.Ascii)
print "Key:", event.Key
print "KeyID:", event.KeyID
print "ScanCode:", event.ScanCode
print "Extended:", event.Extended
print "Injected:", event.Injected
print "Alt", event.Alt
print "Transition", event.Transition
print "---"
return True
def main():
hm = pyHook.HookManager()
hm.KeyDown = onKeyboardEvent
hm.HookKeyboard()
hm.MouseAll = onMouseEvent
hm.HookMouse()
pythoncom.PumpMessages()
if __name__ == "__main__":
main()
from distutils.core import setup
import py2exe
setup(console=['test.py'])
import ctypes
whnd = ctypes.windll.kernel32.GetConsoleWindow()
if whnd != 0:
ctypes.windll.user32.ShowWindow(whnd, 0)
ctypes.windll.kernel32.CloseHandle(whnd)