0

Im trying to develop an autoclicker for Minecraft. When I try to use the right click the autoclicker stops working(It goes to 0cps). I want to be able to use the right click while the autoclicker is still working. For example, that the program clicks 16cps and I use the right clicker and it still clicks.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Clicker3
{
    public partial class Form1 : Form
    {
        
        #region dlls
        [DllImport("user32.dll")]
        public static extern IntPtr GetForegroundWindow();

        [DllImport("user32.dll", SetLastError = true)]
        public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

        [DllImport("User32.Dll", EntryPoint = "PostMessageA")]
        public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);

        [DllImport("User32.dll")]
        public static extern short GetAsyncKeyState(System.Windows.Forms.Keys vKey); // Keys enumeration
        #endregion

        public Form1()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void sldCPS_Scroll(object sender, ScrollEventArgs e)
        {
            lbCPS.Text = $"{sldCPS.Value}";
        }

        private void LeftClicker_Tick(object sender, EventArgs e)
        {

            LeftClicker.Interval = 1000 / sldCPS.Value;

            Process[] processes = Process.GetProcessesByName("javaw");
            foreach (Process process in processes)
            {
                if (GetForegroundWindow() == FindWindow(null, process.MainWindowTitle))
                {
                    if (cbToggle.Checked)
                    {
                        if (MouseButtons == MouseButtons.Left)
                        {

                            SendMessage(GetForegroundWindow(), 0x201, 0, 0);
                            Task.Delay(20).Wait();
                            SendMessage(GetForegroundWindow(), 0x202, 0, 0);

                        }
                    }
                }
            }
        }

        private void RightClicker_Tick(object sender, EventArgs e)
        {
           
        }
    }
}
Jared
  • 1

0 Answers0