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 参数传背景颜色,直接传颜色名字,非常方便。

阅读更多

Android 强制锁定屏幕旋转方向

在使用我的一加平板时,一直被一个问题困扰,由于我的桌面电源在左手边,平板横着放在桌上时,如果需要充电,就需要将 Type-C 接口对准左侧,这就需要先解除旋转锁定,立起平板,待屏幕旋转后,打开旋转锁定,再放平。使其锁定在充电口朝左的横屏状态(技术上称为 SCREEN_ORIENTATION_REVERSE_LANDSCAPE,屏幕方向反横向)。

以前用 iPad Pro 时,我也是一直都这么干的,这倒也没啥,但更麻烦的问题来了。有些 APP 由于代码实现问题,会强制屏幕旋转至某个方向,例如在平板打开美团时,会自动切换到竖屏,打开苍雾世界时,会自动切换到充电口朝右的横屏,退出应用时又会自动切回来。于是当我需要以上场景使用这些 APP 时,必须拖着充电线把平板转来转去,不够大的桌面,不够长的充电线,加上 13 寸 1 斤重的平板,让这一切显得格外艰难。

阅读更多

将扣子空间生成的 jsx 格式网页部署到自己的服务器

扣子空间生成的网页是 jsx 格式的,在扣子空间内可以正常打开,如果想要部署到自己的服务器,则需要经过编译。

为此,我写了一个模板,只需将扣子空间生成的 jsx 重命名为 coze.tsx(注意后缀要改为 tsx)放入本项目 src 目录,即可编译出可静态部署的 dist 产物。

阅读更多

扣子空间邀请码

字节跳动出了一个类 Manus 的 AI Agent 工具,叫扣子空间,目前是邀请码内测机制,在此分享几个邀请码。

邀请码使用地址: https://space.coze.cn

用完记得评论说下已使用,如果邀请码都已使用,可以评论提醒我补充更多的邀请码。

阅读更多

Midscene.js:AI驱动的自动化测试工具

字节有一个很实用但不怎么火的项目,叫 Midscene.js,Chrome 商店上的安装数仅有 1 万,它是一个由多模态模型驱动的前端自动化测试插件。

Midscene.js 一共就三大 API:Action、Query、Assert

Action 交互

描述步骤并执行交互。例如,在 GitHub 上交互:查找 GitHub 上的 Twikoo 项目,点进详情页,点个 Star——

阅读更多