Python ctypes keybd_event 模拟ctrl+alt+delete

标签 python winapi keyboard-shortcuts ctypes

我正在尝试使用 keybd_event 模拟 ctrl+alt+del,但它没有做任何事情,像 ctrl+esc 或 alt+tab 这样的东西可以工作,但 ctrl+alt+del 不会工作。

import ctypes
ctypes.windll.user32.keybd_event(0x11, 0, 0, 0) #CTRL is down
ctypes.windll.user32.keybd_event(0x12, 0, 0, 0) #ALT is down
ctypes.windll.user32.keybd_event(0x2E, 0, 0, 0) #DEL is down
ctypes.windll.user32.keybd_event(0x2E, 0, 0x0002, 0) #DEL is up
ctypes.windll.user32.keybd_event(0x12, 0, 0x0002, 0) #ALT is up
ctypes.windll.user32.keybd_event(0x11, 0, 0x0002, 0) #CTRL is up

最佳答案

CTRL + ALT + DEL 是一个特殊的键序列,称为 secure attention sequence出于安全原因,不能使用 keybd_inputSendInput 伪造。

您将需要使用 SendSAS模拟 SAS 的 API 调用。请仔细阅读文档并确保您遵守此功能的严格要求。

关于Python ctypes keybd_event 模拟ctrl+alt+delete,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24030781/

相关文章:

php - Apache2 access.log 对于相同的数据包不同

visual-studio - 使用简单的键盘快捷键进行 Visual Studio 注释和取消注释

eclipse - 如何在Eclipse中增量搜索中选择剩余的单词?

python - 使用点表示法从 Python 中的字典列表中获取特定数据

python - django 从 1.9 升级到 1.10 __init__() 得到意外的关键字参数 'current_app'

python - 在 Django 中使用 Python ZipStream 获取损坏的 zip

c++ - 如何在C++中获取线程的结果

c++ - 用 C++ 显示 latex 字符串

c# - 如何创建通用键盘快捷键?

python - 从哪个 Python 3 API 开始?