Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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.Threading;
- using System.Runtime.InteropServices;
- using System.Diagnostics;
- using WindowsInput;
- namespace APB
- {
- public partial class Form1 : Form
- {
- [DllImport("user32.dll")]
- public static extern IntPtr FindWindow(String sClassName, String sAppName);
- [return: MarshalAs(UnmanagedType.Bool)]
- [DllImport("user32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
- public static extern bool SetForegroundWindow(IntPtr hwnd);
- //this is just standard procedure copy and paste to get the mouse_event fucntion in user32.dll working here
- [DllImport("user32.dll")]
- static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
- [DllImport("user32.dll")]
- static extern bool GetWindowRect(IntPtr hWnd, out RECT rect);
- [DllImport("user32.dll")]
- static extern IntPtr GetDC(IntPtr hwnd);
- [DllImport("user32.dll")]
- static extern Int32 ReleaseDC(IntPtr hwnd, IntPtr hdc);
- [DllImport("gdi32.dll")]
- static extern uint GetPixel(IntPtr hdc, int nXPos, int nYPos);
- static public System.Drawing.Color GetPixelColor(int x, int y)
- {
- IntPtr hdc = GetDC(IntPtr.Zero);
- uint pixel = GetPixel(hdc, x, y);
- ReleaseDC(IntPtr.Zero, hdc);
- Color color = Color.FromArgb((int)(pixel & 0x000000FF),
- (int)(pixel & 0x0000FF00) >> 8,
- (int)(pixel & 0x00FF0000) >> 16);
- return color;
- }
- [StructLayout(LayoutKind.Sequential)]
- struct RECT
- {
- public int left;
- public int top;
- public int right;
- public int bottom;
- }
- [Flags]
- public enum MouseEventFlags
- {
- LEFTDOWN = 0x00000002,
- LEFTUP = 0x00000004,
- MIDDLEDOWN = 0x00000020,
- MIDDLEUP = 0x00000040,
- MOVE = 0x00000001,
- ABSOLUTE = 0x00008000,
- RIGHTDOWN = 0x00000008,
- RIGHTUP = 0x00000010
- }
- public Form1()
- {
- InitializeComponent();
- }
- void click(int posX, int posY)
- {
- mouse_event((int)(MouseEventFlags.LEFTDOWN), posX, posY, 0, 0);
- mouse_event((int)(MouseEventFlags.LEFTUP), posX, posY, 0, 0);
- }
- void Shoot() {
- while (1 == 1)
- {
- RECT rect;
- IntPtr APBwindow = FindWindow(null, "APB Reloaded");
- GetWindowRect(APBwindow, out rect);
- int X,Y,winX, winY,sizeX,sizeY;
- winX = rect.left;
- winY = rect.top;
- sizeX = rect.right;
- sizeY = rect.bottom;
- if (InputSimulator.IsKeyDown(VirtualKeyCode.RBUTTON) == true)
- {
- for (int i = 1; i <= 10; i++)
- {
- if (i == 1)
- {
- Thread.Sleep(250);
- if (GetPixelColor(winX + (sizeX * 803/1763), winY + (sizeY *488/984)).G < 140 & GetPixelColor(winX + (sizeX * 803/1763), winY + (sizeY *488/984)).B < 140 & GetPixelColor(winX + (sizeX * 803/1763), winY + (sizeY *488/984)).R > 170)
- {
- X = Cursor.Position.X;
- Y = Cursor.Position.Y;
- click(0, 0);
- Thread.Sleep(150);
- }
- }
- else if (i > 1)
- {
- if (GetPixelColor(winX + (sizeX * 803/1763), winY + (sizeY *488/984)).G < 140 & GetPixelColor(winX + (sizeX * 803/1763), winY + (sizeY *488/984)).B < 140 & GetPixelColor(winX + (sizeX * 803/1763), winY + (sizeY *488/984)).R > 170)
- {
- X = Cursor.Position.X;
- Y = Cursor.Position.Y;
- click(0, 0);
- Thread.Sleep(150);
- }
- }
- if (InputSimulator.IsKeyDown(VirtualKeyCode.RBUTTON) == false)
- {
- break;
- }
- Thread.Sleep(1);
- }
- Thread.Sleep(1);
- }
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- ThreadStart APBshoot = new ThreadStart(Shoot);
- Thread APBActive = new Thread(APBshoot);
- APBActive.Start();
- IntPtr APBwindow = FindWindow(null, "APB Reloaded");
- SetForegroundWindow(APBwindow);
- }
- private void button2_Click(object sender, EventArgs e)
- {
- foreach (Process clsProcess in Process.GetProcesses())
- {
- if (clsProcess.ProcessName.StartsWith("APBbot"))
- {
- clsProcess.Kill();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement