0

我一直在为一项任务而苦苦挣扎。我正在尝试使用该tasklist命令检测进程中的多个窗口。

解释一下:如果您打开了“notepad.exe”并单击“文件”→ “打开”,“notepad.exe”进程中将有 2 个窗口。(主窗口:“无标题 - 新文本文档”和名为“打开”的子窗口。

但是,当我运行时,tasklist /fi "windowtitle eq Open我没有得到任何结果。

是否有另一种方法可以批量检测子窗口或 VBScript?

4

1 回答 1

0

您需要与 Windows API 交谈。

Autohotkey 非常擅长快速执行此类操作,并且可以从批处理脚本中调用。

它包括一个名为 WinGet 的命令,可用于迭代打开的窗口。

http://www.autohotkey.com/docs/commands/WinGet.htm

以下是文档中用于迭代所有打开的窗口的示例。

; Example #2: This will visit all windows on the entire system and display info about each of them:
WinGet, id, list,,, Program Manager
Loop, %id%
{
    this_id := id%A_Index%
    WinActivate, ahk_id %this_id%
    WinGetClass, this_class, ahk_id %this_id%
    WinGetTitle, this_title, ahk_id %this_id%
    MsgBox, 4, , Visiting All Windows`n%a_index% of %id%`nahk_id %this_id%`nahk_class %this_class%`n%this_title%`n`nContinue?
    IfMsgBox, NO, break
}
于 2013-03-02T14:51:20.520 回答