Windows – Is it possible to make Ctrl+C as responsive as Ctrl+Break in the Windows 7 console

command lineconsolewindows 7

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

^c::
    WinGetClass, WinClass, A
    if(WinClass = "ConsoleWindowClass")
        SendPlay ^{CtrlBreak}
    else
        SendPlay ^c

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 variable WinClass.

  • if(WinClass = "ConsoleWindowClass") ... else ... checks if WinClass macthes the string ConsoleWindowClass (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

  1. Download and install the latest version of AutoHotkey.

  2. Save the above script as break-on.ahk, using your favorite text editor.

  3. Double-click the file to run the script.

  4. If you wish, copy the script (or a link to it) in the Startup folder.

Related Question