Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.36 KB | None | 0 0
  1. import pyHook
  2. import pythoncom
  3. import time
  4. import datetime
  5.  
  6.  
  7.  
  8. def onclick(event):
  9.  
  10.     record = f"{event.Position}"
  11.  
  12.     recorded = str(record)
  13.     recorded = recorded.strip("(")
  14.     recorded = recorded.strip(")")
  15.     recorded = recorded.replace (" ", "")
  16.     recorded = recorded.split(",")
  17.    
  18.     print(recorded)
  19.    
  20.     recordedX = str(recorded[0:1])
  21.     recordedX = recordedX.strip("[")
  22.     recordedX = recordedX.strip("]")
  23.     recordedX = recordedX.strip("'")
  24.    
  25.     recordedY = str(recorded[1:])
  26.     recordedY = recordedY.strip("[")
  27.     recordedY = recordedY.strip("]")
  28.     recordedY = recordedY.strip("'")
  29.    
  30.     print(recordedX)
  31.     print(recordedY)
  32.     with open ("locations.txt", "a+") as location:
  33.         location.write(recordedX)
  34.         location.write("\n")
  35.         location.write(recordedY)
  36.         location.write("\n")
  37.     print (event.Position)
  38.    
  39.     result = datetime.datetime.now()
  40.     print (result)
  41.     delay_time = f"{result}"
  42.     delay_time = delay_time[11:19]
  43.     print (delay_time)
  44.     #record time elapsed to txt file
  45.     with open ("delay.txt", "a+") as delay:
  46.         delay.write(delay_time)
  47.         delay.write("\n")
  48.    
  49.     return True
  50.  
  51. hm = pyHook.HookManager()
  52. hm.SubscribeMouseAllButtonsDown(onclick)
  53. hm.HookMouse()
  54. pythoncom.PumpMessages()
  55. hm.UnhookMouse()
  56.  
  57.  
  58. #start timer on first click
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement