[C#]Pixel Aimbot Example

02/03/2012 11:15 I don't have a username#1
I would not recommend using this nor ever using a pixel aimbot. It's a simply bad way to do it.

Code:
        //This is the native call to the mouse event.
        [System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto, CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
        public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);

        //mouse buttons
        private const int MOUSEEVENTF_LEFTDOWN = 0x02;
        private const int MOUSEEVENTF_LEFTUP = 0x04;
        private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
        private const int MOUSEEVENTF_RIGHTUP = 0x10;

        /// <summary>
        /// Finding a certain pixel in the screen.
        /// </summary>
        /// <param name="SnapShot">The snapshot need to be a screenshot of the whole screen!!</param>
        /// <param name="ColorToFind">Which color to find.</param>
        /// <returns></returns>
        public Point FindPixel(Image Screen, Color ColorToFind)
        {
            Bitmap bit = new Bitmap(Screen);

            for (int y = 0; y < Screen.Height; y++)
            {

                for (int x = 0; x < Screen.Width; x++)
                {
                    Color c = bit.GetPixel(x, y);
                    if (c == ColorToFind)
                        return new Point(x + this.Location.X, y + this.Location.Y);
                }
            }

            return new Point(0, 0);
        }

        /// <summary>
        /// Starting the aimbot.
        /// </summary>
        public void Aimbot()
        {
            while (true)
            {
                //This method need to be created by you, so it's not an exaclt handover!
                Image Screen = GetScreen();

                //Will find a pink color on the screen.
                //What you could do to improve the performance is making a check,
                //if there is more than at least 10 pixels in row both h/w that is same.
                //Then you could make the avatars in the client have a certain color and it would aim for that,
                //or you could make the shadow have a certain color.
                //You could also make a color range like checking if colors are close ot being the same.
                //However it's more advanced and it would be up to you, I'm not going to hand everything over.
                Point Aim = FindPixel(Screen, Color.Pink);

                //will set the mouse to the location where the pixel was found.
                SetMouseLocation(Aim);

                //Will send the mouseclick event. True for right click, false for left click.
                SendClick(Aim, true);
            }
        }

        /// <summary>
        /// Sending the mouseclick event.
        /// </summary>
        /// <param name="Loc">The location.</param>
        /// <param name="Skill">If it's a skill or not.</param>
        public void SendClick(Point Loc, bool Skill)
        {
            if (Skill)
                mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, (uint)Loc.X, (uint)Loc.Y, 0, 0);
            else
                mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, (uint)Loc.X, (uint)Loc.Y, 0, 0);
        }

        /// <summary>
        /// Setting the position of the mouse.
        /// </summary>
        /// <param name="Loc">The location.</param>
        public void SetMouseLocation(Point Loc)
        {
            Cursor.Position = new Point(Loc.X, Loc.Y);
        }
02/03/2012 14:41 injection illusion logic#2
without reading the rest of code , here what i thought it will be doing
hits the shadow even in the mid of air
keep hitting and rape stamina
eff. with high ping will be 20/100
so its fail but thanks for sharing the idea
btw i made a pixel aimbot for crossfire , the point is that it was too slow in updating farms to aim a new pixel which was the main reason i stopped developing it , it was a bit laggy cuz it was updating 5 frames per sec and the game was +40 fps