Hook安裝
哇 這東西可真費勁 主要有pyhook和pyhook3 兩種 每個都要根據系統版本和python版本 分成各種小版本
具體安裝
一.可以在cmd 中輸入 pip install pyhook 來嘗試自動在線安裝 一般都不行
二.可以去https://www.lfd.uci.edu/~gohlke/pythonlibs/ 中尋找自己喜歡的版本
- pyHook‑1.5.1‑cp27‑cp27m‑win32.whl 代表 pyHook的1.5.1版本 適用於python2.7版本 windows32位
- pyHook‑1.5.1‑cp27‑cp27m‑win_amd64.whl 代表 pyHook的1.5.1版本 適用於python2.7版本 windows64位
然后下載
在cmd中輸入 pip install 將剛下載的*.whl文件拖入cmd 回車安裝
三.去https://sourceforge.net 里面搜 或許有自動安裝包 不過python有注冊表問題 安裝中會報錯 “沒有找到該python版本” 復制下面的代碼 保存為*.py 運行一下即好
# # script to register Python 2.0 or later for use with win32all # and other extensions that require Python registry settings # # written by Joakim Loew for Secret Labs AB / PythonWare # # source: # http://www.pythonware.com/products/works/articles/regpy20.htm # # modified by Valentine Gogichashvili as described in http://www.mail-archive.com/distutils-sig@python.org/msg10512.html import sys from _winreg import * # tweak as necessary version = sys.version[:3] installpath = sys.prefix regpath = "SOFTWARE\\Python\\Pythoncore\\%s\\" % (version) installkey = "InstallPath" pythonkey = "PythonPath" pythonpath = "%s;%s\\Lib\\;%s\\DLLs\\" % ( installpath, installpath, installpath ) def RegisterPy(): try: reg = OpenKey(HKEY_CURRENT_USER, regpath) except EnvironmentError as e: try: reg = CreateKey(HKEY_CURRENT_USER, regpath) SetValue(reg, installkey, REG_SZ, installpath) SetValue(reg, pythonkey, REG_SZ, pythonpath) CloseKey(reg) except: print "*** Unable to register!" return print "--- Python", version, "is now registered!" return if (QueryValue(reg, installkey) == installpath and QueryValue(reg, pythonkey) == pythonpath): CloseKey(reg) print "=== Python", version, "is already registered!" return CloseKey(reg) print "*** Unable to register!" print "*** You probably have another Python installation!" if __name__ == "__main__": RegisterPy()
四.如果安裝了多個版本python 在cmd時只會顯示一種,這樣pip安裝不能指向所需要的版本,就需要更改環境變量Path,刪掉不需要的版本即可,同時一定記得備份該數據。如果在更改完使用一些基本cmd命令無效,如ipconfig 需要在環境變量Path頭部添加《c:\windows\system32;》 去掉書名號
----
最重要的是由於python3.7的hook 不能抓有中文標題的窗口 被我放棄了
----
python 安裝了太多版本 charm里面都混亂了 在執行測試的時候一直報“ImportError: DLL load failed: 找不到指定的模塊” 我一直以為安裝的版本 不對或者沒安裝到位
最后發現是charm里面並沒有選對 合適python ~.~
