private Dictionary<int, MagicCard> SplitCombinedImageFile(Ocr ocr, bool includeTickets, bool limitAmount = false) { var listOfCards = new Dictionary<int, MagicCard>(); var cards = ocr.ExtractTextFromScreen(); _logger.Trace("Card Image Block Returned: " + cards); return SplitCombinedImageString(includeTickets, limitAmount, listOfCards, cards); }
public int DetermineYouGiveConfirmedAmount() { var ocr = new Ocr(); ocr.AddToCollectionImage(_pbv.YouGiveAmountNumberConfirmed, _pbv.YouGiveAmountBlankSpaceConfirmed, _pbv.YouGiveAmountNameConfirmed); var text = ocr.ExtractTextFromScreen(); try { return GetAmountFromString(text); } catch (Exception ex) { _logger.Error(ex, "Conversion of you give amount failed on confirmation screen for: " + text); } return 0; }
private bool DetermineYouGiveAmount(bool fireEvent) { int i = 0; while (i++ < 10 && _windowManager.InTrade()) { var ocr = new Ocr(); ocr.AddToCollectionImage(_pbv.YouGiveAmountNumber, _pbv.YouGiveAmountBlankSpace, _pbv.YouGiveAmountName); var text = ocr.ExtractTextFromScreen(); try { YouGiveAmount = GetAmountFromString(text); return YouGiveAmountChanged; } catch (Exception ex) { _logger.Error(ex, "Conversion of you give amount failed for: " + text); _windowManager.CloseTradeCancelledDialog(); } finally { if (YouGiveAmountChangedEvent != null && fireEvent) { YouGiveAmountChangedEvent(this, EventArgs.Empty); } } } return YouGiveAmountChanged; }
public void DetermineYouGetAmount() { var ocr = new Ocr(); ocr.AddToCollectionImage(_pbv.YouGetAmountNumber, _pbv.YouGetAmountBlankSpace, _pbv.YouGetAmountName); var text = ocr.ExtractTextFromScreen(); try { YouGetAmount = GetAmountFromString(text); } catch (Exception ex) { _logger.Error(ex, "Conversion of you get amount failed for: " + text); _windowManager.CloseTradeCancelledDialog(); } }
public Dictionary<int, MagicCard> DetermineCards(List<Square> cardLocations, Square setPosition, Square numberPosition, int slowDownAmount = 100, int currentCardCount = 0, int maxCardCount = 75) { Ocr ocr = new Ocr(); _windowManager.CloseTradeCancelledDialog(); AutoItX.Sleep(100); var firstPosition = cardLocations[0].MidPoint; AutoItX.MouseClick(firstPosition); AutoItX.Sleep(100); AutoItX.Send(Constants.HomeKey); AutoItX.Sleep(250); AutoItX.MouseMove(firstPosition.X, firstPosition.Y - 35); Square currentCard = cardLocations[0].Copy(); int lastCardNameChecksum = 0; int lastCardSetChecksum = 0; int currentCardSetChecksum = 1; int currentCardNameChecksum = 1; int i = 0; while ((!lastCardNameChecksum.Equals(currentCardNameChecksum) || !lastCardSetChecksum.Equals(currentCardSetChecksum)) && currentCardCount++ <= maxCardCount) { var j = 0; while (AutoItX.PixelGetColor(currentCard.Copy().MoveAlongYAxis(1).TopLeft) != _pbv.CardSelectedColor && j < 50) { AutoItX.Sleep(50); if (j == 10) { if (i < 4) { return SplitCombinedImageFile(ocr, true); } } if (++j == 50) { AutoItX.Send(Constants.DownArrow); AutoItX.Sleep(100); if (AutoItX.PixelGetColor(currentCard.TopLeft) != _pbv.CardSelectedColor) { return SplitCombinedImageFile(ocr, true); } } } lastCardNameChecksum = currentCardNameChecksum; currentCardNameChecksum = AutoItX.PixelChecksum(currentCard); lastCardSetChecksum = currentCardSetChecksum; currentCardSetChecksum = AutoItX.PixelChecksum(setPosition); ocr.AddToCollectionImage(currentCard, numberPosition, setPosition); AutoItX.Send(Constants.DownArrow); if (++i < cardLocations.Count) { currentCard = cardLocations[i].Copy(); setPosition.MoveTopEdgeTo(currentCard.TopEdge); setPosition.MoveBottomEdgeTo(currentCard.BottomEdge); numberPosition.MoveTopEdgeTo(currentCard.TopEdge); numberPosition.MoveBottomEdgeTo(currentCard.BottomEdge); } else { AutoItX.Sleep(slowDownAmount); } } return SplitCombinedImageFile(ocr, true); }
private void DoGetOCR() { switch (this.State++) { case 0: this.values.Text = string.Empty; this.instructions.Text = "Move the mouse to the top left position of the area you want to checksum and press the spacebar."; break; case 1: var point = AutoItX.MouseGetPos(); Point checkSumTopLeft = new Point(point.X, point.Y); this.CheckSumTopLeft = checkSumTopLeft; this.instructions.Text = "Now move the mouse to the bottom right and press the spacebar again."; break; case 2: point = AutoItX.MouseGetPos(); this.CheckSumBottomRight = new Point(point.X, point.Y); Ocr ocr = new Ocr(); string ocrText = ocr.ExtractTextFromScreen(this.CheckSumTopLeft, this.CheckSumBottomRight); this.instructions.Text = "Copy the code below and paste it into your constants or ini file. After pasting into your file replace all instances of 'checkSum' with the variable name that this belongs to."; this.values.Text = string.Format( "public static readonly Point checkSumTopLeft = new Point({0}, {1}); \r public static readonly Point checkSumBottomRight = new Point({2}, {3}); \r public static readonly string text = {4};", this.CheckSumTopLeft.X, this.CheckSumTopLeft.Y, this.CheckSumBottomRight.X, this.CheckSumBottomRight.Y, ocrText); State = 0; break; } }
public void TestScreenHeaderTextGrab() { Point screenHeaderTopLeft = new Point(73, 10); Point screenHeaderBottomRight = new Point(274, 34); Ocr ocr = new Ocr(); string extractTextFromScreen = ocr.ExtractTextFromScreen(screenHeaderTopLeft, screenHeaderBottomRight); _logger.Trace(extractTextFromScreen); }
public string GetOCRValue() { Ocr ocr = new Ocr(); var value = ocr.ExtractTextFromScreen(_topLeft, _bottomRight).Trim(); // _logger.TraceFormat("Ocr for {0},{1} -> {2},{3} is : {4}", LeftEdge, TopEdge, RightEdge, BottomEdge, value); return value; }