'****************************************************************************************
' Script Name: ApplicationCycler.vbs
' Author: Ian Burns
' Date: 2 Dec 2011
' Edited By: Makaveli84
' Edit Date: 30 Aug 2014
' Description: VBScript for Windows Scripting Host. Cycles through any applications
' visible in the Task Bar giving them focus for a set period.
' Usage: Save file to Desktop and double click to run. If it isn't already running,
' it will start. If it is already running, it will stop.
'*****************************************************************************************
Option Explicit
Dim wshShell
Dim wshSystemEnv
Dim intCycle
Dim intSleep
Dim intTimer
' Cycle every 5 seconds / Check on/off status every 250 milliseconds
intCycle = 5000: intSleep = 250: intTimer = intCycle
Set wshShell = CreateObject("WScript.Shell")
' Volatile environment variables are not saved when user logs off
Set wshSystemEnv = wshShell.Environment("VOLATILE")
' Check to see if the script is already running
If len(wshSystemEnv("AlreadyRunning")) = 0 Then
' It isn't, so we set an environment variable as a flag to say the script IS running
wshSystemEnv("AlreadyRunning") = "True"
' Now we go into a loop, cycling through all the apps on the task bar
Do While len(wshSystemEnv("AlreadyRunning")) > 0
' Simulate the Alt+Esc keypress
If intTimer >= intCycle Then
wshShell.SendKeys "%+{Esc}"
intTimer = 0
End If
intTimer = intTimer + intSleep
Wscript.Sleep intSleep
Loop
Else
' Delete the environment variable
wshSystemEnv.Remove("AlreadyRunning")
End If
' Tidy up
Set wshSystemEnv = Nothing
Set wshShell = Nothing
Saturday, June 3, 2017
Cycle through open Windows applications
VBScript in WHS was the way to go.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment