I had a little progress on my search on how I can do this. Below is the step
I gathered on the web, but I am yet to find how I could use this.
1. In Visual Studio by going to Project->Add Reference. In the .NET tab,
choose the Accessibility.dll..
2. Add the following code in the C# program.
[DllImport("oleacc.dll", EntryPoint="AccessibleObjectFromPoint",
SetLastError=true, CharSet=CharSet.Auto,
CallingConvention=CallingConvention.StdCall)]
public static extern int AccessibleObjectFromPoint(Point pt, ref
Accessibility.IAccessible ppacc,ref object pvarChild);//(IntPtr hWnd);
[DllImport("oleacc.dll", EntryPoint="AccessibleObjectFromEvent",
SetLastError=true, CharSet=CharSet.Auto,
CallingConvention=CallingConvention.StdCall)]
public static extern int AccessibleObjectFromEvent(int hwnd, int objid,
int childid, ref Accessibility.IAccessible ppacc, ref object pvarChild);
[DllImport("user32.dll", EntryPoint="SetWinEventHook", SetLastError=true,
CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
public static extern int SetWinEventHook(int eventMin, int eventMax, int
hmodWinEventProc, WinEventProc lpfnWinEventProc, int idProcess, int
idThread, int dwflags);
public delegate int WinEventProc(int hWinEventHook, int idEvent, int hwnd,
int idObject, int idChild, int dwEventThread, int dwmsEventTime);
Then, I am stuck.... Basically I don't know how I can create the
IAccessible object in the C# and call the ac.get_accName function as the
mouse pointer moves... I crafted up an experimental code, but this does not
work.
Accessibility.IAccessible ac = new Accessibility.IAccessible();
Point pt = new Point(50,50);
string test = ac.get_accName(pt);
If you know a way to do this, can you please let me know? Even the general
pseudo-code would help.
Thanks.
Tomtom