简体   繁体   中英

Python ctypes keybd_event simulate ctrl+alt+delete

I'm trying to simulate ctrl+alt+del with keybd_event but it doesn't do anything, stuff like ctrl+esc or alt+tab do work yet ctrl+alt+del won't work.

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 is a special key sequence, known as the secure attention sequence that, for security reasons, cannot be faked using keybd_input or SendInput .

You will need to use the SendSAS API call to simulate the SAS. Do read the documentation carefully do make sure that you adhere to the stringent requirements of this function.

That's a Windows security mechanism. CTRL + ALT + DEL is special. At least one justification is the "Press CTRL + ALT + DEL for login prompt" thing where by pressing it you make sure Windows is really asking for your password and not just some program masquerading as a Windows prompt.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM