Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.