Chào mừng đến với Diễn đàn lập trình - Cộng đồng lập trình.
Trang 1 của 2 12 CuốiCuối
Kết quả 1 đến 10 của 12
  1. #1
    Ngày tham gia
    Sep 2015
    Đang ở
    Số 60 Thái Hà, Đống Đa, Hà Nội
    Bài viết
    0

    Cài đặt local hook keyboard lên 1 ứng dụng cụ thể khác như thế nào

    Mình đọc hướng dẫn và tự làm hook
    mình muốn ở 1 ứng dụng khác, khi ấn nút H thì sẽ có 1 message box hiện ra
    nhưng ko được,

    Mã:
    HHOOK hHook;LRESULT CALLBACK HookProc(int nCode,WPARAM wParam,LPARAM lParam){    if (nCode>=0&&nCode==HC_ACTION)    {        PMSG pMsg=(MSG*)lParam;        if(pMsg->message==WM_KEYDOWN)        {            char ch=LOBYTE(wParam);            if(ch=='h'||ch=='H')            {                MessageBox(HWND_DESKTOP,"Done","Thong bao",MB_OK);            }        }    }    return CallNextHookEx(hHook,nCode,wParam,lParam);}void SetHook(){    HWND hwnd=FindWindow("MainWindow","Plants vs. Zombies");    if (hwnd==NULL)    {        MessageBox(HWND_DESKTOP,"Start game fist","Thong bao",MB_OK);        return;    }    DWORD dwThreadID=0;    GetWindowThreadProcessId(hwnd,&dwThreadID);        hHook=SetWindowsHookEx(WH_KEYBOARD,(HOOKPROC)HookProc,hInst,dwThreadID);}  .....        case WM_DESTROY:            UnhookWindowsHookEx(hHook);            PostQuitMessage(0);            break;...............

  2. #2
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Hồi trước mình tập hook cũng bị cái lỗi này:

    Mã:
    PMSG pMsg=(MSG*)lParam;
    Cái này trong tài liệu viết sai đó. Sửa cái if như zay nè:


    Mã:
        if (nCode>=0&&nCode==HC_ACTION)    {                if(!(lParam>>31)) //Key down        {            char ch=LOBYTE(wParam);            if(ch=='h'||ch=='H')            {                MessageBox(HWND_DESKTOP,"Done","Thong bao",MB_OK);            }        }    }
    Vì tham số lParam, bit thứ 31 (cao nhất) là 0 thì KEYDOWN, 1 là KEYUP
    Tham khảo thêm
    http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx

  3. #3
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Thậm chí mình làm như này vẫn ko được

    Mã:
    LRESULT CALLBACK QProc(int nCode,WPARAM wParam,LPARAM lParam){    MessageBox(HWND_DESKTOP,"Done","Thong bao",MB_OK);    if (nCode>=0&&nCode==HC_ACTION)    {        if(!(lParam>>31)) //Key down        {            char ch=LOBYTE(wParam);            if(ch=='h'||ch=='H')            {                MessageBox(HWND_DESKTOP,"Done","Thong bao",MB_OK);            }        }    }    return CallNextHookEx(hHook,nCode,wParam,lParam);}
    full code của mình :


    Mã:
    // qmod.cpp : Defines the entry point for the application.// #include "stdafx.h"#include "resource.h"  #define MAX_LOADSTRING 100 // Global Variables:HINSTANCE hInst;                                // current instanceTCHAR szTitle[MAX_LOADSTRING];                              // The title bar textTCHAR szWindowClass[MAX_LOADSTRING];                                // The title bar text // Foward declarations of functions included in this code module:ATOM                MyRegisterClass(HINSTANCE hInstance);BOOL                InitInstance(HINSTANCE, int);LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);LRESULT CALLBACK    About(HWND, UINT, WPARAM, LPARAM);    //my functionvoid InfiniteSunPower(){    HWND hwnd=FindWindow("MainWindow","Plants vs. Zombies");    if (hwnd)    {        DWORD pid;        GetWindowThreadProcessId(hwnd,&pid);        HANDLE handle=OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_OPERATION|PROCESS_VM_WRITE|PROCESS_VM_READ,FALSE,pid);         unsigned char v[6]={0x90,0x90,0x90,0x90,0x90,0x90};        char *address=(char*)0x41BA76 ;         WriteProcessMemory(handle,address,v,6,0);       }}void AddSunPower(int n=200){    HWND hwnd=FindWindow("MainWindow","Plants vs. Zombies");    if (hwnd)    {        DWORD pid;        GetWindowThreadProcessId(hwnd,&pid);        HANDLE handle=OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_OPERATION|PROCESS_VM_WRITE|PROCESS_VM_READ,FALSE,pid);                        char *address=(char*)0x6a9ec0;         char *raddress;         //lan 1        ReadProcessMemory(handle,address,&raddress,4,0);        address=raddress+0x768;         //lan 2        ReadProcessMemory(handle,address,&raddress,4,0);        address=raddress+0x5560;         int temp;        ReadProcessMemory(handle,address,&temp,4,0);        temp+=n;        WriteProcessMemory(handle,address,&temp,4,0);       }} void SetChargeRate(int n=20){    HWND hwnd=FindWindow("MainWindow","Plants vs. Zombies");    if (hwnd)    {        DWORD pid;        GetWindowThreadProcessId(hwnd,&pid);        HANDLE handle=OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_VM_OPERATION|PROCESS_VM_WRITE|PROCESS_VM_READ,FALSE,pid);                if (n>250) n=250; else if (n<1) n=1;        unsigned char v=(unsigned char)n;        char *address=(char*)0x48728F ;         WriteProcessMemory(handle,address,&v,1,0);      }} HHOOK hHook;LRESULT CALLBACK QProc(int nCode,WPARAM wParam,LPARAM lParam){    MessageBox(HWND_DESKTOP,"Done","Thong bao",MB_OK);    if (nCode>=0&&nCode==HC_ACTION)    {        if(!(lParam>>31)) //Key down        {            char ch=LOBYTE(wParam);            if(ch=='h'||ch=='H')            {                MessageBox(HWND_DESKTOP,"Done","Thong bao",MB_OK);            }        }    }    return CallNextHookEx(hHook,nCode,wParam,lParam);}void SetHook(){    HWND hwnd=FindWindow("MainWindow","Plants vs. Zombies");    if (hwnd==NULL)    {        MessageBox(HWND_DESKTOP,"Start game fist","Thong bao",MB_OK);        return;    }    DWORD dwThreadID=0;    GetWindowThreadProcessId(hwnd,&dwThreadID);        hHook=SetWindowsHookEx(WH_KEYBOARD,(HOOKPROC)QProc,hInst,dwThreadID);}  int APIENTRY WinMain(HINSTANCE hInstance,                     HINSTANCE hPrevInstance,                     LPSTR     lpCmdLine,                     int       nCmdShow){    SetHook();     // TODO: Place code here.    MSG msg;    //HACCEL hAccelTable;     // Initialize global strings    LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);    LoadString(hInstance, IDC_QMOD, szWindowClass, MAX_LOADSTRING);     MyRegisterClass(hInstance);     // Perform application initialization:    if (!InitInstance (hInstance, nCmdShow))     {        return FALSE;    }     //hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_QMOD);     // Main message loop:    while (GetMessage(&msg, NULL, 0, 0))     {        TranslateMessage(&msg);        DispatchMessage(&msg);    }     return msg.wParam;}   ////  FUNCTION: MyRegisterClass()////  PURPOSE: Registers the window class.////  COMMENTS:////    This function and its usage is only necessary if you want this code//    to be compatible with Win32 systems prior to the 'RegisterClassEx'//    function that was added to Windows 95. It is important to call this function//    so that the application will get 'well formed' small icons associated//    with it.//ATOM MyRegisterClass(HINSTANCE hInstance){    WNDCLASSEX wcex;     wcex.cbSize = sizeof(WNDCLASSEX);      wcex.style          = CS_HREDRAW | CS_VREDRAW;    wcex.lpfnWndProc    = (WNDPROC)WndProc;    wcex.cbClsExtra     = 0;    wcex.cbWndExtra     = 0;    wcex.hInstance      = hInstance;    wcex.hIcon          = LoadIcon(hInstance, (LPCTSTR)IDI_QMOD);    wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);    wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);    wcex.lpszMenuName   = NULL;    wcex.lpszClassName  = szWindowClass;    wcex.hIconSm        = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);     return RegisterClassEx(&wcex);} ////   FUNCTION: InitInstance(HANDLE, int)////   PURPOSE: Saves instance handle and creates main window////   COMMENTS:////        In this function, we save the instance handle in a global variable and//        create and display the main program window.//BOOL InitInstance(HINSTANCE hInstance, int nCmdShow){   HWND hWnd;    hInst = hInstance; // Store instance handle in our global variable    hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,      100, 100, 300, 300, NULL, NULL, hInstance, NULL);    if (!hWnd)   {      return FALSE;   }    //SetLayeredWindowAttributes(hWnd,RGB(0,0,0),255/100*70,LWA_ALPHA);    ShowWindow(hWnd, nCmdShow);   UpdateWindow(hWnd);    return TRUE;} ////  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)////  PURPOSE:  Processes messages for the main window.////  WM_COMMAND  - process the application menu//  WM_PAINT    - Paint the main window//  WM_DESTROY  - post a quit message and return////LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){    int wmId, wmEvent;    PAINTSTRUCT ps;    HDC hdc;    CHAR xau[100];    HFONT font;    PLOGFONT plf;     switch (message)     {        case WM_COMMAND:            wmId    = LOWORD(wParam);             wmEvent = HIWORD(wParam);             // Parse the menu selections:            switch (wmId)            {                case IDM_ABOUT:                   //DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);                   break;                case IDM_EXIT:                   DestroyWindow(hWnd);                   break;                default:                   return DefWindowProc(hWnd, message, wParam, lParam);            }            break;        case WM_PAINT:            hdc = BeginPaint(hWnd, &ps);            // TODO: Add any drawing code here...            RECT rt;            GetClientRect(hWnd, &rt);             SetBkMode(hdc,TRANSPARENT);             plf=(PLOGFONT)LocalAlloc(LPTR, sizeof(LOGFONT));             lstrcpy(plf->lfFaceName, "Arial");             plf->lfWeight = FW_NORMAL;             plf->lfHeight=26;            font = CreateFontIndirect(plf);             SelectObject(hdc,font);             strcpy(xau,"Plants vs. Zombies Mod");            SetTextColor(hdc,RGB(255,0,0));            ExtTextOut(hdc,(rt.right-rt.left)/2-120,10,ETO_CLIPPED,&rt,xau,strlen(xau),NULL);                         lstrcpy(plf->lfFaceName, "Courier New");             plf->lfHeight=18;            font = CreateFontIndirect(plf);             SelectObject(hdc,font);            SetTextColor(hdc,RGB(255,127,39));             strcpy(xau,"H - Infinite Sun Power ");            ExtTextOut(hdc,15,50,ETO_CLIPPED,&rt,xau,strlen(xau),NULL);             strcpy(xau,"I - Infinite Game Item");            ExtTextOut(hdc,15,70,ETO_CLIPPED,&rt,xau,strlen(xau),NULL);             strcpy(xau,"G - Gaining Fast Combo");            ExtTextOut(hdc,15,90,ETO_CLIPPED,&rt,xau,strlen(xau),NULL);                 EndPaint(hWnd, &ps);            LocalFree((LOCALHANDLE) plf);            break;        case WM_DESTROY:            UnhookWindowsHookEx(hHook);            PostQuitMessage(0);            break;        default:            return DefWindowProc(hWnd, message, wParam, lParam);   }   return 0;}

  4. #4
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    theo mình thì có thể cái hook vào nó anti oy
    bạn thử cài hook dưới dạng global hook xem sao
    ở box hướng dẫn có bài "hook dành cho người mới" bạn ý cài hook global được

  5. #5
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    MFC có thể làm như sau (Peter lấy ví dụ như là Notepad chẳng hạn nhé, khi bạn nhấn phím vào đó (cửa sổ Edit) thì xuất hiện MessageBox thông báo "Thanh cong roi do!"):
    - Lấy Handle cửa sổ đang Focus bằng hàm GetFocus(), đặt là h.
    - Lấy Handle cửa sổ cha chứa cửa sổ nhận phím nhấn bằng hàm FindWindow(), đặt là h1 (Cửa sổ Notepad có title là "Untitled - Notepad").
    - Lấy cửa sổ con nhận sự kiện nhấn phím bằng hàm FindWindowEx(), đặt là h2 (Chính là cửa sổ có Class name là "Edit", dùng Spy++ để check).
    - So sánh h với h2, nếu bằng nhau và nhấn phím thì tạo MessageBox; còn ngược lại thì CallNextHookEx().
    Vậy chúng ta có thể tạo một dll chứa hàm lọc phím LowLevelKeyboardProc(), code:

    Mã:
    // Dll_Demo.cpp : Defines the entry point for the DLL application.// #include "windows.h"LRESULT _stdcall CALLBACK LowLevelKeyboardProc( int nCode, WPARAM wParam, LPARAM lParam ){    HWND h=GetFocus();  //Lay Handle cua so dang focus    HWND h1=FindWindow(NULL,"Untitled - Notepad");  //Lay Handle cua so cha    HWND h2=FindWindowEx(h1,0,"Edit",NULL);         //Lay Handle cua so con nhan Su kien nhan phim        if ((h==h2)&&((DWORD)lParam & 0x40000000) &&(HC_ACTION==nCode))  //Neu cua so Focus trung voi cua so nhan Su kien nhan phim    {        MessageBox(HWND_DESKTOP,"Thanh cong roi do!","Thong bao!",MB_OK);    }    LRESULT RetVal = CallNextHookEx( NULL, nCode, wParam, lParam );    return RetVal;}
    Biên dịch được Dll_Demo.dll.

    Tiếp tục chúng ta set hook trong code exe như sau:

    Mã:
    // Test_Demo.cpp : Defines the entry point for the application.// #include "stdafx.h"#include "resource.h" #define MAX_LOADSTRING 100HHOOK hhk;// Global Variables:HINSTANCE hInst;                                // current instanceTCHAR szTitle[MAX_LOADSTRING];                              // The title bar textTCHAR szWindowClass[MAX_LOADSTRING];                                // The title bar text // Foward declarations of functions included in this code module:ATOM                MyRegisterClass(HINSTANCE hInstance);BOOL                InitInstance(HINSTANCE, int);LRESULT CALLBACK    WndProc(HWND, UINT, WPARAM, LPARAM);LRESULT CALLBACK    About(HWND, UINT, WPARAM, LPARAM); int APIENTRY WinMain(HINSTANCE hInstance,                     HINSTANCE hPrevInstance,                     LPSTR     lpCmdLine,                     int       nCmdShow){        // TODO: Place code here.    //Thao tac truoc khi cai Hook    typedef LRESULT (CALLBACK *ptr)(int, WPARAM,LPARAM);    HINSTANCE Lib = LoadLibrary("Dll_Demo.dll");    ptr LowLevelKeyboardProc;    if (Lib == NULL)    {        return 0;    }    //Lay address LowLevelKeyboardProc()    LowLevelKeyboardProc = (ptr)GetProcAddress(Lib, "LowLevelKeyboardProc");    if (LowLevelKeyboardProc == NULL)    {        return 0;    }    //Lay Handle Dll_Demo.DLL    HMODULE appInstance = GetModuleHandle("Dll_Demo.DLL");    //Cai Hook    hhk=SetWindowsHookEx(WH_KEYBOARD, LowLevelKeyboardProc, appInstance, 0);            MSG msg;    HACCEL hAccelTable;        // Initialize global strings    LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);    LoadString(hInstance, IDC_TEST_DEMO, szWindowClass, MAX_LOADSTRING);    MyRegisterClass(hInstance);        // Perform application initialization:    if (!InitInstance (hInstance, nCmdShow))     {        return FALSE;    }        hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_TEST_DEMO);        // Main message loop:    while (GetMessage(&msg, NULL, 0, 0))     {        if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))         {            TranslateMessage(&msg);            DispatchMessage(&msg);        }    }        return msg.wParam;}   ////  FUNCTION: MyRegisterClass()////  PURPOSE: Registers the window class.////  COMMENTS:////    This function and its usage is only necessary if you want this code//    to be compatible with Win32 systems prior to the 'RegisterClassEx'//    function that was added to Windows 95. It is important to call this function//    so that the application will get 'well formed' small icons associated//    with it.//ATOM MyRegisterClass(HINSTANCE hInstance){    WNDCLASSEX wcex;        wcex.cbSize = sizeof(WNDCLASSEX);         wcex.style          = CS_HREDRAW | CS_VREDRAW;    wcex.lpfnWndProc    = (WNDPROC)WndProc;    wcex.cbClsExtra     = 0;    wcex.cbWndExtra     = 0;    wcex.hInstance      = hInstance;    wcex.hIcon          = LoadIcon(hInstance, (LPCTSTR)IDI_TEST_DEMO);    wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);    wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);    wcex.lpszMenuName   = (LPCSTR)IDC_TEST_DEMO;    wcex.lpszClassName  = szWindowClass;    wcex.hIconSm        = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);        return RegisterClassEx(&wcex);} ////   FUNCTION: InitInstance(HANDLE, int)////   PURPOSE: Saves instance handle and creates main window////   COMMENTS:////        In this function, we save the instance handle in a global variable and//        create and display the main program window.//BOOL InitInstance(HINSTANCE hInstance, int nCmdShow){    HWND hWnd;        hInst = hInstance; // Store instance handle in our global variable        hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,        CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);        if (!hWnd)    {        return FALSE;    }        ShowWindow(hWnd, nCmdShow);    UpdateWindow(hWnd);        return TRUE;} ////  FUNCTION: WndProc(HWND, unsigned, WORD, LONG)////  PURPOSE:  Processes messages for the main window.////  WM_COMMAND  - process the application menu//  WM_PAINT    - Paint the main window//  WM_DESTROY  - post a quit message and return////LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){    int wmId, wmEvent;    PAINTSTRUCT ps;    HDC hdc;    TCHAR szHello[MAX_LOADSTRING];    LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);                switch (message)     {    case WM_COMMAND:        wmId    = LOWORD(wParam);         wmEvent = HIWORD(wParam);         // Parse the menu selections:        switch (wmId)        {        case IDM_ABOUT:            DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);            break;        case IDM_EXIT:            DestroyWindow(hWnd);            break;        default:            return DefWindowProc(hWnd, message, wParam, lParam);        }        break;        case WM_PAINT:            hdc = BeginPaint(hWnd, &ps);            // TODO: Add any drawing code here...            RECT rt;            GetClientRect(hWnd, &rt);            DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);            EndPaint(hWnd, &ps);            break;        case WM_DESTROY:            UnhookWindowsHookEx(hhk);            PostQuitMessage(0);            break;        default:            return DefWindowProc(hWnd, message, wParam, lParam);    }    return 0;} // Mesage handler for about box.LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam){    switch (message)    {    case WM_INITDIALOG:        return TRUE;            case WM_COMMAND:        if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)         {            EndDialog(hDlg, LOWORD(wParam));            return TRUE;        }        break;    }    return FALSE;}
    Ở đây Peter dùng luôn project "Hello World!" để làm exe. Bạn hãy chú ý việc cài Hook và hủy Hook.

    Kết quả là mỗi khi nhấn phím trên Notepad thì chúng ta nhận được một thông báo! Have fun. Đây là code Demo:

    p/s: Bạn có thể Hook mà không cần dll.

  6. #6
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Trích dẫn Gửi bởi peterdrew
    Code

    p/s: Bạn có thể Hook mà không cần dll.
    tuyệt quá
    cám ơn anh Peter, em rất thích cái ý tưởng của anh


    ah, cho e hỏi với, e cũng mới tập hook, nhưng e chưa biết cài hook ko có dll như nào,
    a có thể cho em 1 demo được ko à
    cool cool
    cám ơn anh

    More : dạo này em bỏ VS2010, xài vc++6.0 portable, thấy nó hay vì nó đơn giản và nhẹ nhàng thích oy anh à

  7. #7
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Anh có thể dùng idHook
    WH_KEYBOARD_LL đối với bàn phím
    WH_MOUSE_LL đối với chuột
    Phạm vi của những ID này là Global không cần dll vẫn hook đc.

  8. #8
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Trích dẫn Gửi bởi tucute89
    Anh có thể dùng idHook
    WH_KEYBOARD_LL đối với bàn phím
    WH_MOUSE_LL đối với chuột
    Phạm vi của những ID này là Global không cần dll vẫn hook đc.
    à
    thảo nào
    trong VC6.0 nó ko có cái này, phải tự định nghĩa thêm vào
    #define WH_KEYBOARD_LL 13
    #define WH_MOUSE_LL 14

  9. #9
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Ai cho mình cái ví dụ đc. ko

  10. #10
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Trích dẫn Gửi bởi Học Hỏi
    cái này cũng nghe nói lâu rồi nhưng search mãi thấy mỗi bắt 1 phím được nhấn ... edit hoài thành bắt 1 phím cố đính không được :-( ...

    cậu có thể demo cho mình hook global phím enter mỗi khi được nhấn bắn ra 1 mess được không ?
    Dùng MessageBox bị 1 lỗi . Nên tớ in tạm ra màn hình console bạn coi tạm nhé (=^_^=)
    Mình test trên VC++ 2010 -> Project Win32Console


    Mã:
    #include "stdafx.h" //////////////////////////////////////////////////////////////////////////using namespace std; LRESULT CALLBACK LowLevelKeyboardProc(int nCode,WPARAM wParam,LPARAM lParam ){     if ( nCode == HC_ACTION && wParam == WM_KEYDOWN ){         PKBDLLHOOKSTRUCT pp = (PKBDLLHOOKSTRUCT)lParam;        if( pp->scanCode == 28 ){             cout << "
     Vua An Enter ... " ;        }    }     return CallNextHookEx(NULL,nCode,wParam,lParam);}  //////////////////////////////////////////////////////////////////////////int _tmain(int argc, _TCHAR* argv[]){             HHOOK hHook = SetWindowsHookEx(WH_KEYBOARD_LL,LowLevelKeyboardProc,GetModuleHandle(0),0);    if ( !hHook )    {        cout << "
     Error: " << GetLastError();        return 0;    }    MSG msg;     while( !GetMessage(&msg,NULL,0,0)){         DispatchMessage(&msg);        TranslateMessage(&msg);    }    getch();    return 0;}

 

 
Trang 1 của 2 12 CuốiCuối

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •