当前位置: 首页> 汽车> 时评 > 中信建设有限责任公司刚果金_购物网页html代码_网站推广计划方法_营销策划与运营方案

中信建设有限责任公司刚果金_购物网页html代码_网站推广计划方法_营销策划与运营方案

时间:2025/7/9 4:27:53来源:https://blog.csdn.net/qq_39124701/article/details/145911043 浏览次数: 0次
中信建设有限责任公司刚果金_购物网页html代码_网站推广计划方法_营销策划与运营方案

一、ps1脚本

文件名:KeyboardCheck.ps1

Function WaitForKeyPress($TimeoutInSeconds) {$KeyPressed = $false$deadline = (Get-Date).AddSeconds($TimeoutInSeconds)# 显示提示信息Write-Host "请在 $TimeoutInSeconds 秒内按下任意键(长时间没有检测到按下按键会被认为键盘可能有问题)" -ForegroundColor Blue# 使用 ReadKey 和 Sleep 来实现等待while ((Get-Date) -lt $deadline -and !$KeyPressed) {if ([Console]::KeyAvailable) {# 按键被按下了$key = [Console]::ReadKey($true)  # $true 表示不显示按键Write-Host "检测到按键 '$($key.KeyChar)' ($($key.Key))" -ForegroundColor Green$KeyPressed = $true} else {Start-Sleep -Milliseconds 100  # 延迟 100 毫秒}}if ($KeyPressed) {Write-Host "在 $TimeoutInSeconds 秒内按下了按键。"} else {Write-Host "$TimeoutInSeconds 秒内没有按键!你的键盘可能有问题!" -ForegroundColor Red}# 返回是否检测到按键的值return $KeyPressed
}Function ExitWithCountdown {param ([int]$Seconds = 10  # 默认倒计时时间为10秒)Write-HostWrite-Host "脚本将在 $Seconds 秒后自动关闭窗口" -ForegroundColor Magentafor ($i = $Seconds; $i -gt 0; $i--) {Write-Host -NoNewline "`r正在退出... {$i}秒后关闭窗口..."Start-Sleep -Seconds 1}
}# 获取5秒内是否按下了任意键
$IsKeyPressed = WaitForKeyPress -TimeoutInSeconds 5# 根据 $IsKeyPressed 的值调用 cmd.exe
if ($IsKeyPressed) {Start-Process -FilePath "cmd.exe" -ArgumentList "/c echo cmd_t" -NoNewWindow -Wait
} else {Start-Process -FilePath "cmd.exe" -ArgumentList "/c echo cmd_f" -NoNewWindow -Wait
}# 延迟退出
ExitWithCountdown

二、开机自启动

打开路径:%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup
将下面的代码保存到名为start_KeyboardCheck.bat的文件中
(代码中的文件路径自行修改)

@echo offecho.
echo ScriptPath:%~dp0set "ps1Path=C:\MyScript\KeyboardCheck.ps1"if exist "%ps1Path%" (echo File "%ps1Path%" existsPowerShell -NoLogo -ExecutionPolicy Bypass -File "%ps1Path%"
) else (echo File "%ps1Path%" does not exist, please check the path!pause
)

三、效果

在这里插入图片描述

四、有什么用

额*****,没啥用,配合这个知乎贴如何禁用笔记本自带键盘?,免得真的没键盘用😓

关键字:中信建设有限责任公司刚果金_购物网页html代码_网站推广计划方法_营销策划与运营方案

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: