How to catch the Sikuli keyboard interrupt Alt+Shift+C

Asked by Zebara

I want to know how to catch the Sikuli keyboard interrupt Alt+Shift+C for logging. This would allow me to close the logging file if I kill the Sikuli program with the keyboard interrupt.

I use the following to start and stop logging:

def startLogging(logger, hdlr, logName):
    # used to initialize & format a logfile for this module
    logger.addHandler(hdlr)
    logger.setLevel(logging.INFO)
    formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
    hdlr.setFormatter(formatter)
    logger.info("***** START: " + logName)
    return

def stopLogging(logger, hdlr, logName):
    # use to gracefully shutdown the logfile for this module
    logger.info("***** END: " + logName+"\n")
    logger.removeHandler(hdlr)
    hdlr.flush()
    hdlr.close()
    return

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

not possible, but you could add your own hotkey using Env.addHotkey()

Revision history for this message
Zebara (kbrennan56) said :
#3

Thanks RaiMan for the fast response! I will try adding a new Hotkey.