How to reference the instance of an object

Class library usage, coding and language questions.
sgreenfield
Posts: 17
Joined: Tue Oct 14, 2008 2:19 pm

How to reference the instance of an object

Post by sgreenfield » Sun Oct 26, 2008 11:44 am

Our software runs on multiple monitors. How can I reference multiple instances of the same windows via the instance ID? (at least, that's what I assume you're showing in Spy at the end of the Class Name).

I thought maybe you internally tacked on the #1, #2, etc to the class name - tried that, but I got back the same window and I can't seem to find anything in the API that does it.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Post by Support Team » Mon Oct 27, 2008 9:48 am

Right, the number you see right to the ClassName in RanorexSpy is the instance number. You can use the instance number with the Application.FindFormClassName(...) or Control.FindClassName(...) methods. The following code, for example, will retrieve the third instance of the calculator:

Code: Select all

string className = "SciCalc";
int classInstance = 3;
Ranorex.Form calculator3 = Application.FindFormClassName(className, classInstance);
Regards,
Alex
Ranorex Support Team

sgreenfield
Posts: 17
Joined: Tue Oct 14, 2008 2:19 pm

Post by sgreenfield » Mon Oct 27, 2008 6:21 pm

Thanks - I found that a while after posting but I have to say I'm impressed with how fast you guys reply and how good the information posted is. Just wanted to say thank you and well done. Rare to see these days.