Ranorex

Can't find Control Name

 
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexNet
View previous topic :: View next topic  
Author Message
GuiTester



Joined: 11 Sep 2006
Posts: 4

PostPosted: Thu Sep 14, 2006 8:11 am    Post subject: Can't find Control Name
I have a C#.NET based windows application. I used the RanorexSpy to find out the class name, control name of the application. I got the values for Caption/text and Class name fields. But, the Class name and Control id fields are empty.

In this case, which field should I use to reliable get a handle to the application?

Thanks in advance.
Back to top
View user's profile Send private message
GuiTester



Joined: 11 Sep 2006
Posts: 4

PostPosted: Thu Sep 14, 2006 8:26 am    Post subject:
For the time being, I used the class name which looks something like "WindowsForms10.Window.8.app...".

When I call 'FindFormClassName' method, I get a dialog box with the error 'CoInitialize error'. Any idea what this means?
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 05 Jul 2006
Posts: 351

PostPosted: Thu Sep 14, 2006 10:27 pm    Post subject:
> In this case, which field should I use to reliable get a handle to the application?

An application has no "Control name" and no "Control Id", only controls have these properties. You should find an application with the Application.FindFormTitle function:
(See also the samples in the Samples directory)

Code: click into code to enlarge
Form form = Application.FindFormTitle("Title of the application");

You should use the FindFormClassName method only, if your application has no unique title.

> I get a dialog box with the error 'CoInitialize error'. Any idea what this means?

We use COM in RanorexCore and COM Interop in RanorexNet, so we need a SingleThreadedAppartement.
This error can happen, if the main thread hasn't the attribute [STAThread]
See also: http://www.ranorex.com/net/samples/visual_studio_1/teaser/11/

[STAThread]
static int Main(string[] args)

Jenö Herget
Ranorex Team
Back to top
View user's profile Send private message Visit poster's website
GuiTester



Joined: 11 Sep 2006
Posts: 4

PostPosted: Fri Sep 15, 2006 8:38 am    Post subject:
Thanks for the reply. I fixed the CoInit problem.

I used your example and tried to programmatically get the application handle, the properties window, the solution explorer in my application. I had trouble with the menu bar. If I see the menubar through RanorexSpy, it doesn't have a control name or a caption text. It has a control id, and a class name which is like 'WindowsForms10.Window.8.app.0.b7ab7b #34'.

Is there a way I can get a menubar object without using the title?
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 05 Jul 2006
Posts: 351

PostPosted: Sat Sep 16, 2006 12:27 am    Post subject:
> Is there a way I can get a menubar object without using the title?

If your menu bar has no control name, then you have an old style menu bar with menu handle, not a menu strip.
You can automate such a menu as follows:

Code: click into code to enlarge
Menu menu = new Menu(form);
if (menu != null)
{
    // Get the item count of the first submenu
    int ret = menu.GetItemCount(1);
    Console.WriteLine("  GetItemCount(1)={0}", ret);
   
    // Get the text of the second menu item of the first submenu
    string itemText = menu.GetItemText(1, 2);
    Console.WriteLine("  GetItemText(1,2)={0}", itemText);
   
    // Select a menu item
    ret = menu.SelectItemText("Submenu2", "Submenu2Item1");
}

See the documentation for other menu functions.

Jenö Herget
Ranorex Team
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexNet All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum