TypeError: MouseSwitch() missing 8 required positional arguments: 'msg', 'x', 'y', 'data', 'flags', 'time', 'hwnd', and 'window_name'
当鼠标焦点所在的窗口名包含非ascii码,比如中文是unicode编码,转码就会出现问题,不能获取到window_name,导致MouseSwitch()参数获取不全报的错。
因为pyHook是适配python2的,所以在python2上用不会有问题。
目前比较好的解决办法是把pyHook库改为PyHook3就能完美解决了。
期间我还按照https://blog.csdn.net/u014563989/article/details/77247659df所说进行安装配置,但最后虽然不报错,仍然没有效果,就是没有显示错误直接程序终止。
PyHook3安装要点:
我亲自安装了一遍,中间主要是vc++运行库安装时碰到了很多的坎,总的来说还是蛮容易的。
PyHook3安装主要就是两步:
第一步: swig安装;
第二步: Microsoft Visual C++ 14.0 is required问题解决;
这两步解决了之后直接pip install PyHook3就可以了。
第三部:安装PyHook3。
安装步骤根据如下:
swig安装方法:
我的资源仓库: 提取码:wk6o
解压即可。
我们把解压后的路径添加到系统变量Path里。


Microsoft Visual C++ 14.0安装
vc++14.0就是vc++2015。全称:Microsoft Visual c ++ 2015
我的仓库: 提取码:81gb ,可参考https://blog.csdn.net/qq_38161040/article/details/87929616
安装PyHook3
直接pip install PyHook3,安装即可
可能遇到的问题:
问题1:缺少swig支持

参考:
https://blog.csdn.net/qq_37193537/article/details/90721115
https://blog.csdn.net/qq_38161040/article/details/87920192
网友评论