Page 1 of 1

Check for CTRL-C in a Console (Windows only)

Posted: Thu Oct 09, 2003 2:19 pm
by Rings
Code updated For 5.20+

Often it is usefull if the user press CTRL-C to abort a console-Programm.
This little Api-call do the trick form me, it installs a CallBack in the Console-Handler:

Code: Select all

OpenConsole()
ConsoleColor(14,0)
ConsoleLocate(10,12)
PrintN("PRESS CTRL-C to goto 'MyTest'")
SetConsoleCtrlHandler_(?MyTest,#true)

Repeat ;endless Loop
Delay(1)
ForEver

End

MyTest:
 Beep_(100,100)
 Beep_(200,100)
 CloseConsole()
 MessageRequester("Test","Hello, this is the end from CTRL-C",0)
End