I'm working on a python script that captures user-entered keys. For that, I used the pyHook module. However, using the program, I noticed that every time the user presses Alt + Tab, an error occurs. The simplified version that synthesizes the part of my program in which the error occurs is as follows:
import pyHook,pythoncom
def teclado(event):
print(event.Key)
return True
hm=pyHook.HookManager()
hm.KeyDown=teclado
hm.HookKeyboard()
pythoncom.PumpMessages()
The code shows perfectly all the keys typed, however, pressing Alt + Tab causes the following error:
TypeError: KeyboardSwitch() missing 8 required positional arguments: 'msg', 'vk_code', 'scan_code', 'ascii', 'flags', 'time', 'hwnd', and 'win_name'
And the program closes. How can I avoid this error by preserving the Alt + Tab function in windows?