Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1. from pynput.keyboard import Listener as KeyboardListener
  2. from pynput.mouse import Listener as MouseListener
  3. from pynput.keyboard import Key
  4. import logging
  5.  
  6.  
  7.  
  8.  
  9.  
  10. def on_click(x, y, button, pressed):
  11.     print("Mouse pressed")
  12.  
  13.     with open('macrorecorder.txt', 'a') as f:
  14.         f.write('\n''mouse.position = ''({0}, {1})''\n''mouse.click({2}, 1)'.format(x, y, button, pressed))
  15.        
  16.  
  17.  
  18. def on_press(key):
  19.     keyCapture = '{0} pressed'.format(key)
  20.     print(keyCapture)
  21.  
  22.     with open('macrorecorder.txt', 'a') as f:
  23.         f.write('{}\n''keyboard.press('.keyCapture')'.format(key))
  24.        
  25.        
  26.      
  27.    
  28.  
  29. def on_release(key):
  30.     keyCapture = '{0} released'.format(key)
  31.     print(keyCapture)
  32.  
  33.     with open('macrorecorder.txt', 'a') as f:
  34.         f.write('{}\n''keyboard.release('.format(key))
  35.        
  36.     if key == Key.esc:
  37.         return False
  38.  
  39.  
  40. with MouseListener(on_click=on_click) as listener:
  41.         with KeyboardListener(on_press = on_press, on_release = on_release) as listener:
  42.             listener.join()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement