dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: I need help figuring out why this auto-clicker doesn't work on some windows.

  1. #1
    Join Date
    Jul 2018
    Posts
    1

    I need help figuring out why this auto-clicker doesn't work on some windows.

    Code:
    #ifdef __MINGW32__
    #define _WIN32_WINNT 0x0501
    #endif // __MINGW32__
    #include <iostream>
    #include <windows.h>
    #include <string>
    using namespace std;
    LPVOID mousedown {
    
    
    };
    int main()
    {
        int delay,y,clickboost,x,spin,times;
        bool tehee = false;
        POINT C;
        HWND hwnd;
        cout << "delay: ";
        cin >> delay;
        while (0==0) {
            if (GetAsyncKeyState(VK_MBUTTON)) {
                tehee = true;
                cout << "activated" << endl;
                while (GetAsyncKeyState(VK_MBUTTON)) {
    
                }
            }
            while (tehee==true) {
                    hwnd = GetForegroundWindow();
                        GetCursorPos(&C);
                        x = C.x;
                        y = C.y;
                        if (GetAsyncKeyState(VK_LBUTTON)) {
                        PostMessage(hwnd,WM_LBUTTONDOWN,MK_LBUTTON,MAKELPARAM(x,y));
                        SendMessage(hwnd,WM_SETCURSOR,(WPARAM)hwnd,MAKELPARAM(HTCLIENT,WM_LBUTTONDOWN));
                        Sleep(delay);
                        PostMessage(hwnd,WM_LBUTTONUP,MK_LBUTTON,MAKELPARAM(x,y));
                        SendMessage(hwnd,WM_SETCURSOR,(WPARAM)hwnd,MAKELPARAM(HTCLIENT,WM_LBUTTONUP));
                        Sleep(delay);
                        }
                if (GetAsyncKeyState(VK_MBUTTON)) {
                tehee = false;
                cout << "deactivated" << endl;
                while (GetAsyncKeyState(VK_MBUTTON)) {
    
                }
                }
                    }
            }
            }
    I made an auto-clicker a couple weeks back that you use 'Z' to activate and deactivate. I then thought it'd be nice to have an auto-clicker that clicks when the left mouse button is held down. I first tried a loop with mouse_event, but that puts itself in an infinite loop due to mouse_event inputting VK_LBUTTON input, so you can't use getasynckeystate. I also can't use a hook because I have sleep statements in there, and passing those through a hook would slow down the whole computer. I discovered messages, and I knew this was how I would do it. The problem is this works on most games and windows, but on games like Roblox or windows like Foobar these don't click. I tried to add adding WM_SETCURSOR to make it work, but this didn't do anything. I am at a loss as I have been at this for a while. If someone has made something like this before, I would greatly appreciate the help.

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    12,700

    Re: I need help figuring out why this auto-clicker doesn't work on some windows.

    Look at using SendInput api.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)