Skip to content Skip to sidebar Skip to footer

Python Crash With PyHook.HookManager() On KeyDown [ctrl]+[c]

I am creating a python script to record the keys that I press across my system (keylogger) and call home with information on what my typing habits are. I am new to python and I am

Solution 1:

In python, Ctrl+C throws a KeyboardInterrupt exception.

http://docs.python.org/2/library/exceptions.html#exceptions.KeyboardInterrupt


Solution 2:

If you want to catch KeyboardInterrupt exceptions, you could use a nested loop. This way when a KeyboardInterrupt occurs, the program exits only the inner loop.

while True:
    try:
        while True:
            pythoncom.PumpWaitingMessages()
    except KeyboardInterrupt:
        pass

Post a Comment for "Python Crash With PyHook.HookManager() On KeyDown [ctrl]+[c]"