在應(yīng)用程序中跟蹤MOUSE的坐標(biāo)

    • 相關(guān)推薦

    在應(yīng)用程序中跟蹤MOUSE的坐標(biāo)

    在應(yīng)用程序中跟蹤MOUSE的坐標(biāo)

    第一步,建一DLL,DELPHI中NEW-》DLL SAVE AS GETKEYlibrary getKey;uses
    SysUtils,
    Windows,
    HookMain in hookmain.pas;exports
    OpenGetKeyHook,
    CloseGetKeyHook,
    GetPublicP;begin
    NextHook := 0;
    procSaveExit := ExitProc;
    DLLproc := @DLLMain;
    ExitProc := @HookExit;
    DLLMain(DLL_PROCESS_ATTACH);
    end.第二步,建一UNIT ,HOOK MAIN。關(guān)鍵在于CreateFileMapping 和 消息 WM_NCMouseMove, WM_MOUSEMOVE:unit HookMain; interface
    uses Windows, Messages, Dialogs, SysUtils; //type DataBuf = Array of DWORD;
    type mydata=record
    data1:array of DWORD;
    data2:TMOUSEHOOKSTRUCT;
    end;
    var hObject : Thandle;
    pMem : Pointer;
    NextHook: Hhook;
    procSaveExit: Pointer; function HookHandler(iCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall; export;
    function OpenGetKeyHook(sender : HWND;MessageID : WORD) : BOOL; export;
    function CloseGetKeyHook: BOOL; export;
    function GetPublicP : Pointer;stdcall; export;
    Procedure DLLMain(dwReason:Dword); far;
    procedure HookExit; far; implementation Procedure UnMapMem;
    begin
    if Assigned(pMem) then
    begin
    UnMapViewOfFile(pMem);
    pMem := Nil
    end;
    end; Procedure MapMem;
    begin
    hObject := CreateFileMapping($FFFFFFFF,Nil,Page_ReadWrite,0,$FFFF,pChar(_IOBuffer));
    if hObject = 0 then Raise Exception.Create(創(chuàng)建公用數(shù)據(jù)的Buffer不成? ;
    pMem := MapViewOfFile(hObject,FILE_MAP_WRITE,0,0,SizeOf(mydata));
    // 1 or SizeOf(DataBuf) ????
    // 創(chuàng)建SizeOf(DataBuf)的數(shù)據(jù)區(qū)
    if not Assigned(pMem) then
    begin
    UnMapMem;
    Raise Exception.Create(創(chuàng)建公用數(shù)據(jù)的映射關(guān)系不成功!);
    end;
    end;
    Procedure DLLMain(dwReason:Dword); far;
    begin
    Case dwReason of
    DLL_PROCESS_ATTACH :
    begin
    pMem := nil;
    hObject := 0;
    MapMem; //以下的公有數(shù)據(jù),如tHWND,tMessageID將直接使用本Buf.
    End;
    DLL_PROCESS_DETACH : UnMapMem;
    DLL_THREAD_ATTACH,
    DLL_THREAD_DETACH :; //缺省
    end;
    end; procedure HookExit; far;
    begin
    CloseGetKeyHook;
    ExitProc := procSaveExit;
    end;function GetPublicP : Pointer;export;
    begin //這里引出了公用數(shù)據(jù)區(qū)的指針,你可以在你的應(yīng)用程序中自由操作它。但建議去掉此接口。
    Result := pMem;
    end;function HookHandler(iCode: Integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall; export;
    begin
    Result := 0;
    If iCode $#@60; 0
    Then Result := CallNextHookEx(NextHook, iCode, wParam, lParam);
    // This is probably closer to what you would want to do...
    Case wparam of
    WM_LBUTTONDOWN:
    begin
    end;
    WM_LBUTTONUP:
    begin
    end;
    WM_LBUTTONDBLCLK:
    begin
    end;
    WM_RBUTTONDOWN:
    begin
    messagebeep(1);
    end;
    WM_RBUTTONUP:
    begin
    end;
    WM_RBUTTONDBLCLK:
    begin
    end;
    WM_MBUTTONDOWN:
    begin
    end;
    WM_MBUTTONUP:
    begin
    end;
    WM_MBUTTONDBLCLK:

    下一頁

    【在應(yīng)用程序中跟蹤MOUSE的坐標(biāo)】相關(guān)文章:

    跟蹤審計中存在題目及對策12-08

    視頻圖像中的車輛檢測跟蹤和分類03-18

    坐標(biāo)系在化學(xué)教學(xué)中的運用的方式分析03-16

    Blackfin系統(tǒng)引導(dǎo)過程中的多應(yīng)用程序管理03-07

    淺析極坐標(biāo)系與坐標(biāo)旋轉(zhuǎn)11-30

    實時操作系統(tǒng)VxWorks在跟蹤雷達系統(tǒng)中的應(yīng)用03-18

    電源跟蹤技術(shù)03-19

    成本管理的戰(zhàn)略坐標(biāo)03-07

    基于XML的智能應(yīng)用程序的研究03-07

    光學(xué)3D坐標(biāo)測量技術(shù)在大齒輪在位測量中的應(yīng)用03-07

    91久久大香伊蕉在人线_国产综合色产在线观看_欧美亚洲人成网站在线观看_亚洲第一无码精品立川理惠

      色综合曰本久久 | 一区二区免费精品在线观看国产 | 综合国产在线中文字幕 | 亚洲人成网国产最新在线 | 日本人妖视频一区一区 | 亚洲人成中文字幕在线观看 |