TestComplete 3 FAQ. Writing Scripts - Part 2
This page contains answers to frequently asked questions about TestComplete 3. For answers to questions about TestComplete ver. 4 - 6, see TestComplete 6 FAQ.
Q.: How can I run and close my application via the TestedApp object?
A.: Here is a sample routine in VBScript -
Sub Test
' Launches the first application in
' the tested applications list
Set app = TestedApps.Items(0)
app.Run
' Performing tests
Set p = Sys.Process("MyApplication")
Set w = p.Window("MainFormClass", "MainFormCaption", 1)
w.Window("Button1", "*").Click
Log.Picture w, w.FullName
' Closes the application
app.Close
Sys.Delay 3000 ' Waits until the application is closed
If p.Exists Then app.Terminate
End Sub
Q.: How to right-click the application icon in the tray?
A.: You can use the following code. The RightClickTrayIconroutine "right-clicks" the Volume indicator in the system tray and then selects Open Volume Controls from the context menu.
[VBScript]
Sub RightClickTrayIcon(Name, ItemName)
' Gets the tray. Tray is a toolbar
Set p = Sys.Process("Explorer")
Set w = p.Window("Shell_TrayWnd")
w.Activate
Set show_button = w.WaitWindow("Button", "", 2, 100)
If show_button.Exists Then
If show_button.Visible Then
show_button.Click
Sys.Delay(1000)
End If
End If
' Get Button Position in the button array
pos = w.Window("ToolbarWindow32", "", 1).wButtonPos(Name)
' Right-clicks the application icon
x = pos * w.Window("ToolbarWindow32", "", 1).Height + 5
w.Window("ToolbarWindow32", "", 1).ClickR x, 5
' Selects an item from the context menu
w.PopupMenu.Click ItemName
End Sub
Sub Test
RightClickTrayIcon "Volume", "Open Volume Controls"
End Sub
Q.: How can I set the Clipboard content from TestComplete?
A.: If you need to put text to the Clipboard, you can use the Sys.Clipboard property:
[VBScript]
Sys.Clipboard = "My text"'
Also, you can select the desired text or image and simulate the Ctrl-C keypress, e.g.
Sys.Keys "^C"
To save a picture to the Clipboard, you can either select it and then simulate the Ctrl-C keypress, or you can call the Regions.SaveToClipboard method:
Set w = p.Window("WindowClassName",
"WindowCaption", 1)
Regions.SaveToClipboard w
Q.: How to drag an object from one window and drop it to another?
A.: Below is sample code that lets you do this -
[VBScript]
Sub Test;
WordPadPath = "C:\Program Files\Windows NT\Accessories\WORDPAD.EXE"
ClientStartX = 30
ClientStartY = 15
ClientFinishX = 100
ClientFinishY = 100
Call WinExec(WordPadPath, SW_SHOW)
Set p = Sys.Process("wordpad")
Set w1 = p.Window("WordPadClass", "*")
Call w1.Activate
Call SetWindowPos(w1.Handle, 0, 0, 0, 400, 600, SWP_SHOWWINDOW)
Call Sys.Keys("Test^a")
Call WinExec(WordPadPath, SW_SHOW)
Set p = Sys.Process("wordpad", 2)
Set w2 = p.Window("WordPadClass", "*")
Call w2.Activate
Call SetWindowPos(w2.Handle, 0, 400, 0, 400, 600, SWP_SHOWWINDOW)
Call Sys.Delay(2000)
x1 = ClientStartX
y1 = ClientStartY
x2 = ClientFinishX
y2 = ClientFinishY
Call w1.Window("RICHEDIT50W").ClientToScreen(x1, y1)
Call w2.Window("RICHEDIT50W").ClientToScreen(x2, y2)
Call w1.Activate
Call w1.Window("RICHEDIT50W").Drag(ClientStartX, ClientStartY, x2-x1, y2-y1)
End Sub
[DelphiScript]
procedure Test;
var p, w1, w2, path, x1, y1, x2, y2 : OleVariant;
const
WordPadPath = 'C:\Program Files\Windows NT\Accessories\WORDPAD.EXE';
ClientStartX = 30;
ClientStartY = 15;
ClientFinishX = 100;
ClientFinishY = 100;
begin
WinExec(WordPadPath, SW_SHOW);
p := Sys.Process('wordpad');
w1 := p.Window('WordPadClass', '*');
w1.Activate;
SetWindowPos(w1.Handle, 0, 0, 0, 400, 600, SWP_SHOWWINDOW);
Sys.Keys('Test^a');
WinExec(WordPadPath,SW_SHOW);
p := Sys.Process('wordpad', 2);
w2 := p.Window('WordPadClass', '*');
w2.Activate;
SetWindowPos(w2.Handle, 0, 400, 0, 400, 600, SWP_SHOWWINDOW);
Sys.Delay(2000);
x1 := ClientStartX;
y1 := ClientStartY;
x2 := ClientFinishX;
y2 := ClientFinishY;
w1.Window('RICHEDIT50W').ClientToScreen(x1, y1);
w2.Window('RICHEDIT50W').ClientToScreen(x2, y2);
w1.Activate;
w1.Window('RICHEDIT50W').Drag(ClientStartX, ClientStartY, x2-x1, y2-y1);
end;
[JScript]
function ClientToScreenX(obj, x) { return obj.SLeft + x; }
function ClientToScreenY(obj, y) { return obj.STop + y; }
function Test()
{
var p, w1, w2, path, x1, y1, x2, y2;
WordPadPath = "C:\\Program Files\\Windows NT\\Accessories\\WORDPAD.EXE";
ClientStartX = 30;
ClientStartY = 15;
ClientFinishX = 100;
ClientFinishY = 100;
WinExec(WordPadPath, SW_SHOW);
p = Sys.Process("wordpad");
w1 = p.Window("WordPadClass", "*");
w1.Activate();
SetWindowPos(w1.Handle, 0, 0, 0, 400, 600, SWP_SHOWWINDOW);
Sys.Keys("Test^a");
WinExec(WordPadPath,SW_SHOW);
p = Sys.Process("wordpad", 2);
w2 = p.Window("WordPadClass", "*");
w2.Activate();
SetWindowPos(w2.Handle, 0, 400, 0, 400, 600, SWP_SHOWWINDOW);
Sys.Delay(2000);
x1 = ClientToScreenX(w1.Window("RICHEDIT50W"), ClientStartX);
y1 = ClientToScreenY(w1.Window("RICHEDIT50W"), ClientStartY);
x2 = ClientToScreenX(w2.Window("RICHEDIT50W"), ClientFinishX);
y2 = ClientToScreenX(w2.Window("RICHEDIT50W"), ClientFinishY);
w1.Activate();
w1.Window("RICHEDIT50W").Drag(ClientStartX, ClientStartY, x2-x1, y2-y1);
}
[C++Script, C#Script]
function ClientToScreenX(obj, x) { return obj.SLeft + x; }
function ClientToScreenY(obj, y) { return obj.STop + y; }
function Test()
{
var p, w1, w2, path, x1, y1, x2, y2;
WordPadPath = "C:\\Program Files\\Windows NT\\Accessories\\WORDPAD.EXE";
ClientStartX = 30;
ClientStartY = 15;
ClientFinishX = 100;
ClientFinishY = 100;
WinExec(WordPadPath, SW_SHOW);
p = Sys["Process"]("wordpad");
w1 = p["Window"]("WordPadClass", "*");
w1["Activate"]();
SetWindowPos(w1.Handle, 0, 0, 0, 400, 600, SWP_SHOWWINDOW);
Sys["Keys"]("Test^a");
WinExec(WordPadPath,SW_SHOW);
p = Sys["Process"]("wordpad", 2);
w2 = p["Window"]("WordPadClass", "*");
w2["Activate"]()
SetWindowPos(w2.Handle, 0, 400, 0, 400, 600, SWP_SHOWWINDOW);
Sys["Delay"](2000);
x1 = ClientToScreenX(w1.Window("RICHEDIT50W"), ClientStartX);
y1 = ClientToScreenY(w1.Window("RICHEDIT50W"), ClientStartY);
x2 = ClientToScreenX(w2.Window("RICHEDIT50W"), ClientFinishX);
y2 = ClientToScreenX(w2.Window("RICHEDIT50W"), ClientFinishY);
w1["Activate"]();
w1["Window"]("RICHEDIT50W").Drag(ClientStartX, ClientStartY, x2-x1, y2-y1);
}
Q.: How can I read and write data to and from a file in scripts?
A.: In DelphiScript, file operations are supported by special file functions similar to those of Pascal (see "DelphiScript - List of Supported Routines" in on-line help). For VBScript, JScript, C++Script and C#Script the situation is a bit different. These languages do not include functions to write or read data files. The solution, as the examples show, is to create the FileSystemObject via OLE and then use this object to work with the file. The following code gives simple examples of reading and writing files:
[DelphiScript] // Reading a file procedure ReadFile(AFileName : string); var FileVar, s; begin AssignFile(FileVar, AFileName); Reset(FileVar); while not Eof(FileVar) do begin Readln(FileVar, s); Log.Message(s); end; CloseFile(FileVar); end; // Writing to a file procedure WriteToFile(AFileName); var f, s; begin s := 'Hello, world!'; AssignFile(f, AFileName); if Utilities.FileExists(AFileName) then Append(f) else Rewrite(f); Write(f, s); CloseFile(f); end;
[VBScript]
' Reading a file
Sub ReadFile(AFileName)
ForReading = 1
ForWriting = 2
ForAppending = 8
' Creates a new file object
Set FS = Sys.GetOleObject("Scripting.FileSystemObject")
Set F = FS.OpenTextFile(AFileName, ForReading)
While Not F.AtEndOfStream
s = F.ReadLine
Log.Message s
WEnd
F.Close
End Sub
' Writing to a file
Sub WriteToFile(AFileName)
Const ForReading = 1, ForWriting = 2, ForAppending = 8, TristateFalse = 0
Dim fs, f, s
s = "Hello, world!"
' Creates a new file object
Set fs = CreateObject("Scripting.FileSystemObject")
If Not fs.FileExists(AFileName) Then
Set f = fs.CreateTextFile(AFileName)
Else
Set f = fs.OpenTextFile(AFileName, ForAppending, TristateFalse)
End If
f.Write s
f.Close
End Sub
[JScript]
// Reading a file
function ReadFile(AFileName)
{
ForReading = 1;
ForWriting = 2;
ForAppending = 8;
// Creates a new file object
fs = Sys.GetOleObject("Scripting.FileSystemObject");
f = fs.OpenTextFile(AFileName, ForReading);
while(! f.AtEndOfStream){
s = f.ReadLine();
Log.Message(s);
}
f.Close();
}
// Writing to a file
function WriteToFile(AFileName){
ForReading = 1;
ForWriting = 2;
ForAppending = 8;
TristateFalse = 0;
s = "Hello, world!";
// Creates a new file object
fs = new ActiveXObject("Scripting.FileSystemObject")
if(! fs.FileExists(AFileName))
f = fs.CreateTextFile(AFileName);
else
f = fs.OpenTextFile(AFileName, ForAppending, TristateFalse);
// Writes string to file
f.Write(s);
// Closes the file
f.Close();
}
[C++Script, C#Script]
// Reading a file
function ReadFile(AFileName)
{
var ForReading, ForWriting, ForAppending;
var f, fs, s;
ForReading = 1;
ForWriting = 2;
ForAppending = 8;
// Creates a new file object
fs = Sys["GetOleObject"]("Scripting.FileSystemObject");
f = fs["OpenTextFile"](AFileName, ForReading);
while(! f["AtEndOfStream"]){
s = f["ReadLine"]();
Log["Message"](s);
}
f["Close"]();
}
// Writing to a file
function WriteToFile(AFileName){
var ForReading, ForWriting, ForAppending, TristateFalse;
var s, fs, f;
ForReading = 1;
ForWriting = 2;
ForAppending = 8;
TristateFalse = 0;
s = "Hello, world!";
// Creates a new file object
fs = Sys["GetOleObject"]("Scripting.FileSystemObject");
if(! fs["FileExists"](AFileName))
f = fs["CreateTextFile"](AFileName);
else
f = fs["OpenTextFile"](AFileName, ForAppending, TristateFalse);
// Writes string to file
f["Write"](s);
// Closes the file
f["Close"]();
}
Q.: Is it possible to read data from an Excel sheet?
A.: Yes, it's possible. Excel is an OLE server, so you can work with it from scripts via the Excel.Application OLE object. Please review our sample located in the <TestComplete folder>\Samples\Scripts\MSOffice folder. Below there is a simple procedure that reads data from Excel cells and posts them to TestComplete's log.
[VBScript]
Sub ReadDataFromExcel
Set Excel = Sys.GetOleObject("Excel.Application")
Sys.Delay 3000 ' Wait until Excel starts
Excel.Visible = True
Excel.Workbooks.Open "c:\MyFile.xls"
For i = 1 to 10
s = ""
For j = 1 to 5
s = s + VarToString(Excel.Cells(i, j)) + Chr(13) + Chr(10)
Next
Log.Message "Row: " + VarToString(i), s
Next
End Sub
Q.: How can I export results to Excel?
A.: Here is an example of how you can do this -
[VBScript]
Sub Main
Call ExportLogToExcel
End Sub
Dim xcl ' Global variable that holds the Excel OLE object
Dim Num
Sub ParseMasterItem(AMasterItem, ALevel)
s = ""
s = AMasterItem.Data.ValueByName("Name")
xcl.Cells(1, 1) = s
set Details = AMasterItem.Details
Num = 2
For i = 0 To (Details.Count - 1)
ParseDetailItem Details.Items(i), (ALevel + 1)
Next
End Sub
Sub ParseDetailItem (ADetailItem, ALevel)
s = ""
t = ADetailItem.Data.ValueByName("Type")
If t = 2 then
xcl.Cells(Num, 1) = ADetailItem.Data.ValueByName("Message")
xcl.Cells(Num, 2) = ADetailItem.Data.ValueByName("ExtendedMessage")
xcl.Cells(Num, 3) = TimeToStr(ADetailItem.Data.ValueByName("Time"))
End If
Num = Num + 1
End Sub
Sub ExportLogToExcel
' Creates Excel
Set xcl = Sys.GetOleObject("Excel.Application")
Sys.Delay 3000
xcl.Visible = True
Set wb = xcl.Workbooks.Add
' Obtains the current test results
Set MasterDataset = Log.Results
Set MasterItem = MasterDataset.Items(Log.Results.Count - 1)
Call ParseMasterItem(MasterItem, 0)
End Sub
Q.: How can I run a script routine from an external application?
A.: If you want to run the script in TestComplete, you must connect to TestComplete via OLE and then call the Manager.Runner.StartRun method. This is the method called by TestComplete itself when you right-click on the routine in the Editor panel and select Run from the context menu. StartRun uses two parameters: The first specifies the unit name; the second specifies the name of the routine to be run. The Manager object is available from any Connected Application, for instance --
Delphi Connected App
var
app, man : OleVariant;
. . .
app := Sys.GetOleObject('TestComplete.Application');
man := app.Manager;
man.Runner.StartRun('Unit1', 'HelloProc');
Visual Basic Connected App
Set app = Sys.GetOleObject("TestComplete.Application")
Set man = app.Manager
man.Runner.StartRun('Unit1', 'HelloProc')
Manager.Runner.StartRun "Unit1", "HelloProc"
C++
var app, man;
app = Sys["GetOleObject"]("TestComplete.Enterprise");
man = app["Manager"];
man["Runner"]["StartRun"]("Unit1", "HelloProc");
Q.: How to work with results from an external application? For example, how can I check if the last test was successful?
A.: TestComplete saves results of every test run in a structured fashion. For convenient browsing, the results are stored as XML files on hard disk. In memory, the results are organized as two datasets: One of them holds a list of all executed tests. It is a source for the upper part of the Test Log panel. The other dataset is used as a source for the Messages pane of the Test Log panel. You can connect to TestComplete as OLE server and get access to any of these datasets. Then you may scan through their records and fields and process data in your own way. To check, if the last test was successful, you can check the value stored in the datasets. The code below illustrates this. For detailed information on working with results, see "Using TestComplete as OLE Server", "Test Results Structure" and "Structures of Test Log Datasets" in on-linehelp.
Delphi Application
var
i, Idx : Integer;
App, TestLog, TestLogItem : OleVariant;
begin
// Obtains a reference to TestComplete
// TestComplete must be run
App := GetActiveOleObject('TestComplete.Application');
TestLog := App.Manager.Log;
// Obtains test log items
Idx := TestLog.Results.Count;
TestLogItem := TestLog.Results.Items[Idx - 1];
// Checks if the last test was successful
i := TestLogItem.Data.Values[1];
case i of
0 : // OK
. . .
1 : // Error
. . .
2 : // Warning
. . .
end;
end;
VB Application
Sub Test
Dim i, Idx, App, TestLog, TestLogItem
' Obtains a reference to TestComplete
' TestComplete must be run
Set App = GetObject(, "TestComplete.Application")
Set TestLog = App.Manager.Log
' Obtains test log items
Idx = TestLog.Results.Count
Set TestLogItem = TestLog.Results.Items(Idx - 1)
' Checks if the last test was successful
i = TestLogItem.Data.Values(1)
Select Case i
Case 0 ' OK
. . .
Case 1 ' Error
. . .
Case 2 ' Warning
. . .
End Select
End Sub
Q.: Is there a way to translate HWND into a Window object?
A.: Yes. The ID property of a Window object specifies the HWND identifier of a window. Each Window object and Processobject contains the FindID method that lets you find the desired window by its ID:
[VBScript]
Dim MyProcessObj, MyWndObj
Set MyProcessObj = Sys.Process(“MyProcess”)
If MyProcess.FindID(HWND_Value, MyWndObj)
Then
' The window with
the specified hwnd was found.
' The MyWndObj parameter holds the corresponding
Windows object.
Else
' Window not found.
End If
Q.: How can I retrieve information on the memory use on a workstation?
A.: To do this, you can use the Windows API GlobalMemoryStatus function and MEMORYSTATUS structure. Below is a sample code snippet. Note that both the function and structure are available only if the Win32API plug-in is installed.
[VBScript]
Sub TestMemoryStatus
Dim Mem
Set Mem = Win32API.TMemoryStatus
Mem.dwLength = 32
Win32API.GlobalMemoryStatus Mem
Log.Message "MEMORYSTATUS test", _
"Percent of memory in use - " + _
CStr(Mem.dwMemoryLoad) + Chr(13) + Chr(10) + _
"Total bytes of physical memory - " + _
CStr(Mem.dwTotalPhys) + Chr(13) + Chr(10) + _
"Size of available physical memory (bytes) - " + _
CStr(Mem.dwAvailPhys) + Chr(13) + Chr(10) + _
"Size of the user mode portion of virtual address space (bytes) - " + _
CStr(Mem.dwTotalVirtual) + Chr(13) + Chr(10) + _
"The number of available bytes in the user mode portion of virtual "+_
"address space - " + CStr(Mem.dwAvailVirtual)
End Sub
[JScript]
function TestMemoryStatus()
{
var Mem;
Mem = Win32API.TMemoryStatus();
Mem.dwLength = 32;
Win32API.GlobalMemoryStatus(Mem);
Log.Message("MEMORYSTATUS test",
"Percent of memory in use - " + VarToStr(Mem.dwMemoryLoad) +
"\r\nTotal bytes of physical memory - " + VarToStr(Mem.dwTotalPhys) +
"\r\nSize of available physical memory (bytes) - " +
VarToStr(Mem.dwAvailPhys) +
"\r\nSize of the user mode portion of virtual address space (bytes) - " +
VarToStr(Mem.dwTotalVirtual) +
"\r\nThe number of available bytes in the user mode portion of virtual " +
"address space - " + VarToStr(Mem.dwAvailVirtual));
}
[DelphiScript]
procedure TestMemoryStatus;
var
Mem: OleVariant;
begin
Mem := Win32API.TMemoryStatus;
Mem.dwLength := 32;
Win32API.GlobalMemoryStatus(Mem);
Log.Message('MEMORYSTATUS test',
'Percent of memory in use - '+ VarToStr(Mem.dwMemoryLoad) + #13#10 +
'Total bytes of physical memory - ' + VarToStr(Mem.dwTotalPhys) + #13#10 +
'Size of available physical memory (bytes) - ' +
VarToStr(Mem.dwAvailPhys) + #13#10 +
'Size of the user mode portion of virtual address space (bytes) - ' +
VarToStr(Mem.dwTotalVirtual) + #13#10 +
'The number of available bytes in the user mode portion of virtual '+
'address space - '+ VarToStr(Mem.dwAvailVirtual));
end;
[C++Script, C#Script]
function TestMemoryStatus()
{
var Mem;
Mem = Win32API["TMemoryStatus"]();
Mem["dwLength"] = 32;
Win32API["GlobalMemoryStatus"](Mem);
Log["Message"]("MEMORYSTATUS test",
"Percent of memory in use - " +
VarToStr(Mem["dwMemoryLoad"]) +
"\r\nTotal bytes of physical memory - " +
VarToStr(Mem["dwTotalPhys"]) +
"\r\nSize of available physical memory (bytes) - " +
VarToStr(Mem["dwAvailPhys"]) +
"\r\nSize of the user mode portion of virtual address space (bytes) - " +
VarToStr(Mem["wTotalVirtual"]) +
"\r\nThe number of available bytes in the user mode portion of virtual "+
"address space - " + VarToStr(Mem["dwAvailVirtual"]));
}
Q.: I can't find functions to deal with time. Where should I search for them?
A.: VBScript, JScript have special objects and functions that return time, e.g. Time or Now in VBScript or the Date object in JScript. If you use DelphiScript you can use the following routines from the Utilities plug-in (it is installed in the <TestComplete>\Extensions folder) --
DateTimeToStr
StrToDateTime
Now
Date
Time
For example:
Log.Message(Now)
Log.Message(DateTimeToStr(Now))
Log.Message(DateToStr(Now))
Log.Message(TimeToStr(Now))
You can use functions from this plug-in in any other languages too, not only in DelphiScript. As for C++Script and C#Script, you can also use JScript functions there as C++Script and C#Script are based on JScript.
Q.: How can I measure the time passed between events?
A.: You can use either the Win32API.GetTickCount or the Utilities.Now function to measure the time. Here are the examples that demonstrate how you can use these functions:
[VBScript] Sub Test1 t1 = Win32API.GetTickCount Call Sys.Delay(1000) t2 = Win32API.GetTickCount Call Log.Message(t2 - t1) End SubSub Test2 t1 = Utilities.Now Call Sys.Delay(1500) t2 = Utilities.Now Call Log.Message(Utilities.FormatDateTime("nn:ss:zzz", t2-t1)) End Sub
[JScript]
function CheckTime1()
{
var t1, t2;
t1 = Win32API.GetTickCount();
Sys.Delay(1500);
t2 = Win32API.GetTickCount();
Log.Message(t2-t1);
}
function CheckTime2()
{
var t1, t2;
t1 = Utilities.Now();
Sys.Delay(1500);
t2 = Utilities.Now();
Log.Message(Utilities.FormatDateTime("nn:ss:zzz", t2-t1));
}
[DelphiScript]
procedure CheckTime1;
var t1, t2: OleVariant;
begin
t1 := Win32API.GetTickCount;
Sys.Delay(1500);
t2 := Win32API.GetTickCount;
Log.Message(t2-t1);
end;
procedure CheckTime2;
var t1, t2: OleVariant;
begin
t1 := Utilities.Now;
Sys.Delay(1500);
t2 := Utilities.Now;
Log.Message(Utilities.FormatDateTime('nn:ss:zzz', t2-t1));
end;
[C++Script, C#Script]
function CheckTime1()
{
var t1, t2;
t1 = Win32API["GetTickCount"]();
Sys["Delay"](1500);
t2 = Win32API["GetTickCount"]();
Log["Message"](t2-t1);
}
function CheckTime2()
{
var t1, t2;
t1 = Utilities["Now"]();
Sys["Delay"](1500);
t2 = Utilities["Now"]();
Log["Message"](Utilities["FormatDateTime"]("nn:ss:zzz", t2-t1));
}
Q.: How to minimize TestComplete after running a script?
A.: When you run a script, TestComplete remains on screen at its current location. The following two-line code fragment will minimize TestComplete, or any other Windows application if you change the names for the process and the window class:
[DelphiScript]
// Obtains the main window of TestComplete process
w := Sys.Process('TestComplete').Window('TFormTestComplete');
w.Minimize; // Minimizes TestComplete
[VBScript]
' Obtains the main window of TestComplete process
Set w = Sys.Process("TestComplete").Window("TFormTestComplete")
w.Minimize ' Minimizes TestComplete
[JScript]
// Obtains the main window of TestComplete process
w = Sys.Process("TestComplete").Window("TFormTestComplete");
w.Minimize(); // Minimizes TestComplete
[C++Script, C#Script]
// Obtains the main window of TestComplete process
w = Sys["Process"]("TestComplete")["Window"]("TFormTestComplete");
w["Minimize"]; // Minimizes TestComplete
See "Creating Connected Applications in C++" in on-line help for detailed information on executing C++ script code.
