This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to make a mouse autoclicker?

if(radio_data[APP_MOUSE_BUTTONS]==0x09)
        {

}
        else if(radio_data[APP_MOUSE_BUTTONS]==0x0A)
        {

         }


how to modify the button to autoclicker? Thanks!

Parents
  • You can create a simple mouse auto clicker but for that you need to have a basic understanding of doing coding.

    Step 1:

    Firstly you can create a simple form and declare a variable which will hold the cursor location:

    //this will hold the location where to click
    Point clickLocation = new Point(0,0);
    Step 2:
    After that we would be needing the countdown timer
    private void btnSetPoint_Click(object sender, EventArgs e)
    {
       timerPoint.Interval = 5000;
       timerPoint.Start();
    }
    
    
    Step 3:
    We also create a timer to help us get the mouse location. We can get the mouse location from the Position property of the Cursor class.
    private void timerPoint_Tick(object sender, EventArgs e)
    {
    clickLocation = Cursor.Position;
    //show the location on window title
    this.Text = "autoclicker " + clickLocation.ToString();
    timerPoint.Stop();
    }
    
    
    Step 4:
    Now we have to declare the main interval
    [DllImport("User32.dll", SetLastError = true)]
    public static extern int SendInput(int nInputs, ref INPUT pInputs,
    int cbSize);
    
    
    Step 5:
    To keep things simple, we will use only one INPUT structure. We will need to define this structure and some constants too:
    //mouse event constants
    const int MOUSEEVENTF_LEFTDOWN = 2;
    const int MOUSEEVENTF_LEFTUP = 4;
    //input type constant
    const int INPUT_MOUSE = 0;

    public struct MOUSEINPUT
    {
    public int dx;
    public int dy;
    public int mouseData;
    public int dwFlags;
    public int time;
    public IntPtr dwExtraInfo;
    }

    public struct INPUT
    {
    public uint type;
    public MOUSEINPUT mi;
    };
    
    
    Step 5:
    Each time our timer elapses, we want to click. We do it by moving the cursor to the memorized place, then setting up the INPUT structure and filling it with required values.
    private void timer1_Tick(object sender, EventArgs e)
    {
    //set cursor position to memorized location
    Cursor.Position = clickLocation;
    //set up the INPUT struct and fill it for the mouse down
    INPUT i = new INPUT();
    i.type = INPUT_MOUSE;
    i.mi.dx = 0;
    i.mi.dy = 0;
    i.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
    i.mi.dwExtraInfo = IntPtr.Zero;
    i.mi.mouseData = 0;
    i.mi.time = 0;
    //send the input
    SendInput(1, ref i, Marshal.SizeOf(i));
    //set the INPUT for mouse up and send it
    i.mi.dwFlags = MOUSEEVENTF_LEFTUP;
    SendInput(1, ref i, Marshal.SizeOf(i));
    }
    
    
    Step 6:
    Finally - we can use a button to start/stop the autoclicking feature. Let's create a button with the following handler:
    private void btnStart_Click(object sender, EventArgs e)
    {
    timer1.Interval = (int)numericUpDown1.Value;
    if (!timer1.Enabled)
    {
    timer1.Start();
    this.Text = "autoclicker - started";
    }
    else
    {
    timer1.Stop();
    this.Text = "autoclicker - stopped";
    }
    }
    
    
    ELSE:

    I also suggest to look at the few free mouse auto clickers available for free online.
    I prefer Murgee auto clicker or you can choose the one as per your requirements.
    These are the few auto clickers available in the market see here >> www.clickspeedtester.com/auto-clicker



Reply
  • You can create a simple mouse auto clicker but for that you need to have a basic understanding of doing coding.

    Step 1:

    Firstly you can create a simple form and declare a variable which will hold the cursor location:

    //this will hold the location where to click
    Point clickLocation = new Point(0,0);
    Step 2:
    After that we would be needing the countdown timer
    private void btnSetPoint_Click(object sender, EventArgs e)
    {
       timerPoint.Interval = 5000;
       timerPoint.Start();
    }
    
    
    Step 3:
    We also create a timer to help us get the mouse location. We can get the mouse location from the Position property of the Cursor class.
    private void timerPoint_Tick(object sender, EventArgs e)
    {
    clickLocation = Cursor.Position;
    //show the location on window title
    this.Text = "autoclicker " + clickLocation.ToString();
    timerPoint.Stop();
    }
    
    
    Step 4:
    Now we have to declare the main interval
    [DllImport("User32.dll", SetLastError = true)]
    public static extern int SendInput(int nInputs, ref INPUT pInputs,
    int cbSize);
    
    
    Step 5:
    To keep things simple, we will use only one INPUT structure. We will need to define this structure and some constants too:
    //mouse event constants
    const int MOUSEEVENTF_LEFTDOWN = 2;
    const int MOUSEEVENTF_LEFTUP = 4;
    //input type constant
    const int INPUT_MOUSE = 0;

    public struct MOUSEINPUT
    {
    public int dx;
    public int dy;
    public int mouseData;
    public int dwFlags;
    public int time;
    public IntPtr dwExtraInfo;
    }

    public struct INPUT
    {
    public uint type;
    public MOUSEINPUT mi;
    };
    
    
    Step 5:
    Each time our timer elapses, we want to click. We do it by moving the cursor to the memorized place, then setting up the INPUT structure and filling it with required values.
    private void timer1_Tick(object sender, EventArgs e)
    {
    //set cursor position to memorized location
    Cursor.Position = clickLocation;
    //set up the INPUT struct and fill it for the mouse down
    INPUT i = new INPUT();
    i.type = INPUT_MOUSE;
    i.mi.dx = 0;
    i.mi.dy = 0;
    i.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
    i.mi.dwExtraInfo = IntPtr.Zero;
    i.mi.mouseData = 0;
    i.mi.time = 0;
    //send the input
    SendInput(1, ref i, Marshal.SizeOf(i));
    //set the INPUT for mouse up and send it
    i.mi.dwFlags = MOUSEEVENTF_LEFTUP;
    SendInput(1, ref i, Marshal.SizeOf(i));
    }
    
    
    Step 6:
    Finally - we can use a button to start/stop the autoclicking feature. Let's create a button with the following handler:
    private void btnStart_Click(object sender, EventArgs e)
    {
    timer1.Interval = (int)numericUpDown1.Value;
    if (!timer1.Enabled)
    {
    timer1.Start();
    this.Text = "autoclicker - started";
    }
    else
    {
    timer1.Stop();
    this.Text = "autoclicker - stopped";
    }
    }
    
    
    ELSE:

    I also suggest to look at the few free mouse auto clickers available for free online.
    I prefer Murgee auto clicker or you can choose the one as per your requirements.
    These are the few auto clickers available in the market see here >> www.clickspeedtester.com/auto-clicker



Children
No data