I was wondering if anyone had any suggestions on how to get accessability
information form a window handle. I know this is possible and even found
some sample code but it doesn't seem to work.
Here is the code i am using:
-----------------------------------------------------------------------------------------------
using Accessibility;
private UUID uuidAccessible;
private Guid iAccessibleGuid = new
Guid("618736e0-3c3d-11cf-810c-00aa00389b71");
private IAccessible GetAccessibleInterfaceFromWindow(int handleWindow)
{
uuidAccessible = new UUID();
uuidAccessible.data1 = 0x618736e0;
uuidAccessible.data2 = 0x3c3d;
uuidAccessible.data3 = 0x11cf;
uuidAccessible.data4 = new byte[8];
uuidAccessible.data4[0] = 0x81;
uuidAccessible.data4[1] = 0xc;
uuidAccessible.data4[2] = 0x0;
uuidAccessible.data4[3] = 0xaa;
uuidAccessible.data4[4] = 0x0;
uuidAccessible.data4[5] = 0x38;
uuidAccessible.data4[6] = 0x9b;
uuidAccessible.data4[7] = 0x71;
IAccessible iDialogWindow = null;
//Allocate memory the size of IAccessible interface
IntPtr dialogWindow = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(UUID) ));
//Add 1 level of indirection
IntPtr dialogWindowp =
Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(IntPt r)));
Marshal.StructureToPtr(dialogWindow, dialogWindowp, false);
//Call function in Oleacc.dll
AccessibleObjectFromWindow(handleWindow, 0, uuidAccessible, dialogWindowp);
//Remove 1 level of indirection
dialogWindow = Marshal.ReadIntPtr(dialogWindowp);
//Allocate memory for the real IAccessible interface
IntPtr iAccessiblePtr =
Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(UUID) ));
Marshal.QueryInterface(dialogWindow, ref iAccessibleGuid, out
iAccessiblePtr);
iDialogWindow =
(IAccessible)Marshal.GetTypedObjectForIUnknown(iAc cessiblePtr,
typeof(IAccessible));
return iDialogWindow;
}
[StructLayout(LayoutKind.Sequential)]
public class UUID
{
public int data1;
public short data2;
public short data3;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public byte[] data4;
}
-----------------------------------------------------------------------------------------------
This runs but more or less every propery has a value of "<cannot view
indexed property>". Is there something i need to do to get the information
out of it?
Thanks in advance,
Logan