I\'ve done some research but I would like to be able to call control-alt-delete from python. If that is not possible is it possible to call it from command line because then I c
On reading OP's comments, his/her original need was to change the user's password. In fact, this can be done with:
from win32com import adsi
ads_obj = adsi.ADsGetObject("WinNT://localhost/%s,user" % username)
ads_obj.SetPassword(password)
As far as I know, Ctrl-Alt-Delete is protected for security reasons, so programs cannot use it. (At least in Windows 7 and before.)
If what you want to do is to shutdown or restart the system, Windows has a 'shutdown' command and linux's typically have 'shutdown' and 'reboot' commands.
Check out the following thread:
According to it, VNC uses something like this:
PostMessage HWND_BROADCAST, WM_HOTKEY, 0, MakeLong(MOD_ALT Or MOD_CONTROL, VK_DELETE)
I suspect you would need to use ctypes or PyWin32 to do something like this. I would probably go with ctypes since it's cross-platform, however, even with ctypes you would probably need to write a special method for each OS that you support.
You surely mean activating the Windows Security window. In this case:
import win32com.client
shell = win32com.client.Dispatch("WScript.Shell")
shell.SendKeys("^(%{DELETE})")
UPDATE
The above code seems not to work because of the reasons described in other posts. In that case, the alternative is to create a similar window and call from Python the different programs/functions called by the real Windows Security window.
On reading OP's comments to the original question, OP's final need is to change a user's password. This can be done with:
from win32com import adsi
ads_obj = adsi.ADsGetObject("WinNT://localhost/%s,user" % username)
ads_obj.SetPassword(password)
I just tested this in my PC, so is final information (though not necessarily correct; this is up to the OP :-) ).
UPDATE 2: Copying the later as a separate answer as comments seem to indicate that all of the answer doesn't work. This is correct for the SendKeys
proposition, which doesn't work.
You can use vncdotool library At:
lib
And use vncdotool by:
os.system("vncdotool key ctrl-alt-del")