Advertisement
Guest User

dd

a guest
Dec 3rd, 2019
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.29 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Threading;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. using KAutoHelper;
  17. using System.Drawing;
  18.  
  19. namespace AutoPUBG
  20. {
  21.     /// <summary>
  22.     /// Interaction logic for MainWindow.xaml
  23.     /// </summary>
  24.     public partial class MainWindow : Window
  25.     {
  26.         public MainWindow()
  27.         {
  28.             InitializeComponent();
  29.             //LoadData();
  30.         }
  31.  
  32.         //void LoadData()
  33.         //{
  34.         //    TOP_UP_BMP = (Bitmap)Bitmap.FromFile("Data//CickVaoGame.png");
  35.         //}
  36.  
  37.         private void Button_Start(object sender, RoutedEventArgs e)
  38.         {
  39.             Task t = new Task(()=> {
  40.                 isStop = false;
  41.                 Auto();
  42.             });
  43.             t.Start();
  44.         }
  45.         bool isStop = false;
  46.         void Auto()
  47.         {
  48.             // Lay ra Danh sach thiet bi
  49.             List<string> devices = new List<string>();
  50.             devices = KAutoHelper.ADBHelper.GetDevices();
  51.             // Chay tung Device
  52.             foreach (var deviceID in devices)
  53.             {
  54.                 // Tao Ra Mot Luong Xu Ly
  55.                 Task t = new Task(()=> {
  56.                     // Lap Kich Ban
  57.                     while (true)
  58.                     {
  59.                         // Viet Auto O day  
  60.                         if (isStop)
  61.                             return;
  62.                         KAutoHelper.ADBHelper.TapByPercent(deviceID, 37.3, 25.4);
  63.                         Delay(10);
  64.  
  65.                     }
  66.                 });
  67.                 t.Start();
  68.             }
  69.                
  70.         }
  71.         void Delay(int delay)
  72.         {
  73.             while (delay > 0)
  74.             {
  75.                 Thread.Sleep(TimeSpan.FromSeconds(1));
  76.                 delay--;
  77.                 if (isStop)
  78.                     break;
  79.             }
  80.         }
  81.  
  82.         private void Button_Stop(object sender, RoutedEventArgs e)
  83.         {
  84.             isStop = true;
  85.         }
  86.     }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement