Advertisement
Jmeel14

Useful Python Win32API shortcut scripts

Jan 2nd, 2016
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. import win32api, win32con
  2.  
  3. def key_press(key): # presses a key according to keycodes
  4.     win32api.keybd_event(key, 0, 2, 0)
  5.     win32api.keybd_event(key, 0, 1, 0)
  6.  
  7. def mouse_l_down(x,y): # left-mouse down
  8.     win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
  9.  
  10. def mouse_l_up(x,y): # left-mouse up
  11.     win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
  12.  
  13. def mouse_r_down(x,y): # right-mouse down
  14.     win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN,x,y,0,0)
  15.  
  16. def mouse_r_up(x,y): # right-mouse up
  17.     win32pi.mouse_event(win32con.MOUSEEVENTF_RIGHTUP,x,y,0,0)
  18.  
  19. def click(x, y): # left-clicks
  20.     mouse_l_down(x,y)
  21.     mouse_l_up(x,y)
  22.  
  23.  
  24. def rclick(x,y):  # right-clicks
  25.     mouse_r_down(x,y)
  26.     mouse_r_up(x,y)
  27.  
  28. def cursor_loc(): # finds the cursor's location
  29.     location = win32api.GetCursorPos()
  30.     return location
  31.  
  32. def set_cursor_loc(x,y): # sets the cursor's location
  33.     win32api.SetCursorPos((x,y))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement