Skip to content

Instantly share code, notes, and snippets.

@sudot
Created October 4, 2025 03:06
Show Gist options
  • Select an option

  • Save sudot/ce1729caae9de54097b14d9645ab6317 to your computer and use it in GitHub Desktop.

Select an option

Save sudot/ce1729caae9de54097b14d9645ab6317 to your computer and use it in GitHub Desktop.
防止电脑自动锁屏
' 点击键盘滚动键版本
Const keyString = "{SCROLLLOCK}"
Set vbObj = WScript.CreateObject("WScript.Shell")
Do While True
vbObj.SendKeys keyString
' 间隔300毫秒再按一次,还原键盘状态
WScript.Sleep 300
vbObj.SendKeys keyString
' 锁屏时间是 3 分钟,此处设定提前 3 秒按下键盘
WScript.Sleep 1000 * (60 * 3 - 3)
Loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment