Clear windows command prompt screen using keyboard shortcuts

128

20

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

Ishan

Posted 2013-04-20T05:44:10.247

Reputation: 2 752

8If 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 – 2013-04-20T13:03:15.133

Answers

161

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.

mehdi

Posted 2013-04-20T05:44:10.247

Reputation: 1 719

3in powershell you can use also clear – binary_runner – 2014-12-09T12:23:40.153

I think I understand why people like to alias clear in linux to cls for the consistency between systems! – Roy Ling – 2015-11-04T05:40:37.440

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

petermeissner

Posted 2013-04-20T05:44:10.247

Reputation: 354

You might want to use SendInput

– user2418306 – 2016-02-19T11:57:25.427

1Also #IfWinActive Command Prompt will prevent overriding shortcuts for other console applications like bash – user2418306 – 2016-02-19T12:11:18.900

must say, this makes me smile every time I use it. TY @petermeissner – Mark Nadig – 2016-04-22T15:58:37.957

Doing SendInput {Escape} before SendInput cls{Enter} makes sure the line gets cleared before adding the cls command. – Karlsson – 2019-07-26T10:53:27.993

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

RAJA

Posted 2013-04-20T05:44:10.247

Reputation: 11