import ctypes,time
KEYEVENTF_UNICODE = 0x0004
KEYEVENTF_KEYUP = 0x0002
def PressKey(KeyUnicode):
extra = ctypes.c_ulong(0)
ii_ = Input_I()
ii_.ki = KeyBdInput( 0, KeyUnicode, KEYEVENTF_UNICODE, 0, ctypes.pointer(extra) )
x = Input( ctypes.c_ulong(1), ii_ )
ctypes.windll.user32.SendInput(1, ctypes.pointer(x), ctypes.sizeof(x))
def ReleaseKey(KeyUnicode):
extra = ctypes.c_ulong(0)
ii_ = Input_I()
ii_.ki = KeyBdInput( 0, KeyUnicode, KEYEVENTF_UNICODE|KEYEVENTF_KEYUP, 0, ctypes.pointer(extra) )
x = Input( ctypes.c_ulong(1), ii_ )
ctypes.windll.user32.SendInput(1, ctypes.pointer(x), ctypes.sizeof(x))
def PressAltTab():
ctypes.windll.user32.keybd_event(0x12, 0, 0, 0) #Alt
ctypes.windll.user32.keybd_event(0x09, 0, 0, 0) #Tab
time.sleep(2) #optional : if you want to see the atl-tab overlay
ctypes.windll.user32.keybd_event(0x09, 0, 0x0002, 0) #~Tab
ctypes.windll.user32.keybd_event(0x12, 0, 0x0002, 0) #~Alt
PressAltTab()
This works for ALT
+TAB
, at PressAltTab()
you see ctypes.windll.user32.keybd_event(0x12, 0, 0, 0)
, just find the right numbers for ctrl
and delete
. As you see alt
is 0x12
However, ctrl+alt+del is a special shortcut, there might be security reasons to block it from fake-pressing. At least that's what I saw in the forums.