QTP Wonder codes with Notepad,Explorer,Excel

Dim text
text = ""

Dim rgx
Set rgx = New RegExp
rgx.IgnoreCase = True
rgx.Global = True
rgx.Pattern = "([A-Za-z]{3,9})://([-;:&=\+\$,\w]+@{1})?([-A-Za-z0-9\.]+)+:?(\d+)?((/[-\+~%/\.\w]+)?\??([-\+=&;%@\.\w]+)?#?([\w]+)?)?"

Dim match, matches
Set matches = rgx.Execute(text)
For Each match in matches
  MsgBox match.Value, 0, "Found Match"
Next

'Launch a notepad window
SystemUtil.Run "notepad.exe"  
'Close the window just launched using the exact title
SystemUtil.CloseProcessByWndTitle "Untitled - Notepad" 
'Launch a notepad window
SystemUtil.Run "notepad.exe"  
'Close the window just launched using a pattern string
SystemUtil.CloseProcessByWndTitle ".*Notepad", True  
SystemUtil.CloseDescendentProcesses  
CloseDescendentProcesses can be used to close any process launched by QTP. The code below illustrates the usage 
'Launch explorer
SystemUtil.Run "iexplore.exe"  
'Launch excel using COM
Set oXL = CreateObject("Excel.Application")
oXL.Visible = True  
'Close processes launched by QTP. This will close
'the internet explorer and Excel as well
SystemUtil.CloseDescendentProcesses


While Browser("creationtime:=0").Exist(0) 
    'Close the browser
    Browser("creationtime:=0").Close  

Post a Comment

أحدث أقدم