Skip to content Skip to sidebar Skip to footer

Toggle Scroll Lock When Screensaver Activates

I wish to make an application that runs in the background at all times in windows that toggles scroll lock when my computer's screensaver enables, then toggle it back after it disa

Solution 1:

The result of a WMI query reflects the state when the query was run. It doesn't automatically refresh and thus won't pick up any processes that were launched after its initial run. Move the query inside the outer loop so it's re-run with every iteration:

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Do
  WScript.Sleep 300
  Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process")
  For Each objProcess In colProcesses
    If Right(objProcess.Name, 4) = ".scr" Then
      wshShell.SendKeys "{SCROLLLOCK}"
    End If 
  Next
Loop

Post a Comment for "Toggle Scroll Lock When Screensaver Activates"