Search code examples
vbscripthp-uft

Can I pause execution of an application that was started by a VBscript?


I launch the Unified Functional Testing application and tell it to run a script:

Dim uftApp
Dim WshShell

Set uftApp = CreateObject("QuickTest.Application")

If NOT uftApp.Launched Then
    uftApp.Launch
End if

uftApp.Visible = True
uftApp.WindowState = "Minimized"

uftApp.Open "C:\Users\smithjohn\Desktop\UFT Repository\Project 1\MyUFTScript", False
uftApp.Test.Environment.Value("ForTeam") = "TEAM A"

uftApp.Test.Run

uftApp.Test.Close

uftApp.Quit

Set uftApp = Nothing

This launches UFT and begins to run MyUFTScript. Since this script be can be quite long and take hours to run I want to be able to pause the execution. I've written another small vbscript file that looks like this:

Dim qtApp
Set qtApp = CreateObject("QuickTest.Application")
qtApp.Test.Pause
Set qtApp = Nothing

I then create a shortcut to that vbs file and give it a shortcut key, "cntl + alt + p". When I lauch UFT myself my pause script works perfectly, but when the top most vbs file is used to launch and run UFT my pause.vbs file wont run at all - I am not able to pause execution.

Am I doing something wrong?


Solution

  • Use GetObject instead of CreateObject. this should work for you.

    Dim qtApp
    Set qtApp = GetObject("","QuickTest.Application")
    qtApp.Test.Pause
    Set qtApp = Nothing