First, Pyuserinput installation
The python3.5 Pymouse and Pykeyboard modules are integrated into the Pyuserinput module. In python3.5, the Pyuserinput module can be installed directly
Installation of Pywin32 and Pyhook modules prior to pyuserinput module installation
PYWIN32 module is installed by default
The Pyhook module can be downloaded from here
http://www.lfd.uci.edu/~gohlke/pythonlibs/
Find a lot of Pyhook on the Python website is not available for python3.5 version
Pyuserinput Module
Https://github.com/PyUserInput/PyUserInput
Ii. Methods of Use
Import Module
Import Pymouse,pykeyboard,os,sys from Import *fromimport Pykeyboard
Define an instance individually
m = Pymouse ()
K = Pykeyboard ()
Mouse Operation:
M.click (x,y,button,n) – Mouse click
x,y– is the coordinate position
Buttong–1 means left button, 2 means right click
n – Clicks, default is 1 times, 2 means double click
M.move (x, y) – Mouse moves to coordinates (x, y)
X_dim, Y_dim = M.screen_size () – Get screen size
Keyboard operation:
K.type_string (' Hello, world! ') – Analog keyboard input string
K.press_key (' h ') – Analog keyboard Press H key
K.release_key (' h ') – Analog keypad release H key
K.tap_key ("H") – Analog click H key
K.tap_key (' h ', n=2,interval=5) – Analog-click H-Key, 2 times, 5 seconds per interval
K.tap_key (K.function_keys[5]) – Click the function key F5
K.tap_key (k.numpad_keys[5],3) – Tap Numpad 5, 3 times
Joint key Simulation
For example, pressing ALT + TAB keyboard
K.press_key (K.alt_key) – Hold down the ALT key
K.tap_key (K.tab_key) – Click the TAB key
K.release_key (K.alt_key) – Release the ALT key
[python3.5] [Pyuserinput] simulating mouse and keyboard simulations