检测进程中的多个窗口

时间:2013-02-26 19:00:37

标签: windows batch-file cmd

我一直在努力完成任务。我正在尝试使用tasklist命令检测进程中的多个窗口。

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

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

是否有其他方法可以批量检测子窗口或VBScript?

1 个答案:

答案 0 :(得分: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
}