循环浏览打开的 Windows 应用程序 [英] Cycle through open Windows applications
问题描述
我需要一些帮助,以了解如何处理起初看起来非常简单的要求.
I need some help on which way to go with something that seemed at first like a very simple requirement.
我必须找到一种在 Windows PC 上循环浏览打开的应用程序的方法,目的是在安装在墙上的大屏幕上每次显示窗口 30 秒.通常会有一个 MS Access 报告和几个网页.
I have to find a method of cycling through open applications on a Windows PC, with the objective of displaying the windows for say 30 seconds at a time on a large screen mounted on a wall. Typically there will be an MS Access report and a couple of web pages.
我最初的想法是我可以在 PC 上手动打开这些应用程序,然后运行 VBScript 来循环浏览它们.然而,这有两个问题.
My initial thinking was that I could open these apps manually on the PC, then run a VBScript to cycle through them. However there were two problems with this.
- 模拟 Alt+Tab 按键只会切换两个最最近使用过的应用,而不是循环浏览所有应用,并且
- 我无法看到用户能够使用按键退出脚本.
谁能建议我如何使用 Windows(XP 以上)机器上已有的资源来实现这一目标?
Can anyone suggest how I can achieve this using resources already available on a Windows (XP upwards) machine?
推荐答案
结果证明 WHS 中的 VBScript 是要走的路.这似乎有效.
Turned out VBScript in WHS was the way to go. This seems to work.
'****************************************************************************************
' Script Name: ApplicationCycler.vbs
' Author: Ian Burns
' Date: 2 Dec 2011
' 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 strComputer
Dim objWMIService
Dim colProcessList
Dim objProcess
Dim intSleep
' Loop lasts 5 seconds
intSleep = 5000
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
' Simulate the Alt+Esc keypress
wshShell.SendKeys "%+{Esc}"
Wscript.Sleep intSleep
Loop
Else
' It IS already running so kill any or all instances of it
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = 'WScript.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next
' Delete the environment variable
wshSystemEnv.Remove("AlreadyRunning")
' Tidy up
Set wshSystemEnv = Nothing
Set wshShell = Nothing
Set objWMIService = Nothing
Set colProcessList = Nothing
End If
这篇关于循环浏览打开的 Windows 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!