powershell控制键盘 保存为.ps1
#$shell = New-Object -com "Wscript.Shell"
$shell = New-Object -ComObject Wscript.Shell
# 按键(推荐使用不常用按键)
$key = "{NUMLOCK}" # NUMLOCK
#$key = " " # 空格
#$key = "^" # CTRL
#$key = "{TAB}" # TAB
# 循环执行
while($True){
# 间隔50秒
Start-Sleep -Seconds 5
# 打印执行日志
$time = Get-Date
Write-Output "$time Run sendkeys : $key"
# 执行按键
$shell.sendkeys($key)
}
vbs控制键盘 保存为.vbs
Set WshShell = WScript.CreateObject("WScript.shell")
WScript.Sleep 5000
WshShell.SendKeys "{NUMLOCK}"
WScript.Sleep 500
WshShell.SendKeys "{NUMLOCK}"
for i = 1 to 1800
WScript.Sleep 50000
WshShell.SendKeys "{NUMLOCK}"
WScript.Sleep 500
WshShell.SendKeys "{NUMLOCK}"
next