Micro Focus QTP (UFT) Forums
No.of Browsers & Close - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: No.of Browsers & Close (/Thread-No-of-Browsers-Close)



No.of Browsers & Close - bfakruddin - 01-27-2009

Hello Friends,

I develop this script... everything is okay but I am struggling to keep else part here please help me... Check it once and rectify my error..
If you give your site to close for eg "Yahoo", it is not opened here then it should show the popup or msgbox... eagerly waiting for reply

Code:
Dim bro
Set bro=description.Create
bro("micclass").value="Browser"

Set brow=desktop.ChildObjects(bro)
browco=brow.count
print browco

siteclose=inputbox("Enter your Site to Close",WebPage,"Enter Window Name")

For i=0 to browco-1
    title=brow(i).getroproperty("title")
    print "Browser Title is :    "&title
    
    Dim regEx,Match,Matches
    Set regEx=New RegExp
    regEx.pattern=siteclose
    regEx.IgnoreCase=True
    regEx.Global=True
    Set Matches=regEx.Execute(title)
    
    For Each Match in Matches
            hnd=browser("title:="&title).getroproperty("hwnd")
            'namee=browser("title:="&val).getroproperty("LocationName")
            print title&"         Page Found    It is Closing now"
            systemutil.CloseProcessByHwnd(hnd)
     Next
Next





and I tried to use systemutil.closeprocessbyname, systemutil.closeprocessbywndtitle, systemutil.closeprocessbyid...
but I can't able to close a website by using these? why? If we can use these to close please provide good example..

thanks & regards
Baba Fakruddin.D