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);
}






