Python ctypes keybd_event模拟ctrl + alt + delete

Sha*_*hay 3 python winapi ctypes keyboard-shortcuts

我正在尝试使用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
Run Code Online (Sandbox Code Playgroud)

Dav*_*nan 5

CTRL+ ALT+ DEL是一个特殊的密钥序列,称为安全注意序列,出于安全原因,不能使用keybd_input或伪造SendInput.

您需要使用SendSASAPI调用来模拟SAS.请仔细阅读文档,确保您遵守此功能的严格要求.