Advertisement
Guest User

Untitled

a guest
Jun 20th, 2012
2,324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 8.85 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Diagnostics;
  8. using System.Text;
  9. using System.Runtime.InteropServices;
  10. using System.Threading;
  11. using System.Windows.Forms;
  12. using ReadWriteMemory;
  13.  
  14. namespace Yes
  15. {
  16.     public partial class Form1 : Form
  17.     {
  18.    
  19.         [DllImport("user32.dll", EntryPoint = "SetWindowPos", CallingConvention = CallingConvention.StdCall, SetLastError = true)]
  20.         public static extern int SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
  21.         [DllImport("user32.dll", SetLastError = true)]
  22.         static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
  23.         private const int downclick = 0x201;
  24.         private const int upclick = 0x202;
  25.         static int sleep_time_1;
  26.         static int sleep_time_2;
  27.         static bool is_buying = false;
  28.         static bool is_running = false;
  29.         static int proc_id;
  30.         public Form1()
  31.         {
  32.             InitializeComponent();
  33.         }
  34.         private void button1_Click_1(object sender, EventArgs e)
  35.         {
  36.             new Thread(RefreshThread).Start();
  37.             proc_id = Convert.ToInt32(ExtractNumbers(comboBox1.SelectedItem.ToString()));
  38.             sleep_time_1 = Convert.ToInt32(textBox1.Text)*1000;
  39.             sleep_time_2 = Convert.ToInt32(textBox2.Text)*1000;
  40.             is_running = true;
  41.             SetWindowPos(Process.GetProcessById(Convert.ToInt32(ExtractNumbers(comboBox1.SelectedItem.ToString()))).MainWindowHandle, (IntPtr)null, 0, 0, 500, 500, 0u);
  42.         }
  43.         #region AH_ITEMS_EXIST
  44.         private int PRICE_BUYOUT_1()
  45.         {
  46.                 //AH_ITEM_1_BUYOUT 0x00FA3DB0, 0xC , 0xD8
  47.                 ProcessMemory memory_ = new ProcessMemory(proc_id);
  48.                 memory_.StartProcess();
  49.                 int price = memory_.ReadInt(memory_.ReadInt(memory_.ReadInt(memory_.ReadInt(memory_.ImageAddress() + 0x00FC7590)) + 0xC) + 0xD8);
  50.                 return price;
  51.            
  52.         }
  53.         private int PRICE_BUYOUT_2()
  54.         {
  55.             //AH_ITEM_2_BUYOUT 0x00FA3DB0, 0xC , 0xD8
  56.             ProcessMemory memory_ = new ProcessMemory(proc_id);
  57.             memory_.StartProcess();
  58.             int price = 1;
  59.             return price;
  60.  
  61.         }
  62.         private int PRICE_BUYOUT_3()
  63.         {
  64.             //AH_ITEM_3_BUYOUT 0x00FA3DB0, 0xC , 0xD8
  65.             ProcessMemory memory_ = new ProcessMemory(proc_id);
  66.             memory_.StartProcess();
  67.             int price = memory_.ReadInt(memory_.ReadInt(memory_.ReadInt(memory_.ReadInt(memory_.ImageAddress() + 0x00FA3DB0)) + 0xC) + 0xD8);
  68.             return price;
  69.  
  70.         }
  71.         private int PRICE_BUYOUT_4()
  72.         {
  73.             //AH_ITEM_4_BUYOUT 0x00FA3DB0, 0xC , 0xD8
  74.             ProcessMemory memory_ = new ProcessMemory(proc_id);
  75.             memory_.StartProcess();
  76.             int price = memory_.ReadInt(memory_.ReadInt(memory_.ReadInt(memory_.ReadInt(memory_.ImageAddress() + 0x00FA3DB0)) + 0xC) + 0xD8);
  77.             return price;
  78.  
  79.         }
  80.         private int PRICE_BUYOUT_5()
  81.         {
  82.             //AH_ITEM_5_BUYOUT 0x00FA3DB0, 0xC , 0xD8
  83.             ProcessMemory memory_ = new ProcessMemory(proc_id);
  84.             memory_.StartProcess();
  85.             int price = memory_.ReadInt(memory_.ReadInt(memory_.ReadInt(memory_.ReadInt(memory_.ImageAddress() + 0x00FA3DB0)) + 0xC) + 0xD8);
  86.             return price;
  87.  
  88.         }
  89.  
  90.         #endregion
  91.  
  92.         #region AH_BUY_ITEMS
  93.         void BUY_ITEM_1()
  94.         {
  95.             IntPtr handle = Process.GetProcessById(proc_id).MainWindowHandle;
  96.             int X = new Random().Next(270, 714);
  97.             int Y = new Random().Next(173,182);
  98.             IntPtr lParam = (IntPtr)((Y << 16) | X);
  99.             IntPtr wParam = IntPtr.Zero;
  100.             PostMessage(handle, downclick, wParam, lParam);
  101.             PostMessage(handle, upclick, wParam, lParam);
  102.             /////////////////////////////////////////////////////////////
  103.             Thread.Sleep(new Random().Next(10, 90));
  104.             X = new Random().Next(620, 724);
  105.             Y = new Random().Next(481, 492);
  106.             lParam = (IntPtr)((Y << 16) | X);
  107.             wParam = IntPtr.Zero;
  108.             PostMessage(handle, downclick, wParam, lParam);
  109.             PostMessage(handle, upclick, wParam, lParam);
  110.             Thread.Sleep(new Random().Next(10, 90));
  111.             X = new Random().Next(292, 401);
  112.             Y = new Random().Next(389, 408);
  113.             lParam = (IntPtr)((Y << 16) | X);
  114.             wParam = IntPtr.Zero;
  115.             PostMessage(handle, downclick, wParam, lParam);
  116.             PostMessage(handle, upclick, wParam, lParam);
  117.             Thread.Sleep(new Random().Next(1000,3500));
  118.             X = new Random().Next(351, 441);
  119.             Y = new Random().Next(245, 265);
  120.             lParam = (IntPtr)((Y << 16) | X);
  121.             wParam = IntPtr.Zero;
  122.             PostMessage(handle, downclick, wParam, lParam);
  123.             PostMessage(handle, upclick, wParam, lParam);
  124.             /////////////////////////////////////////////////////////////
  125.         }
  126.         void BUY_ITEM_2()
  127.         {
  128.             IntPtr handle = Process.GetProcessById(proc_id).MainWindowHandle;
  129.             int X = new Random().Next(270, 714);
  130.             int Y = new Random().Next(194, 212);
  131.             IntPtr lParam = (IntPtr)((Y << 16) | X);
  132.             IntPtr wParam = IntPtr.Zero;
  133.             PostMessage(handle, downclick, wParam, lParam);
  134.             PostMessage(handle, upclick, wParam, lParam);
  135.             /////////////////////////////////////////////////////////////
  136.             Thread.Sleep(new Random().Next(10, 90));
  137.             X = new Random().Next(620, 724);
  138.             Y = new Random().Next(481, 492);
  139.             lParam = (IntPtr)((Y << 16) | X);
  140.             wParam = IntPtr.Zero;
  141.             PostMessage(handle, downclick, wParam, lParam);
  142.             PostMessage(handle, upclick, wParam, lParam);
  143.             Thread.Sleep(new Random().Next(10, 90));
  144.             X = new Random().Next(292, 401);
  145.             Y = new Random().Next(389, 408);
  146.             lParam = (IntPtr)((Y << 16) | X);
  147.             wParam = IntPtr.Zero;
  148.             PostMessage(handle, downclick, wParam, lParam);
  149.             PostMessage(handle, upclick, wParam, lParam);
  150.             Thread.Sleep(new Random().Next(1000, 3500));
  151.             X = new Random().Next(351, 441);
  152.             Y = new Random().Next(245, 265);
  153.             lParam = (IntPtr)((Y << 16) | X);
  154.             wParam = IntPtr.Zero;
  155.             PostMessage(handle, downclick, wParam, lParam);
  156.             PostMessage(handle, upclick, wParam, lParam);
  157.             /////////////////////////////////////////////////////////////
  158.         }
  159.         #endregion
  160.         private void Form1_Load(object sender, EventArgs e)
  161.         {
  162.             Process[] p = Process.GetProcessesByName("Diablo III");
  163.             foreach (Process proc in p)
  164.             { comboBox1.Items.Add("Proc ID:" + proc.Id); }
  165.  
  166.         }
  167.         static string ExtractNumbers(string expr)
  168.         {
  169.             return string.Join(null, System.Text.RegularExpressions.Regex.Split(expr, "[^\\d]"));
  170.         }
  171.      
  172.         private void SimulateMouseClick(int x_pos, int y_pos)
  173.         {
  174.             IntPtr handle = Process.GetProcessById(proc_id).MainWindowHandle;
  175.             int X = x_pos;
  176.             int Y = y_pos;
  177.             IntPtr lParam = (IntPtr)((Y << 16) | X);
  178.             IntPtr wParam = IntPtr.Zero;
  179.             PostMessage(handle, downclick, wParam, lParam);
  180.  
  181.             PostMessage(handle, upclick, wParam, lParam);
  182.         }
  183.  
  184.  
  185.         void RefreshThread()
  186.         {
  187.             while (true)
  188.             {
  189.                 while (is_running & !is_buying)
  190.                 {
  191.                     Thread.Sleep(new Random().Next(sleep_time_1+1,sleep_time_2));
  192.                     //SEARCH X=104~209
  193.                     //SEARCH Y =459~474
  194.                     IntPtr handle = Process.GetProcessById(proc_id).MainWindowHandle;
  195.                     int X = new Random().Next(111, 209);
  196.                     int Y = new Random().Next(457, 473);
  197.                     IntPtr lParam = (IntPtr)((Y << 16) | X);
  198.                     IntPtr wParam = IntPtr.Zero;
  199.                     PostMessage(handle, downclick, wParam, lParam);
  200.                     PostMessage(handle, upclick, wParam, lParam);
  201.                     Thread.Sleep(new Random().Next(100,300));
  202.                     if (PRICE_BUYOUT_1() != 0)
  203.                     {
  204.                         is_buying = true;
  205.                         BUY_ITEM_1();
  206.                         is_buying = false;
  207.                     }
  208.                 }
  209.             }
  210.         }
  211.  
  212.         private void button2_Click(object sender, EventArgs e)
  213.         {
  214.             Environment.Exit(0);
  215.         }
  216.  
  217.      
  218.     }
  219. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement