public static void msaa()
{
object obj = new object();
IntPtr hWnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Maxthon2_Frame", null);//get the parent hwnd
IntPtr hwnd2 = FindWindowEx(hWnd, IntPtr.Zero, "XTPToolBar", "标准工具栏"); //get the sub window
Guid guid = new Guid("{618736E0-3C3D-11CF-810C-00AA00389B71}");
AccessibleObjectFromWindow(hwnd2, 0x00000000, ref guid, ref obj);//get the aa object
IAccessible accessible = obj as IAccessible;
accessible = accessible.accParent as IAccessible;//get the parent aa object
Object[] childs = new Object[accessible.accChildCount]; //set a array to receive the sub aa object list
int obtained = 0;
AccessibleChildren(accessible, 0, accessible.accChildCount - 1, childs, out obtained);//get the sub aa objects
Console.WriteLine(obtained.ToString());//print count to verify the result
//print relative information ,not very importent .
for (int i = 0; i < obtained; i++)
{
IAccessible child = childs as IAccessible;
try { Console.WriteLine(child.get_accName(0)); }
catch { }
Object[] accchilds = new Object[child.accChildCount];
int result = 0;
AccessibleChildren(child, 0, child.accChildCount - 1, accchilds, out result);
for (int j = 0; j < result; j++)
{
IAccessible jchild = accchilds[j] as IAccessible;
Console.WriteLine(jchild.get_accName(0));
}
}
Console.ReadLine();
}作者: sihanjishu 时间: 2008-8-6 15:45
问题已经解决。
我的api定义有问题