示例#1
0
        private void StartClick(Process mcProcess, IntPtr mainWindowHandle, uint buttonCode, int delay, int rand, bool miningMode)
        {
            SetControlPropertyThreadSafe(this.btn_start, "Enabled", false);
            SetControlPropertyThreadSafe(this.btn_stop, "Enabled", true);

            var handle = mcProcess.MainWindowHandle;

            FocusToggle(mcProcess.MainWindowHandle);

            //Ajout d'une variable random
            Random rand_obj  = new Random();
            int    randomize = rand_obj.Next(rand, rand * 2);


            SetControlPropertyThreadSafe(this.btn_start, "Text", @"Starting in: ");
            Thread.Sleep(500);

            for (var i = 5; i > 0; i--)
            {
                SetControlPropertyThreadSafe(this.btn_start, "Text", i.ToString());
                Thread.Sleep(500);
            }

            FocusToggle(mainWindowHandle);
            SetControlPropertyThreadSafe(this.btn_start, "Text", @"Running...");
            Thread.Sleep(500);

            var millisecondsPassed = -1;

            if (miningMode)
            {
                Win32Api.PostMessage(handle, (uint)buttonCode, (IntPtr)0x0001, IntPtr.Zero); // send left button down
            }
            while (!this._stop)
            {
                if (millisecondsPassed == -1 || millisecondsPassed >= delay + randomize)
                {
                    millisecondsPassed = 0;
                    if (!miningMode)
                    {
                        Win32Api.PostMessage(handle, buttonCode, IntPtr.Zero, IntPtr.Zero);
                        Win32Api.PostMessage(handle, buttonCode + 1, IntPtr.Zero, IntPtr.Zero);
                    }
                }

                // sleep only 25 ms and do the check above so if the user clicks
                // "STOP" with a like 60 second delay, they don't have to wait 60 seconds
                Thread.Sleep(5);
                millisecondsPassed += 5;
            }

            Win32Api.PostMessage(handle, buttonCode, IntPtr.Zero, IntPtr.Zero);
            Win32Api.PostMessage(handle, buttonCode + 1, IntPtr.Zero, IntPtr.Zero);

            SetControlPropertyThreadSafe(this.btn_start, "Text", @"START!");
            SetControlPropertyThreadSafe(this.btn_start, "Enabled", true);
        }
        private void Click()
        {
            Win32Api.PostMessage(minecraftHandle, buttonDownCode, IntPtr.Zero, IntPtr.Zero);
            Win32Api.PostMessage(minecraftHandle, buttonUpCode, IntPtr.Zero, IntPtr.Zero);
            int delay = rand.Next(1, 2000);

            timer.Interval = delay;
            Console.WriteLine("Random Number = " + delay);
        }
示例#3
0
        public void Start(int delay)
        {
            Stop();
            hold = (delay == 0);
            if (hold)
            {
                Win32Api.PostMessage(minecraftHandle, buttonDownCode, (IntPtr)0x0001, IntPtr.Zero);
            }

            else
            {
                Click();
                timer.Interval = delay;
                timer.Start();
            }
        }
示例#4
0
        public void Start(int delay)
        {
            Stop();
            hold = (delay == 0);

            if (hold)
            {
                //Select the minecraft handle with Alt+Tab to not stop holding (when using the program)
                Win32Api.PostMessage(minecraftHandle, buttonDownCode, (IntPtr)0x0001, IntPtr.Zero);
            }
            else
            {
                Click();
                timer.Interval = delay;
                timer.Start();
            }
        }
示例#5
0
 private void Click()
 {
     Win32Api.PostMessage(minecraftHandle, buttonDownCode, IntPtr.Zero, IntPtr.Zero);
     Win32Api.PostMessage(minecraftHandle, buttonUpCode, IntPtr.Zero, IntPtr.Zero);
 }
示例#6
0
 private void Release()
 {
     Win32Api.PostMessage(minecraftHandle, buttonUpCode, IntPtr.Zero, IntPtr.Zero);
 }