0

我正在尝试列出所有可见的窗口(名称和顶部)。我的脚本运行良好,但需要安装 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 吗?

非常感谢

4

1 回答 1

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
于 2012-04-24T21:55:22.593 回答