MSN = new messengerclass ();
MSN. onimwindowcreated + = new dmessengerevents_onimwindowcreatedeventhandler (msn_onimwindowcreated );
MSN. onimwindowdestroyed + = new dmessengerevents_onimwindowdestroyedeventhandler (msn_onimwindowdestroyed );
4.
Private void msn_onimwindowcreated (Object pimwindow)
{
Msnmsgwnd = (imessential gerconversationwnd) pimwindow; // get the IM window handle
# Region get IM message
System. intptr ptruihwnd = nativewin32.find1_wex (msnmsgwnd. hwnd, 0, "directuihwnd", 0); // obtain the directuihwnd handle in the window
Guid guidcom = new GUID (0x618736e0, 0x3c3d, 0x11cf, 0x81, 0xc, 0x0, 0xaa, 0x0 0x38, 0x9b, 0x71 ); // The GUID of COM
Iaccessible iacurrent = NULL; // iaccessible set
Try
{
Nativewin32.accessibleobjectfromwindow (ptruihwnd, (INT) nativemsg. objid_client, ref guidcom, ref iacurrent); // obtain the iaccessible set in ptruihwnd
Iacurrent = (iaccessible) iacurrent. accparent; // its parent is the real container of the iaccessible set.
Int _ childcount = iacurrent. accchildcount;
Object [] _ Children = new object [_ childcount];
Int _ out;
Nativewin32.accessiblechildren (iacurrent, 0, _ ChildCount-1, _ children, out _ out); // from iacurrent, add all sub-iaccessible to the _ Children Array
Foreach (iaccessible _ child in _ children)
{
String _ accname = _ child. get_accname (INT) nativemsg. childid_self );
{System. intptr hwndstart;
Int _ next = 0;
Do
{
Hwndstart = nativewin32.find1_wex (0, _ next, "imwindowclass", 0 );
_ Next = hwndstart. toint32 ();
} While (_ next! = 0 );
}
6. Finally, the API Declaration
# Region API wrapper
Public class nativewin32
{
[Dllimport ("user32.dll", charset = charset. Auto)]
Public static extern intptr find1_wex (
Int parent/* hwnd */,
Int next/* hwnd */,
String lpszclass,
String swindowtitle );
[Dllimport ("oleacc. dll")]
Public static extern int accessibleobjectfromwindow (
Intptr hwnd,
Int dwobjectid,
Guid refID,
Ref iaccessible ppvobject );
[Dllimport ("oleacc. dll")]
Public static extern int accessiblechildren (
Accessibility. iaccessible pacccontainer,
Int ichildstart,
Int cChildren,
[Out] object [] rgvarchil.pdf,
Out int pcobtained );
}
Public Enum nativemsg: long {
Childid_self = 0,
Childid_1 = 1,
Objid_client = 0 xffffffc
}
# Endregion
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.