Is there any way of clearing the command prompt screen in windows using keyboard shortcuts?
3 Answers
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.
-
4
-
1I think I understand why people like to alias
clear
in linux tocls
for the consistency between systems!– Roy LingNov 4, 2015 at 5:40 -
Typing 'cls' +
Enter
(Return) is 4 keystrokes. That's pretty close to the 2 or probably 3 you'd need for a keyboard shortcut.– DvaeerApr 29, 2021 at 10:05 -
@Dvaeer with a keyboard shortcut I could e.g. clear the terminal without removing the command I was typing - please don't assume there's only the one use case you can come up with– mcccOct 12, 2022 at 8:17
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
-
-
2Also
#IfWinActive Command Prompt
will prevent overriding shortcuts for other console applications like bash Feb 19, 2016 at 12:11 -
must say, this makes me smile every time I use it. TY @petermeissner Apr 22, 2016 at 15:58
-
2Doing
SendInput {Escape}
beforeSendInput cls{Enter}
makes sure the line gets cleared before adding the cls command.– KarlssonJul 26, 2019 at 10:53
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
- Bring you on clean Command route
- Clear entire screen
Note: you can add multiple desire command under one macro by separating them with $T
cls<Enter>
to the open command prompt window.