我正在尝试使用 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_input
或 SendInput
伪造。
您将需要使用 SendSAS
模拟 SAS 的 API 调用。请仔细阅读文档并确保您遵守此功能的严格要求。
关于Python ctypes keybd_event 模拟ctrl+alt+delete,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24030781/