我正在尝试列出所有可见的窗口(名称和顶部)。 我的脚本运行良好,但需要安装Microsoft Word。 要执行我的脚本,您可以运行此命令
Cscript -B myScript.vbs
muScript.vbs:
Dim console
Set console = WScript.StdOut
Dim myString
myString = ""
Set Word = CreateObject("Word.Application")
Set Tasks = Word.Tasks
Set colTasks = Word.Tasks
For Each Task in Tasks
If Task.Visible Then
If colTasks.Exists(Task.Name) Then
myString = myString & "@@##@@" & colTasks(Task.Name).Name & ","& colTasks(Task.Name).Top
End If
End If
Next
Word.Quit
console.WriteLine myString
你知道如何在没有安装Microsoft Word的情况下列出像myScript.vbs这样的可见窗口吗?
非常感谢
答案 0 :(得分:0)
我不认为这是可能的。但是,您可以列出所有正在运行的进程。
http://www.computerperformance.co.uk/vbscript/wmi_process.htm
' Process.vbs
' VBScript Win32_Process to discover which processes are running
' Author Guy Thomas http://computerperformance.co.uk/
' Version 1.4 - December 2010
' -------------------------------------------------------'
Option Explicit
Dim objWMIService, objProcess, colProcess
Dim strComputer, strList
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process")
For Each objProcess in colProcess
strList = strList & vbCr & _
objProcess.Name
Next
WSCript.Echo strList
WScript.Quit
' End of List Process Example VBScript