Python ctypes keybd_event simulate ctrl+alt+delete

依然范特西╮ 提交于 2019-12-14 01:42:43

问题


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

回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/24030781/python-ctypes-keybd-event-simulate-ctrlaltdelete

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!