Running Code under Application Under Test from the UFT One Context
When the Custom Server is running in the UFT One context, there is no direct access to the control, which is in a different run-time process. To access the control directly, run part of the code in the Application under test context. This is done using assistant classes.
To launch code from the UFT One context that runs under the Application under test context, implement an assistant class that inherits from CustomAssistantBase. To create an instance of an assistant class, call CreateRemoteObject. Before using the object, attach it to the control with SetTargetControl.
After SetTargetControl is called, you can call methods of the assistant in one of the following ways:
If the method can run in any thread of the Application under test process, read and set control values and call control methods with the simple obj.Member syntax:
int i = oMyAssistant.Add(1,2);
If the method must run in the control's thread, use the InvokeAssistant method:
int i = (int)InvokeAssistant(oMyAssistant, "Add", 1, 2);
Tip: You can use the EventListenerBase, which is an assistant class that supports listening to control events.
For more information, see Reviewing Commonly-used API Calls.