124

Is there any way of clearing the command prompt screen in windows using keyboard shortcuts?

  • 7
    If keyboard shortcuts are a must for some reason you can always cook up an AutoHotkey script that sends cls<Enter> to the open command prompt window. – Karan Apr 20 '13 at 13:03
157

NO, But you can use CLS command to clear the whole screen, Esc (Escape) key will clear the input line. In addition, pressing Ctrl + C will move the cursor to a new blank line.

  • 3
    in powershell you can use also clear – binary_runner Dec 9 '14 at 12:23
  • I think I understand why people like to alias clear in linux to cls for the consistency between systems! – Roy Ling Nov 4 '15 at 5:40
22

If you really really want to do that with a keyboard shortcut (myself included) you might turn to using autohotkey and write a little script like this:

; -------------------------------------------------------------------------
; Cntr-L should clear screen
; -------------------------------------------------------------------------
#IfWinActive ahk_class ConsoleWindowClass
^L::
Send cls{Enter}
return

#IfWinActive

what the script does ...

  • first look if one is within console application
  • if CTRL+L is pressed
  • write cls to the console and then hit ENTER
  • You might want to use SendInput – user2418306 Feb 19 '16 at 11:57
  • 1
    Also #IfWinActive Command Prompt will prevent overriding shortcuts for other console applications like bash – user2418306 Feb 19 '16 at 12:11
  • must say, this makes me smile every time I use it. TY @petermeissner – Mark Nadig Apr 22 '16 at 15:58
  • Doing SendInput {Escape} before SendInput cls{Enter} makes sure the line gets cleared before adding the cls command. – Karlsson Jul 26 at 10:53
1

So long i also research but found best way to achieve this by defining Doskey Macro

i defined macro like this

doskey 1=cd\ $T cls

this will do two things by simple writing 1 and hit enter

  1. Bring you on clean Command route
  2. Clear entire screen

Note: you can add multiple desire command under one macro by separating them with $T

protected by Community Oct 11 '17 at 14:40

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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