Is it possible to make Ctrl+C act like Ctrl+Break in the Windows 7 cmd.exe
console?
By default Ctrl+C seems to only send a signal the next time the input buffer is read, where Ctrl+Break sends a signal immediately.
This makes Ctrl+C useless for ending processes because when I want to end a process I want to end it immediately.
I'm using Ctrl+Break for now but it's far harder to type.
It looks like in DOS you can add BREAK=ON
to CONFIG.SYS
to achieve this, but not in Windows 7?
Best Answer
There's no setting that I know of, but you can accomplish this with an AutoHotkey script.
The script
How it works
^c
specifies the key combination to modify: Ctrl + C (^
indicates Ctrl).WinGetClass, WinClass, A
stores the active window's title in the variableWinClass
.if(WinClass = "ConsoleWindowClass") ... else ...
checks ifWinClass
macthes the stringConsoleWindowClass
(the window class of the Windows 7 command prompt).If it does,
SendPlay ^{CtrlBreak}
simulates the key combination Ctrl + Break.Otherwise,
SendPlay ^c
simulates the key combination Ctrl + C.This way, other programs still behave as they should.
How to use
Download and install the latest version of AutoHotkey.
Save the above script as
break-on.ahk
, using your favorite text editor.Double-click the file to run the script.
If you wish, copy the script (or a link to it) in the
Startup
folder.