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
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
在TIMER里面用这个函数监视就是了
VB只能够检测到一部分窗口类型,win7下的窗口vb是检测不到的。