/// <summary> /// Нажимаем Коннект (переводим бота из состояния логаут в состояние казарма) /// </summary> /// <returns></returns> public bool ConnectBH() // возвращает true, если успешно вошли в казарму { bool result = true; const int MAX_NUMBER_ITERATION = 4; //максимальное количество итераций uint count = 0; iPointColor testColor = new PointColor(65 - 5 + botParam.X, 55 - 5 + botParam.Y, 7800000, 5); //запоминаем цвет в координатах 55, 55 для проверки того, сменился ли экран (т.е. принят ли логин-пароль) Pause(500); do { PressConnectButton(); Pause(10000); if (isCheckBugs()) { BugFixes(); } count++; if (count > MAX_NUMBER_ITERATION) { result = false; break; } //if (server.isBarack()) //{ // result = true; // break; //} } while (!isChangeDisplay(testColor.GetPixelColor())); return(result); }
/// <summary> /// проверяем, сменилось ли изображение на экране /// </summary> /// <param name="testColor">тестовая точка</param> /// <returns>true, если сменился экран</returns> private bool isChangeDisplay(uint testColor) { iPointColor currentColor = new PointColor(65 - 5 + botParam.X, 55 - 5 + botParam.Y, 7800000, 5); uint color = currentColor.GetPixelColor(); bool result = (color == testColor); return(!result); }
/// <summary> /// Продажа товара, когда список уже не прокручивается /// </summary> public void SaleToEnd() { iPointColor pointCurrentProduct; for (int j = 2; j <= 12; j++) { pointCurrentProduct = new PointColor(149 - 5 + xx, 219 - 5 + yy + (j - 1) * 27, 3360337, 0); //проверяем цвет текущего продукта Pause(50); if (NeedToSellProduct(pointCurrentProduct.GetPixelColor(), j)) //если нужно продать товар в строке j { AddToCartLotProduct(j); //добавляем в корзину весь товар в строке j } } }
/// <summary> /// Нажимаем Коннект (переводим бота из состояния логаут в состояние казарма) /// </summary> /// <returns></returns> public bool Connect() // возвращает true, если успешно вошли в казарму { #region новый вариант //bool result = true; //const int MAX_NUMBER_ITERATION = 4; //максимальное количество итераций //uint count = 0; //iPointColor testColor = new PointColor(65 - 5 + databot.X, 55 - 5 + databot.Y, 7800000, 5); //запоминаем цвет в координатах 55, 55 для проверки того, сменился ли экран (т.е. принят ли логин-пароль) //Pause(500); //do //{ // PressConnectButton(); // Pause(10000); // if (isCheckBugs()) BugFixes(); // count++; // if (count > MAX_NUMBER_ITERATION) // { // result = false; // break; // } // //if (server.isBarack()) // //{ // // result = true; // // break; // //} //} while (!isChangeDisplay(testColor.GetPixelColor())); //return result; #endregion #region старый вариант (но рабочий) //server.WriteToLogFileBH("вошли в процедуру коннект"); //server.WriteToLogFile(botParam.NumberOfInfinity + " " + botParam.Logins[botParam.NumberOfInfinity] + " " + botParam.Passwords[botParam.NumberOfInfinity] + " " + botParam.Parametrs[botParam.NumberOfInfinity]); //server.serverSelection(); //выбираем из списка свой сервер iPointColor point5050 = new PointColor(50 - 5 + botParam.X, 50 - 5 + botParam.Y, 7800000, 5); //запоминаем цвет в координатах 50, 50 для проверки того, сменился ли экран (т.е. принят ли логин-пароль) iPoint pointButtonOk = new Point(525 - 5 + botParam.X, 410 - 5 + botParam.Y); // кнопка Ok в логауте iPoint pointButtonOk2 = new Point(525 - 5 + botParam.X, 445 - 5 + botParam.Y); // кнопка Ok в логауте uint Tek_Color1; uint Test_Color = 0; bool ColorBOOL = true; uint currentColor = 0; const int MAX_NUMBER_ITERATION = 4; //максимальное количество итераций bool aa = true; Test_Color = point5050.GetPixelColor(); //запоминаем цвет в координатах 50, 50 для проверки того, сменился ли экран (т.е. принят ли логин-пароль) Tek_Color1 = Test_Color; ColorBOOL = (Test_Color == Tek_Color1); int counter = 0; //счетчик pointButtonOk.PressMouseL(); //кликаю в кнопку "ОК" Pause(500); pointButtonOk2.PressMouseL(); //кликаю в кнопку "ОК" 3 min Pause(500); server.serverSelection(); //выбираем из списка свой сервер server.WriteToLogFileBH("дошли до while"); while ((aa | (ColorBOOL)) & (counter < MAX_NUMBER_ITERATION)) { counter++; //счетчик Tek_Color1 = point5050.GetPixelColor(); ColorBOOL = (Test_Color == Tek_Color1); server.WriteToLogFileBH("нажимаем на кнопку connect"); //pointButtonOk.PressMouseL(); //кликаю в кнопку "ОК" //Pause(500); //pointButtonOk2.PressMouseL(); //кликаю в кнопку "ОК" 3 min //Pause(500); //server.serverSelection(); //выбираем из списка свой сервер PressConnectButton(); Pause(1500); //pointButtonOk.PressMouseL(); //кликаю в кнопку "ОК" //Pause(500); //pointButtonOk2.PressMouseL(); //кликаю в кнопку "ОК" 3 min //Pause(500); //если есть ошибки в логине-пароле, то возникает сообщение с кнопкой "OK". if (server.isPointConnect()) // Обработка Ошибок. { pointButtonOk.PressMouse(); //кликаю в кнопку "ОК" Pause(500); if (server.isPointConnect()) //проверяем, выскочила ли форма с кнопкой ОК { pointButtonOk.PressMouse(); //кликаю в кнопку "ОК" Pause(500); } pointButtonOk.PressMouseL(); //кликаю в кнопку "ОК" pointButtonOk2.PressMouseL(); //кликаю в кнопку "ОК" 3 min EnterLoginAndPasword(); } else { aa = false; } } bool result = true; Pause(5000); currentColor = point5050.GetPixelColor(); if (currentColor == Test_Color) //проверка входа в казарму. { //тыкнуть в Quit //PressMouseL(600, 530); //если не вошли в казарму, то значит зависли и жмем кнопку Quit //PressMouseL(600, 530); result = false; } return(result); #endregion }
/// <summary> /// возвращает цифру от 0 до 9, расположенную в указанных координатах (левый верхний угол) /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <returns></returns> private int Numeral(int x, int y) { iPointColor pointdigit1 = new PointColor(x - 5 + xx + 3, y - 5 + yy + 2, 65000, 3); //1 iPointColor pointdigit2 = new PointColor(x - 5 + xx + 3, y - 5 + yy + 5, 63000, 3); //2 iPointColor pointdigit3 = new PointColor(x - 5 + xx + 2, y - 5 + yy + 4, 65000, 3); //3 iPointColor pointdigit4 = new PointColor(x - 5 + xx + 3, y - 5 + yy + 6, 59000, 3); //4 iPointColor pointdigit5 = new PointColor(x - 5 + xx + 5, y - 5 + yy + 0, 56000, 3); //5 iPointColor pointdigit6 = new PointColor(x - 5 + xx + 5, y - 5 + yy + 1, 60000, 3); //6 iPointColor pointdigit7 = new PointColor(x - 5 + xx + 0, y - 5 + yy + 0, 63000, 3); //7 iPointColor pointdigit8 = new PointColor(x - 5 + xx + 1, y - 5 + yy + 4, 63000, 3); //8 iPointColor pointdigit9 = new PointColor(x - 5 + xx + 5, y - 5 + yy + 4, 65000, 3); //9 iPointColor pointdigit0 = new PointColor(x - 5 + xx + 1, y - 5 + yy + 8, 56000, 3); //0 switch (product.numberOfDigit) { case 3: break; case 4: //зеленые цифры pointdigit1 = new PointColor(x - 5 + xx + 3, y - 5 + yy + 2, 64000, 3); //1 pointdigit2 = new PointColor(x - 5 + xx + 0, y - 5 + yy + 9, 65000, 3); //2 pointdigit3 = new PointColor(x - 5 + xx + 3, y - 5 + yy + 4, 64000, 3); //3 pointdigit4 = new PointColor(x - 5 + xx + 3, y - 5 + yy + 6, 58000, 3); //4 pointdigit5 = new PointColor(x - 5 + xx + 5, y - 5 + yy + 0, 50000, 4); //5 pointdigit6 = new PointColor(x - 5 + xx + 5, y - 5 + yy + 1, 59000, 3); //6 pointdigit7 = new PointColor(x - 5 + xx + 0, y - 5 + yy + 0, 60000, 4); //7 pointdigit8 = new PointColor(x - 5 + xx + 1, y - 5 + yy + 4, 63000, 3); //8 pointdigit9 = new PointColor(x - 5 + xx + 5, y - 5 + yy + 4, 65000, 3); //9 pointdigit0 = new PointColor(x - 5 + xx + 1, y - 5 + yy + 8, 56000, 3); //0 break; case 5: //желтые цифры pointdigit1 = new PointColor(x - 5 + xx + 3, y - 5 + yy + 2, 65000, 3); //1 pointdigit2 = new PointColor(x - 5 + xx + 0, y - 5 + yy + 9, 65000, 3); //2 pointdigit3 = new PointColor(x - 5 + xx + 5, y - 5 + yy + 6, 65000, 3); //3 pointdigit4 = new PointColor(x - 5 + xx + 3, y - 5 + yy + 6, 50000, 4); //4 если 3 и 6, то 59000 pointdigit5 = new PointColor(x - 5 + xx + 5, y - 5 + yy + 0, 50000, 4); //5 pointdigit6 = new PointColor(x - 5 + xx + 5, y - 5 + yy + 1, 60000, 3); //6 pointdigit7 = new PointColor(x - 5 + xx + 0, y - 5 + yy + 0, 63000, 3); //7 pointdigit8 = new PointColor(x - 5 + xx + 1, y - 5 + yy + 4, 63000, 3); //8 pointdigit9 = new PointColor(x - 5 + xx + 5, y - 5 + yy + 4, 65000, 3); //9 pointdigit0 = new PointColor(x - 5 + xx + 1, y - 5 + yy + 8, 56000, 3); //0 break; case 6: //коричневые цифры pointdigit1 = new PointColor(x - 5 + xx + 3, y - 5 + yy + 2, 4090000, 4); //1 pointdigit2 = new PointColor(x - 5 + xx + 3, y - 5 + yy + 5, 4030000, 4); //2 pointdigit3 = new PointColor(x - 5 + xx + 3, y - 5 + yy + 4, 4030000, 4); //3 pointdigit4 = new PointColor(x - 5 + xx + 3, y - 5 + yy + 6, 3760000, 4); //4 pointdigit5 = new PointColor(x - 5 + xx + 5, y - 5 + yy + 0, 3560000, 4); //5 pointdigit6 = new PointColor(x - 5 + xx + 5, y - 5 + yy + 1, 3760000, 4); //6 pointdigit7 = new PointColor(x - 5 + xx + 0, y - 5 + yy + 0, 4030000, 4); //7 pointdigit8 = new PointColor(x - 5 + xx + 1, y - 5 + yy + 4, 4030000, 4); //8 pointdigit9 = new PointColor(x - 5 + xx + 5, y - 5 + yy + 4, 4090000, 4); //9 pointdigit0 = new PointColor(x - 5 + xx + 1, y - 5 + yy + 8, 3560000, 4); //0 break; case 7: break; case 8: break; case 9: break; case 10: break; } if ((pointdigit1.isColor()) || ((pointdigit1.GetPixelColor() > 120000) && (pointdigit1.GetPixelColor() < 130000))) { return(1); } if ((pointdigit2.isColor()) || ((pointdigit2.GetPixelColor() > 120000) && (pointdigit2.GetPixelColor() < 130000))) { return(2); } if ((pointdigit4.isColor()) || ((pointdigit4.GetPixelColor() > 120000) && (pointdigit4.GetPixelColor() < 130000))) { return(4); } if ((pointdigit7.isColor()) || ((pointdigit7.GetPixelColor() > 120000) && (pointdigit7.GetPixelColor() < 130000))) { return(7); } if ((pointdigit5.isColor()) || ((pointdigit5.GetPixelColor() > 120000) && (pointdigit5.GetPixelColor() < 130000))) { return(5); } if ((pointdigit6.isColor()) || ((pointdigit6.GetPixelColor() > 120000) && (pointdigit6.GetPixelColor() < 130000))) { return(6); } if ((pointdigit0.isColor()) || ((pointdigit0.GetPixelColor() > 120000) && (pointdigit0.GetPixelColor() < 130000))) { return(0); } if ((pointdigit9.isColor()) || ((pointdigit9.GetPixelColor() > 120000) && (pointdigit9.GetPixelColor() < 130000))) { return(9); } if ((pointdigit8.isColor()) || ((pointdigit8.GetPixelColor() > 120000) && (pointdigit8.GetPixelColor() < 130000))) { return(8); } if ((pointdigit3.isColor()) || ((pointdigit3.GetPixelColor() > 120000) && (pointdigit3.GetPixelColor() < 130000))) { return(3); } return(0); //возвращаем незанчащий ноль, если никакой цифры на этом месте нет }