팁 & 테크
필요하신 분들은 참고하세요.
동네랑 성격은 틀리지만 필요하신 분들 계실 것 같아서 남겨둡니다.
파이썬훅이라는 모듈을 이용해서 마우스와 키보드 이벤들을 체크하는 겁니다.
일종의 시스템 디바이스 후킹입니다.
다른 오에스는 소스중에 링크 걸려있는 소스포지로 가셔서 원소스를 받아다가 조금만 손 보시면 됩니다.
지원하는 파이썬 버전은 2.7x입니다.
3.x는 소스 컨버트 해도 안될겁니다.
import os
import time
import pyHook # http://sourceforge.net/projects/pyhook/
from win32gui import GetWindowRect, GetClassName, GetWindowText
curTime = time.strftime("%Y%m%d_%H%M%S", time.localtime(time.time()))
if not os.path.exists("Messages"):
os.mkdir("Messages")
f = open("Messages\\messages"+ curTime +".txt", "w")
def Log(logStr):
print str(logStr)
f.write(logStr + "\n")
def OnMouseEvent(event):
Log('MessageName:' + str(event.MessageName))
Log('Message:' + str(event.Message))
Log('Time:' + str(event.Time))
Log('Window:' + str(event.Window))
if event.Window != 0:
Log('Window Rect:' + str( GetWindowRect(event.Window)))
Log('Window Class Name:' + str( GetClassName(event.Window)))
#Log('Window Text:' + str( GetWindowText(event.Window)))
Log('WindowName:' + str(event.WindowName))
Log('Position:' + str(event.Position))
Log('Wheel:' + str(event.Wheel))
Log('Injected:' + str(event.Injected))
Log('---')
# return True to pass the event to other handlers
# return False to stop the event from propagating
return True
def OnKeyboardEvent(event):
Log('MessageName:' + str(event.MessageName))
Log('Message:' + str(event.Message))
Log('Time:' + str(event.Time))
Log('Window:' + str(event.Window))
if event.Window != 0:
Log('Window Rect:' + str( GetWindowRect(event.Window)))
Log('Window Class Name:' + str( GetClassName(event.Window)))
#Log('Window Text:' + str( GetWindowText(event.Window)))
Log('WindowName:' + str(event.WindowName))
Log('Ascii:' + str( event.Ascii) + str( chr(event.Ascii)))
Log('Key:' + str( event.Key))
Log('KeyID:' + str( event.KeyID))
Log('ScanCode:' + str( event.ScanCode))
Log('Extended:' + str( event.Extended))
Log('Injected:' + str( event.Injected))
Log('Alt' + str( event.Alt))
Log('Transition' + str( event.Transition))
Log('---')
# return True to pass the event to other handlers
# return False to stop the event from propagating
return True
# create the hook mananger
hm = pyHook.HookManager()
# register two callbacks
hm.MouseAllButtonsDown = OnMouseEvent
hm.KeyDown = OnKeyboardEvent
# hook into the mouse and keyboard events
hm.HookMouse()
hm.HookKeyboard()
if __name__ == '__main__':
import pythoncom
pythoncom.PumpMessages()
봄날의 곰... -GOM-
레오폴드 FC750R 갈축
레오폴드 FC660C 승화
더키 Shine 3 단무지 에디션 풀배열 갈축
.
.
.
And now...
Happy Hacking Professional 2 Type-S,
Majestouch Filco Minila air 정각 흑축 Bluetooth Edition,
Leopold FC660M White 무각인 흑축
Leopold FC750R White 정각 흑축
TEX YODA Coming soon...
좋은정보 감사합니다.~