control ids

Hi

We have an automation software which detects Windows built-in control according to their ids.

We noticed that on Windows Vista build 5472, the ids are were totally changed comparing to the ids in Vista beta 2 and earlier.

Is it not correct to rely on the ids? Is there a better way to identify the type of a control (can't it's name change)?

Here is a code sample that we used to list the control ids:

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Automation;
using System.Reflection;

namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
foreach (FieldInfo fi in typeof(ControlType).GetFields())
{
ControlType ct = fi.GetValue(new object()) as ControlType;
Console.WriteLine(string.Format("id: {0}\tname: {1}", ct.Id, fi.Name));
}
Console.Read();
}
}
}

[1080 byte] By [rosebud75] at [2008-2-4]
# 1

In general, the automationId property is not intended for identifying specific elements across all platforms. It is more likely to be used, for example, by testing software that already knows the ID of an element on the platform it is testing, or for navigating within a subtree to a known element within that subtree. (Remember, automationIds are not unique on the desktop, only unique among siblings.)

If you are trying to locate a particular Windows element such as the Start button, you are probably better off looking for it by classname and name. However, there are never any guarantees that these will not change from version to version.

PeterDonnelly-MSFT at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Microsoft UI Automation...
# 2

Hi Peter

I did not refer to a specifc element automation id, but rather to a "control id" - a unique number that identifies all controls of a specific type.
Have a look at the code sample above to see what I mean.

Thanks

rosebud75 at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Microsoft UI Automation...
# 3

My apologies for the brain cramp.

I'm curious to know why you are drilling down to the id of the ControlType. The static objects themselves (e.g. ControlType.Button) are what identify the types, and any searches or comparisons should work regardless of whether the underlying numerical id changes in future versions.

PeterDonnelly-MSFT at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Microsoft UI Automation...

Software Development for Windows Vista

Site Classified