How Do I Interrupt a Program Run from Cmd?

How Do I Interrupt a Program Run from Cmd?

I am trying to get into C programming, but the larger the project get, the more often I want to interrupt programs I run from CMD. Usually when running for example Python from the CMD, I can interrupt the script using CTRL+C. This however does not work. I have seen people say you can use CTRL+BREAK/PAUSE, but my keyboard does not have those keys.

Is there any way I could interrupt C programs I run from CMD? Maybe using a custom keybind (to tell CMD CTRL+C is the same as CTRL+BREAK)?

4 Answers

If the CTRL + C doesn't work for you, use the CTRL + break, you should find break somewhere around your page up and pause keys, depending on what type of keyboard you're using. But CTRL + break usually works or even ESC

4

You can use AutoHotkey to make Ctrl+C send Ctrl+Break instead - or to have it send both - only in Command Prompt.

Here are AutoHotkey scripts for both:

  • Ctrl+C sends only Ctrl+Break:

    #IfWinActive, Command Prompt
    ^c::^CtrlBreak
    
  • Ctrl+C sends both Ctrl+Break and Ctrl+C:

    #IfWinActive, Command Prompt
    ~^c::^CtrlBreak
    

The tilde (~) makes the key retain also its original function. To use, simply install the program, put the script you want in a file and run it.

1

CTRL+C should work as long as it is a command shell / window, i use CTRL+C to stop CMD processes and batch files, problem is sometimes it asks if you want to exit in a app specific way (eg: Batch = "Terminate batch job (Y/N)?"),then when you type "y" it exits so because i would not recommend this if you are debugging your'e C file. however i believe there are programs to edit key binds and / or bind a certan key to somthing (eg numpad7 = windows+R) ill have a look into it and edit this later on.

EDIT:

ive found this wich may be useful: i don't know if it will work but its the best one i could find. hope this helps

Ctrl + Fn + S

If your notebook doesn't have a Break key (Dell Latitude 3490 for example).

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Robert Thorne
Author

Robert Thorne

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.