How can I detect Mouse Click simulated by SendMessage or PostMessage?

433 views Asked by At

I'm working on an anti-clicker in C++. My code works with all Programs that simulate Mouse Clicks, except for Programs which use code like this:

NativeMethods.SendMessage((IntPtr)processHandle, WM_LBUTTONDOWN, (IntPtr)1, (IntPtr)LParams(y, x));

My code:

while (TRUE) {
    struct tagMSG Msg;
    HHOOK Mouse = SetWindowsHookEx(WH_MOUSE_LL, MouseProcces, NULL, NULL);
    while (GetMessage(&Msg, GameMainWindow, 0, 0)) {
        Sleep(5000);
        TranslateMessage(&Msg);
        DispatchMessageA(&Msg);
    }
    UnhookWindowsHookEx(Mouse);
}
LRESULT CALLBACK MouseProcces(INT NCode, WPARAM WParam, LPARAM LParam) {
    if (WParam != WM_MOUSEMOVE && WParam != WM_MOUSEWHEEL)
    {
        std::cout << "click" << std::endl;
    }
    return CallNextHookEx(NULL, NCode, WParam, LParam);
}
0

There are 0 answers