|
9#
发表于 2023-6-3 11:55:21
来自手机
|
只看该作者
本帖最后由 duboy 于 2023-6-3 12:14 编辑
用 chatGPT 写了一个,不知能否可用,自行测试
=============================
@echo off
set timeout=7200
set count=0
:start
timeout /t 1 /nobreak >nul
set /a count+=1
if %count% equ %timeout% (
shutdown -s -t 30 -f
goto end
)
rem 检测键盘和鼠标是否有动
for /f "tokens=1,2" %%a in ('powershell "(Get-WmiObject -cn localhost win32_keyboard).NumberOfFunctionKeys, (Get-WmiObject -cn localhost win32_mouse).NumberOfButtons"') do set KB=%%a&set MS=%%b
if %KB% gtr 0 (
set count=0
)
else if %MS% gtr 0 (
set count=0
)
else (
echo Waiting for %timeout% seconds...
goto start
)
:end
pause>null
|
|