MSN-消息 ( 积分: 0 )

  • 主题发起人 主题发起人 zqssoft
  • 开始时间 开始时间
Z

zqssoft

Unregistered / Unconfirmed
GUEST, unregistred user!
1.如何用Api,取得MSN窗口上两人的聊天文字内容.显示在程序Memo中.
2.如何监听端口,获取MSN上好友发来的消息,到程序Memo控件中显示.
 
以下是获取QQ聊天窗口中的文字例子,谁能依此提供获取MSN聊天窗口的,谢谢.

var
Title: array[0..255] of Char;
QQText: Pchar;
Long: Integer;
hLastWin: THandle;
begin
try
Timer1.Enabled := False;
hLastWin := GetForegroundWindow;
Getwindowtext(hLastWin, Title, 255); //获取窗口标题
if (Pos('聊天中', Title) > 0) then
begin
hLastWin := FindWindowEx(hLastWin, THandle(nil), '#32770', nil);
if hLastWin = 0 then Exit;
hLastWin := FindWindowEx(hLastWin, THandle(nil), 'RichEdit20A', nil);
if hLastWin = 0 then Exit;
Long := SendMessage(hLastWin, WM_GETTEXT, 0, 0) + 1;
GetMem(QQText, Long);
SendMessage(hLastWin, WM_GETTEXT, Long, Integer(QQText));
end else Exit;
try
if QQText <> '' then
begin
Memo1.Text := QQText;
end;
finally
FreeMem(QQText);
end;
finally
Timer1.Enabled := True;
end;
end;
 
不会...
什么也不改不行吗?
 
http://www.delphibbs.com/delphibbs/dispq.asp?lid=2632983
几乎是为你定做的.
 
谁能用类似获取QQ聊天窗口的例程写一下MSN的,谢谢.暂时不说监听.
 
用Spy++ Lite看了看,MSN聊天窗口的类名为:DirectUIHWND
查不到此窗口上有其它控件,请问:
如何访问这个DirectUIHWND窗口,并取得其中显示的聊天文字内容呢.
 
下面是在网上搜索到的.net代码,懂的请帮助看看,改为delphi的,访问DirectUIHWND窗口,并获取其中的文本内容.谢谢.
问题 最近研究界面,发现微软的程序都使用directuihwnd,可是我找不到关于这方面的介绍。
最近研究界面,发现微软的程序都使用directuihwnd,可是我找不到关于这方面的介绍。
响应者 1:.net下基于api封装的directuihwnd窗体访问 响应者 2:.net下基于api封装的directuihwnd窗体访问

1.添加引用. 项目->添加引用->c://progmme~1//msn messenger//msnmsgr.exe

2. using messengerapi;

声明:

private messengerapi.messengerclass msn;
private messengerapi.imessengerconversationwnd msnmsgwnd;

3.init里添加:

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 = (imessengerconversationwnd) pimwindow; //取得im窗口句柄



#region get im message
system.intptr ptruihwnd = nativewin32.findwindowex(msnmsgwnd.hwnd, 0, "directuihwnd", 0); //取得窗口内directuihwnd句柄
guid guidcom= new guid(0x618736e0,0x3c3d,0x11cf,0x81,0xc,0x0,0xaa,0x0,0x38,0x9b,0x71); //com的guid
iaccessible iacurrent=null; //iaccessible集
try
{

nativewin32.accessibleobjectfromwindow(ptruihwnd,(int)nativemsg.objid_client,ref guidcom,ref iacurrent); //取得ptruihwnd中iaccessible集

iacurrent = (iaccessible)iacurrent.accparent; //其父,才是iaccessible集真正的容器
int _childcount = iacurrent.accchildcount;
object;
int _out;
nativewin32.accessiblechildren(iacurrent,0,_childcount-1,_children,out _out); //从iacurrent中,将所有子iaccessible加入_children数组中
foreach(iaccessible _child in _children)
{
string _accname = _child.get_accname((int)nativemsg.childid_self);

}

}
catch(exception ex)
{
throw ex;
}
#endregion
}

private void msn_onimwindowdestroyed(object pimwindow)
{
msnmsgwnd = null;
}

5.直接查找消息窗体的方法

private void findimwindow()

{system.intptr hwndstart;
int _next = 0;
do
{
hwndstart = nativewin32.findwindowex(0, _next, "imwindowclass", 0);
_next = hwndstart.toint32();
}while(_next != 0);

}

6.最后是api声明

#region api wrapper
public class nativewin32
{

public static extern intptr findwindowex(
int parent /*hwnd*/,
int next /*hwnd*/,
string lpszclass,
string swindowtitle);


public static extern int accessibleobjectfromwindow(
intptr hwnd,
int dwobjectid,
guid refid,
ref iaccessible ppvobject);


public static extern int accessiblechildren(
accessibility.iaccessible pacccontainer,
int ichildstart,
int cchildren,
object[] rgvarchildren,
out int pcobtained);

}
public enum nativemsg:long {
childid_self = 0,
childid_1 = 1,
objid_client = 0xffffffc
}
#endregion
 
还有一个方法,就是注入MSN的内存空间,取得其聊天窗口中的文字.
高手谁会,给个解答,谢谢.
 
后退
顶部