如题
如果你在专家前给出代码,或者专家给不出代码,你先给出.500分奉上=5个帖子的总和
如果某个专家给出代码,我将补齐500分给你.
在qq的聊天窗口,当按下"发送"按钮之前,执行一段我的代码
希望能用全局消息钩子加子类化函数实现
WH_CALLWNDPROC setwindowslong
因为,用全局钩子消息,我已会 我在学子类化函数的用法? library TmHook; uses
SysUtils,
Classes,
Windows,
Messages,
CommCtrl;
var
hhook: Windows.HHOOK;
hwndListView: HWND;
na:array[0..300] of char;
oldWndProc: Integer;
{$R *.res}
function WindowProc(hwnd: HWND; msg: UINT; wp: WPARAM; lp: LPARAM): LRESULT; stdcall;
begin
case Msg of
WM_LBUTTONDOWN:
MessageBox(hwndListView,'你好!','提示',MB_OK);
end;
Result := CallWindowProc(TFNWndProc(oldWndProc), hwnd, msg, wp, lp);
end;
function TmHookProc(nCode: Integer; wParam: WPARAM; lParam: LPARAM): Integer; stdcall;
var
cwp: PCwpStruct;
m:TPoint;
begin
Result := 0;
if (nCode < 0) then
begin
Result := CallNextHookEx(hhook, nCode, wParam, lParam);
exit;
end;
cwp := PCwpStruct(lParam);
if cwp^.message <> WM_COMMAND then
begin
Result := CallNextHookEx(hhook, nCode, wParam, lParam);
exit;
end;
GetCursorPos(m);
GetWindowText(WindowFromPoint(m),na,299);
if lstrcmpi('发送(S)',na) <>0 then
begin
Result := CallNextHookEx(hhook, nCode, wParam, lParam);
exit;
end;
hwndListView:=WindowFromPoint(m);
oldWndProc := SetWindowLong(hwndListView, GWL_WNDPROC, Integer(@WindowProc));
end;
procedure Hook(bEnable: Boolean); stdcall; export;
begin
if bEnable then
begin
if hhook = 0 then
begin
hhook := SetWindowsHookEx(WH_CALLWNDPROC, TmHookProc, HInstance, 0);
end;
end
else
begin
if hhook <> 0 then
begin
UnhookWindowsHookEx(hhook);
hhook := 0;
end;
end;
end;
exports
Hook;
begin
hhook := 0;
hwndListView := 0;
oldWndProc:=0;
end.
到底哪里错了,一运行,qq就自动关闭??
如果你在专家前给出代码,或者专家给不出代码,你先给出.500分奉上=5个帖子的总和
如果某个专家给出代码,我将补齐500分给你.
在qq的聊天窗口,当按下"发送"按钮之前,执行一段我的代码
希望能用全局消息钩子加子类化函数实现
WH_CALLWNDPROC setwindowslong
因为,用全局钩子消息,我已会 我在学子类化函数的用法? library TmHook; uses
SysUtils,
Classes,
Windows,
Messages,
CommCtrl;
var
hhook: Windows.HHOOK;
hwndListView: HWND;
na:array[0..300] of char;
oldWndProc: Integer;
{$R *.res}
function WindowProc(hwnd: HWND; msg: UINT; wp: WPARAM; lp: LPARAM): LRESULT; stdcall;
begin
case Msg of
WM_LBUTTONDOWN:
MessageBox(hwndListView,'你好!','提示',MB_OK);
end;
Result := CallWindowProc(TFNWndProc(oldWndProc), hwnd, msg, wp, lp);
end;
function TmHookProc(nCode: Integer; wParam: WPARAM; lParam: LPARAM): Integer; stdcall;
var
cwp: PCwpStruct;
m:TPoint;
begin
Result := 0;
if (nCode < 0) then
begin
Result := CallNextHookEx(hhook, nCode, wParam, lParam);
exit;
end;
cwp := PCwpStruct(lParam);
if cwp^.message <> WM_COMMAND then
begin
Result := CallNextHookEx(hhook, nCode, wParam, lParam);
exit;
end;
GetCursorPos(m);
GetWindowText(WindowFromPoint(m),na,299);
if lstrcmpi('发送(S)',na) <>0 then
begin
Result := CallNextHookEx(hhook, nCode, wParam, lParam);
exit;
end;
hwndListView:=WindowFromPoint(m);
oldWndProc := SetWindowLong(hwndListView, GWL_WNDPROC, Integer(@WindowProc));
end;
procedure Hook(bEnable: Boolean); stdcall; export;
begin
if bEnable then
begin
if hhook = 0 then
begin
hhook := SetWindowsHookEx(WH_CALLWNDPROC, TmHookProc, HInstance, 0);
end;
end
else
begin
if hhook <> 0 then
begin
UnhookWindowsHookEx(hhook);
hhook := 0;
end;
end;
end;
exports
Hook;
begin
hhook := 0;
hwndListView := 0;
oldWndProc:=0;
end.
到底哪里错了,一运行,qq就自动关闭??
解决方案 »
- 请问高手门MEMO控件的基础应用
- 如何把一个16位的16进制数压缩(加密)成4位或5位.
- SQL Server服务帐户选择不对而使天心ERP死机??
- Access导入到sql server2000中,怎么导啊,在线,马上给分
- 如何在DELPHI 程序中创建数据库 和修改表名? 急用 HELPING!!!!!!!!!!!
- 请给小妹帮个忙
- Quickrep报表在窗体SHOW时有数据,而预览时无数据,如何解决该问题?
- 数据库
- 如何删除一个table1表中的所有记录!
- var p: TfrPictureView;显示未定义? 怎么解决
- 请教一个Delphi编写ActiveX的初级问题,请人帮助!
- 请帮看看这段代码?
还好意思说,全局钩子不是我写出来,你会个啥?
在钩子中用WindowFromPoint(m)是非常不应该的,失去了WH_CALLWNDPROC的意义。还不如用无DLL的鼠标钩子。
子类化非常容易,关键是你要找到切入点。QQ聊天时很多人都不是用鼠标去点“发送”按扭的,比如用Alt+S来发消息,你的全局钩子根本钩不住,除非你把鼠标放到按扭上单击。要实现钩住发送消息根本不是这样做的。