PyUserInput操作说明
今天想试一下通过python来模拟键盘和鼠标
PS C:\Users\LiGang> pip install pyuserinput
Collecting pyuserinput
Collecting pyHook (from pyuserinput)
Could not find a version that satisfies the requirement pyHook (from pyuserinput) (from versions: )
No matching distribution found for pyHook (from pyuserinput)
看来没法自动安装pyHook,于是求助万能的http://www.lfd.uci.edu/~gohlke/pythonlibs/,有pyHook,下载后进行安装
pip install C:\Users\LiGang\Downloads\pyHook-1.5.1-cp35-cp35m-win_amd64.whl
顺利装上了,再继续安装pyuserinput,这次提示需要pywin32库,这库也是不能pip自动安装,继续求助上面的网站,谢天谢地,依然有这个库,但是在下载链接前面有一句说明:
To install pywin32 system files, run python.exe Scripts\pywin32_postinstall.py -install from an elevated command prompt.
先下载安装,然后切到python安装目录,执行上面的命令
PS C:\Python35> python.exe Scripts\pywin32_postinstall.py -install
结果报错,说权限不够,于是退出控制台,改为管理员身份运行,这次成功了。
按简书上的示例测试了一下:
x_dim, y_dim = m.screen_size()
m.click(x_dim/2, y_dim/2, 1)
k.type_string('Hello, World!')
1
2
3
问题出在/2上面,变成浮点数了,改成//2就好了。