I want to clear or automatically close popup windows through vbscript, but they may be different popup windows or may be a popup window within popup window. I am using a vbscript to create pop a window and I want a script which will automatically close all the popup windows. Below is the script which creates pop up windows and I want to close all these pop up windows through script.
Dim WshShell, BtnCode
Set WshShell = WScript.CreateObject("WScript.Shell")
BtnCode = WshShell.Popup("Do you like your job?", 7, "Answer This Question:", 4 + 32)
Select Case BtnCode
case 6 WScript.Echo "That's great!."
case 7 WScript.Echo "Sorry to hear that."
case -1 WScript.Echo "No Response?"
End Select
My solution to above code where it works partially:
Set wshShell = CreateObject("WScript.Shell")
Do
ret = wshShell.AppActivate("Answer this question")
If ret = True Then
wshShell.SendKeys "%Y"
Exit Do
End If
WScript.Sleep 500
Loop