How to disable GDI capture feature during runtime

Ranorex Spy, Recorder, and Studio.
phibao37
Posts: 5
Joined: Tue Mar 07, 2017 9:35 am

How to disable GDI capture feature during runtime

Post by phibao37 » Tue Sep 12, 2017 3:26 am

I'm creating automation script for an application that contains many custom element like diagram, status text (this text can be obtained with GDI capture feature), but this feature also affect to another function as well.

Firstly, this is test case for basic element that Ranorex can recognize it, and it run without any problem

+ Testcase_Check_Common_Element
+ Module_1:
+ Click button A
+ Fill value to text B
+ Click button C
+ Validate text D
+ etc...

Now, I add another test case to validate the status text:
+ Testcase_Check_Status_Text
+ Module_2: (Module Settings / GDI Capture Settings / Process names: added process name of the application)
+ Obtain the text: repo.myapplication.rawtext_status.RawTextValue
+ Validate the text

The test case also run OK, but when I run 2 test cases together, at each step of Module_1 (click button A, fill value to text B, ...), all diargram in the application flashing many time before it operate the step. I think that the diagram was constructed with some native GDI drawing function, and at each step of the module, Ranorex send message to the application window to make it "redrawing" and then capturing the text. It mean that at each step, Ranorex will refresh the RawText element no matter these element was used in the step or not. Is it correct?

Finally, if the above statement is true, how can I limit the GDI Capture process within the module/testcase only, that is, when running into Module_1, it will not capturing rawtext anymore


System information:
- Windows 7
- Ranorex version: 6.2.1

McTurtle
Posts: 191
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: How to disable GDI capture feature during runtime

Post by McTurtle » Wed Sep 13, 2017 2:52 pm

Hello phibao37,

I can not say what exactly is happening to your application... But I can say how to turn off/on GDI during runtime ;)
public void TurnOn()
{
	Report.Info("Activate GDI");
	var plugins= Ranorex.Core.PluginManager.Instance;
	plugins.LoadDefaultPlugins();
	RawTextFlavor.Instance.UpdateFromConfig();
}

public void TurnOff()
{
	Report.Info("Deactivate GDI");
	var plugins=Ranorex.Core.PluginManager.Instance;
	plugins.LoadDefaultPlugins();
	RawTextFlavor.Instance.ProcessNames.Clear();
}
Also, you must reference "using Ranorex.Plugin;".

I hope this helps.
Please do write if the solution was helpful.

Regards,
McTurtle