Friday, March 23, 2012

C# Warcraft 3 Hero Line Wars AutoClicker

Hello There!

So this post is for the Warcraft 3 players!
If you play in the battle.net you probably came across with my favorite custom game.
Hero Line Wars!

Why do we Need an Autoclicker for this?
Everytime you want to buy a creature you can click on an hotkey to buy it, so my program just clicks for you the requested times.



Very simple program, using mostly the RegisterHotKey command (explanation on the AutoClicker Post).
Here is the Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Threading;

namespace Warcraft3HLW
{
    public partial class Form1 : Form
    {
        [DllImport("user32.dll")]
        private static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vlc);

        [DllImport("user32.dll")]
        private static extern bool UnregisterHotKey(IntPtr hWnd, int id);

        static bool run = false;
        
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            RegisterHotKey(this.Handle, (int)Keys.NumPad0, 0, (int)Keys.NumPad0);
        }

        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);

            if (m.Msg == 0x312)
            {

                Keys key = (Keys)(((int)m.LParam >> 16) & 0xFFFF);
                if (key == Keys.NumPad0 && run)
                {
                    run = !run;
                    UnregisterHotKey(this.Handle, (int)Keys.Q);
                    UnregisterHotKey(this.Handle, (int)Keys.W);
                    UnregisterHotKey(this.Handle, (int)Keys.E);
                    UnregisterHotKey(this.Handle, (int)Keys.R);
                    UnregisterHotKey(this.Handle, (int)Keys.T);
                    UnregisterHotKey(this.Handle, (int)Keys.A);
                    UnregisterHotKey(this.Handle, (int)Keys.S);
                    UnregisterHotKey(this.Handle, (int)Keys.D);
                    UnregisterHotKey(this.Handle, (int)Keys.F);
                    UnregisterHotKey(this.Handle, (int)Keys.G);
                }
                else
                {
                    if (key == Keys.NumPad0 && !run)
                    {
                        run = !run;

                        RegisterHotKey(this.Handle, (int)Keys.NumPad0, 0, (int)Keys.NumPad0);
                        RegisterHotKey(this.Handle, (int)Keys.Q, 0, (int)Keys.Q);
                        RegisterHotKey(this.Handle, (int)Keys.W, 0, (int)Keys.W);
                        RegisterHotKey(this.Handle, (int)Keys.E, 0, (int)Keys.E);
                        RegisterHotKey(this.Handle, (int)Keys.R, 0, (int)Keys.R);
                        RegisterHotKey(this.Handle, (int)Keys.T, 0, (int)Keys.T);
                        RegisterHotKey(this.Handle, (int)Keys.A, 0, (int)Keys.A);
                        RegisterHotKey(this.Handle, (int)Keys.S, 0, (int)Keys.S);
                        RegisterHotKey(this.Handle, (int)Keys.D, 0, (int)Keys.D);
                        RegisterHotKey(this.Handle, (int)Keys.F, 0, (int)Keys.F);
                        RegisterHotKey(this.Handle, (int)Keys.G, 0, (int)Keys.G);
                    }
                }
                if (run)
                {
                    string ans = "";
                    switch (key)
                    {
                        case Keys.Q:
                            ans = "Q";
                            break;

                        case Keys.W:
                            ans = "W";
                            break;

                        case Keys.E:
                            ans = "E";
                            break;

                        case Keys.R:
                            ans = "R";
                            break;

                        case Keys.T:
                            ans = "T";
                            break;

                        case Keys.A:
                            ans = "A";
                            break;

                        case Keys.S:
                            ans = "S";
                            break;

                        case Keys.D:
                            ans = "D";
                            break;

                        case Keys.F:
                            ans = "F";
                            break;

                        case Keys.G:
                            ans = "G";
                            break;
                    }
                    if (ans != "")
                    {
                        for (int i = 0; i < 30; i++)
                        {
                            SendKeys.Send(ans);
                        }
                    }
                }
            }
         
        }

        static void doit(Message m)
        {
            
        }
    }
}


Use numlock0 to start and stop the program, and click on the requested Hotkey (for example Q).

Ok so you can download this Project at the following link:
Download This Project (rar file)

Run Without compiling ->Go to the project folder ->bin ->debug -> Warcraft3HLW.exe
This is it, I made this program very simple, and without labels and stuff.

Enjoy (:
And Remember
Questions = Comments!

No comments:

Post a Comment