VBS脚本像屏幕保护程序一样检测空闲时间

时间:2016-05-05 16:20:32

标签: vbscript screensaver

我想知道如何在vbs中创建一个空闲时间计数器,比如屏幕保护程序,所以当空闲时间执行时说10分钟,它启动我的屏幕保护程序并将其重置为0.当鼠标移动时,我也想要它结束了屏幕保护程序,我认为它可以在任务管理器中命名cmd.exe结束procces(屏幕保护程序在cmd中运行)这是我到目前为止所做的,并提前谢谢

Const strComputer = "." 
Dim objWMIService, colProcessList
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Dim StartTime, EndTime, Elapsed

StartTime = Timer

Elapsed = Timer - StartTime

for each Process in Service.InstancesOf ("Win32_Process")

If Timer > 1000 Then
If Process.Name = "cmd.exe" then
sleep 0
else
createObject("WScript.Shell").Run "screensaver.bat"
if (mouse move)                                                *NOT DONE*
   Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'cmd.exe'")
  For Each objProcess in colProcessList 
    objProcess.Terminate() 

StartTime = 0
EndTime = 0
Elapsed = 0
Timer = 0
end if
next


   Set colProcessList = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = 'Process.exe'")
  For Each objProcess in colProcessList 
    objProcess.Terminate() 

  Next  

0 个答案:

没有答案