How can I automate Color Dialogue

Class library usage, coding and language questions.
saurabh
Posts: 20
Joined: Fri Jul 20, 2007 1:11 pm
Location: India
Contact:

How can I automate Color Dialogue

Post by saurabh » Fri Jul 20, 2007 1:39 pm

I want to automate Color dialogue but i didn't get any API in Ranorex .NET Library.
Even Ranorex Spy is not identifying the color box in color dialogue there is no control Name or control id for each color box.
Its just giving some common parent so i am unble to select a particular color from there.Apart from this the there is no control name giving by Ranorex spy for button containing by color dialogue.
Please help me out to do that.Its very critical for my client.I am using paid version of ranorex.

Here no Control Name show by Ranorexspy for these buttons
1.OK
2.Cancel
3.Add To Custom Color

also for
Basic colors
custom colors

Send me code for the same

admin
Site Admin
Site Admin
Posts: 350
Joined: Wed Jul 05, 2006 7:44 pm

Post by admin » Fri Jul 20, 2007 3:21 pm

The following code sample reads the selected colors (red, green and blue) from the dialog, sets red=64, green=128 and blue=192 and clicks the OK button.

Code: Select all

Form form = Application.FindFormTitle("Color");
if (form == null)
    return 1;

Element red     = form.Element.FindChild(Role.Text, "Red:");
Element green   = form.Element.FindChild(Role.Text, "Green:");
Element blue    = form.Element.FindChild(Role.Text, "Blue:");

if( red == null || green == null || blue == null )
{
    Console.WriteLine("ERROR: red, green or blue edit box not found");
    return 1;
}

Console.WriteLine("Color Red={0} Green={1} Blue={2}", red.Value, green.Value, blue.Value);
red.Value   = "64";
green.Value = "128";
blue.Value  = "192";

Element okButton = form.Element.FindChild(Role.PushButton, "OK");
if (okButton != null)
    Mouse.ClickElement(okButton);

return 0;
Gabor
Ranorex Team