vbs如何检测当前是否有标题为“XXXXX”的窗口

如果没有检测到符合的窗口,则循环检测,直到这个窗口出现为止
2026年09月17日 03:09
有3个网友回答
网友(1):

on error resume next
title="Form1" '窗口标题
Set ws = CreateObject("wscript.shell")
Set objWord = CreateObject("Word.Application")
Set colTasks = objWord.Tasks
do
Set colTasks = objWord.Tasks
if colTasks.exists("Form1") then
msgbox "窗口存在"
ws.run "tskill winword",0 '或者 objword.quit
wscript.quit
end if
wscript.sleep 1000
loop

网友(2):

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

在TIMER里面用这个函数监视就是了

网友(3):

VB只能够检测到一部分窗口类型,win7下的窗口vb是检测不到的。