bat 脚本打印输出彩色文字

要在 Windows 批处理脚本中打印彩色内容,通常的方式是 echo [32mHello World[0m,但这种方式需要输入特殊字符 ESC(ASCII 码为 27),我试过 Alt+027 的快捷键却怎么也打不出来这个字符,而且这种方式各个颜色的编码也很不好记,分享一种更简单的方法!

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/write-host

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
powershell -Command "Write-Host 'This is Black' -ForegroundColor White -BackgroundColor Black"
powershell -Command "Write-Host 'This is DarkBlue' -ForegroundColor White -BackgroundColor DarkBlue"
powershell -Command "Write-Host 'This is DarkGreen' -ForegroundColor White -BackgroundColor DarkGreen"
powershell -Command "Write-Host 'This is DarkCyan' -ForegroundColor White -BackgroundColor DarkCyan"
powershell -Command "Write-Host 'This is DarkRed' -ForegroundColor White -BackgroundColor DarkRed"
powershell -Command "Write-Host 'This is DarkMagenta' -ForegroundColor White -BackgroundColor DarkMagenta"
powershell -Command "Write-Host 'This is DarkYellow' -ForegroundColor White -BackgroundColor DarkYellow"
powershell -Command "Write-Host 'This is Gray' -ForegroundColor Black -BackgroundColor Gray"
powershell -Command "Write-Host 'This is DarkGray' -ForegroundColor White -BackgroundColor DarkGray"
powershell -Command "Write-Host 'This is Blue' -ForegroundColor White -BackgroundColor Blue"
powershell -Command "Write-Host 'This is Green' -ForegroundColor White -BackgroundColor Green"
powershell -Command "Write-Host 'This is Cyan' -ForegroundColor Black -BackgroundColor Cyan"
powershell -Command "Write-Host 'This is Red' -ForegroundColor White -BackgroundColor Red"
powershell -Command "Write-Host 'This is Magenta' -ForegroundColor White -BackgroundColor Magenta"
powershell -Command "Write-Host 'This is Yellow' -ForegroundColor Black -BackgroundColor Yellow"
powershell -Command "Write-Host 'This is White' -ForegroundColor Black -BackgroundColor White"

其中单引号内是打印的文字内容,ForegroundColor 参数传文字颜色,BackgroundColor 参数传背景颜色,直接传颜色名字,非常方便。

阅读更多

解决 Windows 任务栏 bug,鼠标悬停效果在鼠标离开任务栏后依旧存在

鼠标移过任务栏后,明明鼠标早已经离开任务栏了,但是任务栏程序还是保持在鼠标悬停在上面的状态,一直都是这样,重启电脑或者重启资源管理器才可以解决问题,但是重启资源管理器又会导致一部分任务栏图标消失,很烦。

这个 bug 从 Windows 7 延续到 Windows 10,包括 Windows Server,依然没有解决,Windows 11 的任务栏大改,似乎解决了,但 Windows 11 的资源管理器卡顿问题更让人苦恼……

阅读更多

常用多媒体软件的开源或免费替代

以下软件,除 FFmpeg 外,均支持中文。

屏幕录像

开源:OBS(直播推流软件,录屏功能也非常强大)
收费:Bandicam(收费录屏软件中自认为最好用的)

屏幕录像(GIF)

开源:ScreenToGif

图片处理

免费:XnViewMP(图片批处理功能非常好用,商用收费)

图片编辑

开源:GIMP(GNU 出品)
收费:Adobe Photoshop(Ps)

视频剪辑

免费:Avidemux(用于简单的剪辑、合并,处理速度极快)
开源:Shotcut(同事推荐)
免费:DaVinci Resolve(有收费版,免费版足矣)
收费:Adobe Premiere(Pr)

阅读更多

把 Win11 的文件资源管理器改回 Win10 的 Ribbon 风格

Windows 11 快速预览通道经过几个小版本更新后,修复了不少 bug,已经成为了我的主力系统。但是,作为平常使用最多的文件资源管理器,其新界面对性能的影响很大,尤其是在使用方向键切换选中的文件的时候,卡顿感严重。经过一番搜索,我找到了改回 Ribbon 风格文件资源管理器的方法,后者更稳定,性能更好。

阅读更多