Use CTRL + D to exit and CTRL + L to cls in Powershell console

前端 未结 6 1590
说谎
说谎 2021-02-01 13:13

I am trying to make

CTRL + D - exit Powershell console

and

CTRL + L - clear the screen

like in bash.

6条回答
  •  青春惊慌失措
    2021-02-01 13:48

    If you don't mind relying on an external program, you could do the following with AutoHotKey:

    #IfWinActive ahk_class ConsoleWindowClass
    ^L::SendInput , {Esc}cls{Enter}
    ^D::SendInput , {Esc}exit{Enter}
    #IfWinActive
    

    The above will work with the PowerShell or CMD console. Otherwise the only thing I can think of would be to work up some P/Invoke magic with SetWindowsHookEx.

    Edit: Fixed AutoHotkey script to pass through the shortcut keys to other programs.

提交回复
热议问题