1,183
社区成员
发帖
与我相关
我的任务
分享
function HookProc(nCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
begin
{
case wParam of
WM_MOUSEMOVE : info := '鼠标位置';
WM_LBUTTONDOWN : info := '按下';
WM_LBUTTONUp : info := '放开';
end;
info := Format('%s: %d,%d', [info, PMouseHookStruct(lParam)^.pt.X, PMouseHookStruct(lParam)^.pt.Y]);
}
{通过消息把数据传递给指定窗口}
info:=IntToStr(wParam);
PostMessage(h, WM_MyMessage, 0, Integer(PChar(info)));
Result := CallNextHookEx(hook, nCode, wParam, lParam);
end;
function SetHook: Boolean; stdcall;
const
WH_MOUSE_LL =14;
var h:HWND; id:Cardinal;
begin
//查找到powrpointView窗体句柄
h:=FindWindow('PPTFrameClass',nil);
h:=FindWindowEx(h,0,'MDIClient',nil);
h:=FindWindowEx(h,0,'mdiClass',nil);
h:=FindWindowEx(h,0,'paneClassDC',nil);
id:=GetWindowThreadProcessId(h,nil);
hook := SetWindowsHookEx(WH_CALLWNDPROC, @HookProc, HInstance,id );
Result := hook <> 0;
end;