简体   繁体   中英

How to clear screen in Windows command prompt window with a hotkey?

I have searched a lot to find a way (keyboard shortcut) to clear the screen of the console window of cmd on Windows 10. I tried Ctrl+L and Ctrl+K and ESC , but nothing worked for me and I didn't find any satisfied solution.

Thanks a lot for the AutoHotkey script.
I modified the script to input Python script to clear the screen when using scrapy shell like that

Send from os import system{Enter}
Send cls = lambda: system)'cls'({Enter}
Send cls)({Enter}

It worked well but I noticed the value 0 at the top of the window.

The console window after execution of AutoHotkey script with as blinking caret symbol.

0
>>> █

How can I remove that zero?

The simplest way of clear window in command prompt is typing: cls + enter

Ecs is a key to exit input of command prompt, it does noting on clear window

Ctrl + L and Ctrl + K are not correct short key in Linux command prompt. If you really want to make it a short cut key of cls, you can use AutoHotKey to write a short script

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

Official website of autohotkey: https://www.autohotkey.com/

Windows 10 + python 3.9 clear command prompt script: import os os.system('cls')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM