check=False
def key_check():
global check
if key == esc: check=True
timer = 30
key_check.start()
while 1:
if check and timer > 10: sys.exit(1)
timer-=1
key_check.stop()
import win32gui
def now():
class_activ_window=win32gui.GetClassName(win32gui.GetForegroundWindow())
if class_activ_window=='my_console': # изменить на реальный класс окна
activ_window='my_consoler'
else:
pass
return activ_window
import get_activ_window
if key == esc and get_activ_window.now() == 'my_console':
check=True