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.d ll..
2. Add the following code in the C# program.
[DllImport("olea cc.dll", EntryPoint="Acc essibleObjectFr omPoint",
SetLastError=tr ue, CharSet=CharSet .Auto,
CallingConventi on=CallingConve ntion.StdCall)]
public static extern int AccessibleObjec tFromPoint(Poin t pt, ref
Accessibility.I Accessible ppacc,ref object pvarChild);//(IntPtr hWnd);
[DllImport("olea cc.dll", EntryPoint="Acc essibleObjectFr omEvent",
SetLastError=tr ue, CharSet=CharSet .Auto,
CallingConventi on=CallingConve ntion.StdCall)]
public static extern int AccessibleObjec tFromEvent(int hwnd, int objid,
int childid, ref Accessibility.I Accessible ppacc, ref object pvarChild);
[DllImport("user 32.dll", EntryPoint="Set WinEventHook", SetLastError=tr ue,
CharSet=CharSet .Auto, CallingConventi on=CallingConve ntion.StdCall)]
public static extern int SetWinEventHook (int eventMin, int eventMax, int
hmodWinEventPro c, WinEventProc lpfnWinEventPro c, int idProcess, int
idThread, int dwflags);
public delegate int WinEventProc(in t 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.I Accessible ac = new Accessibility.I Accessible();
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
"TomTom" <no*****@nospam fordiscussion.c om> wrote in message
news:un******** ******@TK2MSFTN GP09.phx.gbl...
Thanks for your suggestion. I'll ask around a little more.
Tomtom
"Christophe r Kimbell" <a@b.c> wrote in message
news:40******** @news.broadpark .no... I don't know of any way to do it using .NET.
You would probably need functionality similar to Spy++, I tried to
select a MenuItem, but could only get the whole menu.
If it is possible, it would require some interop, try asking in the some of the win32 api groups, if there are APIs you can use,
these can be wrapped in DllImport for use in .NET.
Chris
"TomTom" <no*****@nospam fordiscussion.c om> wrote in message
news:uX******** ******@TK2MSFTN GP09.phx.gbl... Sorry, I didn't describe what I wanted to do in more details.
I need to capture the text that's in other programs. The scenario
looks like:
1. I activate MyApp.
2. I hover mouse pointer over some menu text, command bar text, etc.
in MS Word.
3. The pointed text show up in MyApp.
Is this possible?
Thanks,
TomTom
"Christophe r Kimbell" <a@b.c> wrote in message
news:40******** @news.broadpark .no...
> The MenuItem has a Select event that is called when the mouse is
over it. > Use this to set the label text.
>
> Chris
>
> "TomTom" <no*****@nospam fordiscussion.c om> wrote in message
> news:uW******** *****@TK2MSFTNG P11.phx.gbl...
> > Hi,
> >
> > With C#, is it possible to hover a mouse pointer on the Windows UI
> controls
> > and show the UI text? For example, can I hover my mouse over
"File" in > the
> > menu bar and show the text "File" on a label?
> >
> > I've seen a program like this but not sure if it can be done with
C#. > >
> > Thanks!
> > TomTom
> >
> >
>
>