Ejemplo n.º 1
0
        public void LoginTranS()
        {
            string strCmdText;
            string userName = Environment.UserName;

            strCmdText = @"/C C:\Users\" + userName + @"\AppData\Roaming\TranS\TranS.exe";

            Process p = new Process();

            p.StartInfo.FileName  = "CMD.exe";
            p.StartInfo.Arguments = strCmdText;

            p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

            p.Start();
            Thread.Sleep(4000);

            //click Student
            var screen = CaptureHelper.CaptureScreen();

            screen.Save("mainScreen.png");
            var subBitmap = ImageScanOpenCV.GetImage("btnHocVien.bmp");
            var resBitmap = ImageScanOpenCV.FindOutPoint((Bitmap)screen, subBitmap);

            if (resBitmap != null)
            {
                string x = (resBitmap.ToString()).Remove(0, 3).Remove(3, 7);
                string y = (resBitmap.ToString()).Remove(0, 9).Remove(3, 1);
                AutoControl.MouseClick(int.Parse(x) + 20, int.Parse(y) + 20, EMouseKey.LEFT);
            }

            Thread.Sleep(500);

            //Send Enter ID
            try
            {
                AutoControl.SendStringFocus(txtBoxID.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("Bạn chưa nhập ID");
            }


            //Click Join now
            var screenID = CaptureHelper.CaptureScreen();

            screenID.Save("mainScreen.png");
            var subBitmapID = ImageScanOpenCV.GetImage("btnVaoPhong.bmp");
            var resBitmapID = ImageScanOpenCV.FindOutPoint((Bitmap)screenID, subBitmapID);

            if (resBitmapID != null)
            {
                string x1 = (resBitmapID.ToString()).Remove(0, 3).Remove(3, 7);
                string y1 = (resBitmapID.ToString()).Remove(0, 9).Remove(3, 1);
                AutoControl.MouseClick(int.Parse(x1) + 20, int.Parse(y1) + 20, EMouseKey.LEFT);
            }
            Application.Exit();
        }
Ejemplo n.º 2
0
        private void btnExportPoint_Click(object sender, EventArgs e)
        {
            var screen = CaptureHelper.CaptureScreen();

            screen.Save("mainScreen.PNG");

            var subBitmap = ImageScanOpenCV.GetImage("template.PNG");

            var resBitMap = ImageScanOpenCV.FindOutPoint((Bitmap)screen, subBitmap);

            if (resBitMap != null)
            {
                MessageBox.Show(resBitMap.ToString());
            }
        }
Ejemplo n.º 3
0
        private void btnCheckImage_Click(object sender, EventArgs e)
        {
            var screen = CaptureHelper.CaptureScreen();

            screen.Save("mainScreen.PNG");

            var subBitmap = ImageScanOpenCV.GetImage("template.PNG");

            var resBitMap = ImageScanOpenCV.Find((Bitmap)screen, subBitmap);

            if (resBitMap != null)
            {
                resBitMap.Save("res.PNG");
            }
        }
Ejemplo n.º 4
0
        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            var screen = CaptureHelper.CaptureScreen();

            screen.Save("mainScreen.png");
            var subBit         = ImageScanOpenCV.GetImage("commentSection.PNG");
            var sendpost       = ImageScanOpenCV.GetImage("SendComment.PNG");
            var ComsecLocation = ImageScanOpenCV.FindOutPoint((Bitmap)screen, subBit);

            AutoControl.MouseClick((Point)ComsecLocation);
            //autoItX3.Send("Hello");
            Thread.Sleep(1000);
            screen = CaptureHelper.CaptureScreen();
            var   sendLocation = ImageScanOpenCV.FindOutPoint((Bitmap)screen, sendpost);
            Point sendlo       = (Point)sendLocation;

            sendlo.X += 3;
            sendlo.Y += 7;
            AutoControl.MouseClick((Point)sendlo);
        }
Ejemplo n.º 5
0
        private void button4_Click(object sender, EventArgs e)
        {
            AutoItX3 autoItX3    = new AutoItX3();
            Point    LOLlocation = new Point(805, 175);
            IntPtr   hWnd        = IntPtr.Zero;

            hWnd = AutoControl.FindWindowHandle(null, "Garena - Game Center");
            var child = AutoControl.FindHandle(hWnd, "Chrome_RenderWidgetHostHWND", null);
            var point = AutoControl.GetGlobalPoint(child, LOLlocation);
            int num   = Convert.ToInt32(textBox1.Text);

            AutoControl.BringToFront(hWnd);
            AutoControl.MouseClick(point);
            Thread.Sleep(3000);
            autoItX3.MouseWheel("down", 2);
            Thread.Sleep(3000);
            //var postPoint = AutoControl.GetGlobalPoint(child, 147, 113);// 147 113
            //AutoControl.MouseClick(postPoint);
            //Thread.Sleep(2000);
            int[] arrEndPoint = { 202, 315, 341, 358, 432, 471, 500, 570, 630 }; // for y
            for (int i = 0; i < 2; i++)
            {
                Point startpoint = new Point(951, 12);
                Point endPoint   = new Point(952, 202);
                var   fpoint     = AutoControl.GetGlobalPoint(child, 150, 149);
                for (int j = 0; j < 3; j++)
                {
                    AutoControl.MouseClick(fpoint);
                    Thread.Sleep(3000);
                    var spoint = AutoControl.GetGlobalPoint(child, startpoint);
                    autoItX3.MouseMove(spoint.X, spoint.Y);
                    autoItX3.MouseDown("LEFT");
                    Bitmap screen;
                    for (int p = 0; p < arrEndPoint.Length; p++)
                    {
                        endPoint.Y = arrEndPoint[p];
                        var endP = AutoControl.GetGlobalPoint(child, endPoint);
                        autoItX3.MouseMove(endP.X, endP.Y);
                        screen = (Bitmap)CaptureHelper.CaptureScreen();
                        var subBit         = ImageScanOpenCV.GetImage("commentSection.PNG");
                        var sendpost       = ImageScanOpenCV.GetImage("SendComment.PNG");
                        var ComsecLocation = ImageScanOpenCV.FindOutPoint((Bitmap)screen, subBit);
                        if (ComsecLocation != null)
                        {
                            autoItX3.MouseUp("LEFT");
                            AutoControl.MouseClick((Point)ComsecLocation);
                            autoItX3.Send("Hello");
                            Thread.Sleep(1000);
                            screen = (Bitmap)CaptureHelper.CaptureScreen();
                            var   sendLocation = ImageScanOpenCV.FindOutPoint((Bitmap)screen, sendpost);
                            Point sendlo       = (Point)sendLocation; // can not find  the right so find the near and add a few unit to right point
                            sendlo.X += 3;
                            sendlo.Y += 7;
                            AutoControl.MouseClick((Point)sendlo);
                            screen.Dispose();
                            break;
                        }
                    }
                    var exitpost = AutoControl.GetGlobalPoint(child, 62, 6);
                    exitpost.Y -= 37;
                    AutoControl.MouseClick(exitpost);
                    Thread.Sleep(2000);
                    fpoint.X += 325;
                }
                Thread.Sleep(1000);
                Point zone = AutoControl.GetGlobalPoint(child, 20, 20);
                autoItX3.MouseMove(zone.X, zone.Y);
                autoItX3.MouseWheel("down", 4);
                Thread.Sleep(3000);
            }
        }
Ejemplo n.º 6
0
 public static void CaptureScreenToFile(string filename, ImageFormat format)
 {
     CaptureHelper.CaptureScreen().Save(filename, format);
 }
Ejemplo n.º 7
0
        void runChrome()
        {
            if (isRunning)
            {
                for (int i = 1; i <= 9999; i++)
                {
                    if (isRunning)
                    {
                        for (int rows = 0; rows < dataGridView1.Rows.Count; rows++)
                        {
                            if (isRunning)
                            {
                                IPHostEntry ip;
                                while (isRunning)
                                {
                                    var check = false;
                                    dataGridView1.Rows[rows].Cells[1].Value = "Change IP";
                                    runCMD("rasdial viettel");
                                    string myip = "";
                                    ip = Dns.GetHostEntry(Dns.GetHostName());
                                    foreach (IPAddress ipa in ip.AddressList)
                                    {
                                        if (ipa.AddressFamily == AddressFamily.InterNetwork)
                                        {
                                            myip = ipa.ToString();
                                        }
                                    }

                                    if (File.Exists("ListIP.txt"))
                                    {
                                        dataGridView1.Rows[rows].Cells[1].Value = "Check duplicate IP";
                                        string[] listIP = File.ReadAllLines("ListIP.txt");
                                        foreach (var item in listIP)
                                        {
                                            var temp = item.Split(':');
                                            if (myip == temp[0].Trim())
                                            {
                                                check = true;
                                            }
                                        }
                                    }
                                    if (!check)
                                    {
                                        File.AppendAllText("ListIP.txt", myip + " : " + dataGridView1.Rows[rows].Cells[0].Value + "\n");
                                        dataGridView1.Rows[rows].Cells[1].Value = "Open Chrome";
                                        Process.Start(dataGridView1.Rows[rows].Cells[0].Value.ToString());
                                        break;
                                    }
                                    else
                                    {
                                        runCMD("rasdial /disconnect");
                                    }
                                }

                                if (isRunning)
                                {
                                    Thread.Sleep(2500);
                                    var cap = CaptureHelper.CaptureScreen();
                                    cap.Save("res.png");
                                    var sub   = ImageScanOpenCV.GetImage("icon.PNG");
                                    var count = 0;
                                    while (count <= 30)
                                    {
                                        Point?res = ImageScanOpenCV.FindOutPoint((Bitmap)cap, sub);
                                        if (res != null)
                                        {
                                            AutoControl.MouseClick(res.Value.X, res.Value.Y, EMouseKey.LEFT);
                                            Thread.Sleep(time * 1000);
                                            break;
                                        }
                                        count++;
                                    }
                                }
                                runCMD("taskkill /f /im chrome.exe");
                                dataGridView1.Rows[rows].Cells[1].Value = "Disconnect Dcom";
                                runCMD("rasdial /disconnect");
                                if (isRunning)
                                {
                                    dataGridView1.Rows[rows].Cells[1].Value = "Done";
                                }
                                else
                                {
                                    dataGridView1.Rows[rows].Cells[1].Value = "Stop";
                                }
                            }
                            else
                            {
                                dataGridView1.Rows[rows].Cells[1].Value = "Stop";
                            }
                        }
                    }
                }
            }
        }