Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import win32api,time
- LOGFILE="mouseLog.txt"
- slp=0.5
- mouseLeft=1
- mouseRight=2
- mouseMiddle=4
- counter=0
- autosv=10
- try:
- with open(LOGFILE) as f:
- log=f.read()
- except:
- print "Log file not found, making one..."
- with open(LOGFILE,"w") as f:
- f.write("")
- log=""
- try:
- while True:
- MLV = win32api.GetKeyState(mouseLeft)
- MRV = win32api.GetKeyState(mouseRight)
- MMV = win32api.GetKeyState(mouseMiddle)
- print "%s %s %s \r"%(MLV,MMV,MRV),
- time.sleep(slp)
- counter+=1
- log+="%s: %s\t%s\t%s\n"%(time.ctime(time.time()),MLV,MMV,MRV)
- if not counter%autosv:
- with open(LOGFILE,"w") as f:
- f.write(log)
- except KeyboardInterrupt:
- with open(LOGFILE,"w") as f:
- f.write(log+"***%s: Interrupted\n"%(time.ctime(time.time())))
- raise KeyboardInterrupt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement