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.
Can't find Control Name
> 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)
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/visu ... teaser/11/
[STAThread]
static int Main(string[] args)
Jenö Herget
Ranorex Team
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: Select all
Form form = Application.FindFormTitle("Title of the application");
> 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/visu ... teaser/11/
[STAThread]
static int Main(string[] args)
Jenö Herget
Ranorex Team
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?
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?
> 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:
See the documentation for other menu functions.
Jenö Herget
Ranorex Team
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: Select all
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");
}
Jenö Herget
Ranorex Team