void ScanCommands() { var bmp = new Bitmap(Rectangles.LOBBY_CHATBOX.Width, Rectangles.LOBBY_CHATBOX.Height, PixelFormat.Format32bppArgb); Stopwatch toggle = new Stopwatch(); if (cg.debugmode) { toggle.Start(); } while (KeepScanning) { // Wait for listen to equal true System.Threading.Thread.Sleep(5); while (Listen == false) { System.Threading.Thread.Sleep(5); } updatescreen(ref bmp); int[][] chatColors = Chat.ChatColors; int chatFade = Chat.ChatFade; Bitmap chatMarkup = bmp.Clone(new Rectangle(0, 0, bmp.Width, bmp.Height), bmp.PixelFormat); for (int x = 0; x < chatMarkup.Width; x++) { for (int y = 0; y < chatMarkup.Height; y++) { bool colorFound = false; for (int i = 0; i < chatColors.Length; i++) { if (chatMarkup.CompareColor(x, y, chatColors[i], chatFade)) { colorFound = true; break; } } if (colorFound) { chatMarkup.SetPixel(x, y, Color.Black); } else { chatMarkup.SetPixel(x, y, Color.White); } } } if (PreviousChatMarkup == null) { PreviousChatMarkup = chatMarkup; } else { if (CompareExecutors(PreviousChatMarkup, chatMarkup)) { chatMarkup.Dispose(); continue; } else { PreviousChatMarkup.Dispose(); PreviousChatMarkup = chatMarkup; } } // Scan the second line in the chat. var seed = GetSeed(bmp, 13); var seedfade = GetSeedFade(bmp, 13); string word = null; LineScanResult linescan = ScanLine(bmp, 13, seed, seedfade); if (linescan.Word.Contains("]")) { // If the first line contains ], scan the second line. LineScanResult secondlinescan = ScanLine(bmp, 23, seed, seedfade); word = linescan.Word + " " + secondlinescan.Word; AddExecutedCommand(bmp, 13, linescan.NameLength, seed, seedfade, word); } else { // Scan the first line in chat. seed = GetSeed(bmp, 24); seedfade = GetSeedFade(bmp, 24); linescan = ScanLine(bmp, 24, seed, seedfade); if (linescan.Word.Contains("]")) { word = linescan.Word; AddExecutedCommand(bmp, 24, linescan.NameLength, seed, seedfade, word); } } } // while bmp.Dispose(); }
private void ScanCommands() { while (KeepScanning) { // Wait for listen to equal true Thread.Sleep(5); if (!Listen || ListenTo.Count == 0) { continue; } try { using (cg.LockHandler.SemiInteractive) { cg.UpdateScreen(); // Check if the chat updated #region Check For Chat Update DirectBitmap chatMarkup = Capture.Clone(Rectangles.LOBBY_CHATBOX); if (PreviousChatMarkup == null) { PreviousChatMarkup = chatMarkup; } else { if (PreviousChatMarkup.CompareTo(chatMarkup, 5, 98, DBCompareFlags.Multithread)) { chatMarkup.Dispose(); continue; } else { PreviousChatMarkup.Dispose(); PreviousChatMarkup = chatMarkup; } } #endregion foreach (LineInfo line in lineInfo) { foreach (int[] color in Chat.ChatColors) { if (Capture.CompareColor(MarkerX, line.Marker, color, Chat.ChatFade)) { string command = ""; int nameLength = -1; #if DEBUG List <LetterResult> letterInfos = new List <LetterResult>(); #endif for (int i = 0; i < line.Lines.Length; i++) { LineScanResult linescan = ScanLine(TextStart, ChatLength, line.Lines[i], color); command += linescan.Word; #if DEBUG letterInfos.AddRange(linescan.LetterInfos); #endif if (i == 0) { nameLength = linescan.NameLength; } } AddExecutedCommand(line.Lines[0], nameLength, color, command #if DEBUG , letterInfos #endif ); break; } } } } } catch (OverwatchClosedException) { } } // while // Dispose of resources used by this class. if (PreviousChatMarkup != null) { PreviousChatMarkup.Dispose(); } }
void ScanCommands() { var bmp = new Bitmap(shotarea.Width, shotarea.Height, PixelFormat.Format32bppArgb); Stopwatch toggle = new Stopwatch(); if (cg.debugmode) { toggle.Start(); } while (KeepScanning) { // Wait for listen to equal true System.Threading.Thread.Sleep(10); while (Listen == false) { System.Threading.Thread.Sleep(10); } updatescreen(ref bmp); // Word result string word = ""; // Scan the second line in the chat. var seed = GetSeed(bmp, 13); var seedfade = GetSeedFade(bmp, 13); LineScanResult linescan = ScanLine(bmp, 13, seed, seedfade); if (/* CompareColor(0, 13, seed, seedfade) == false && */ linescan.Word.Contains("]")) { // If the second line contains ], scan the first line. LineScanResult secondlinescan = ScanLine(bmp, 23, seed, seedfade); AddExecutedCommand(bmp, 13, linescan.NameLength, seed, seedfade, linescan.Word + " " + secondlinescan.Word); word = linescan.Word + " " + secondlinescan.Word; } else { // Scan the first line in chat. seed = GetSeed(bmp, 24); seedfade = GetSeedFade(bmp, 24); linescan = ScanLine(bmp, 24, seed, seedfade); if (linescan.Word.Contains("]")) { AddExecutedCommand(bmp, 24, linescan.NameLength, seed, seedfade, linescan.Word); word = linescan.Word; } } ShowScan(ref bmp, 23, seed, seedfade); // Write the word into the window if debug more is on. if (cg.debugmode) { cg.debug.Invalidate(new Rectangle(0, bmp.Height * scale, cg.debug.Width, cg.debug.Height - (bmp.Height * scale))); cg.g.DrawString(word, new Font("Arial", 16), Brushes.Black, new PointF(0, bmp.Height * scale + 5)); cg.g.FillRectangle(new SolidBrush(Color.FromArgb(seed[0], seed[1], seed[2])), new Rectangle(0, 0, 30, 30)); cg.g.DrawRectangle(new Pen(Color.Blue), new Rectangle(0, 0, 30, 30)); int ecy = bmp.Height * scale + 35; for (int i = 0; i < _executedCommands.Count; i++) { try { cg.g.DrawImage(_executedCommands[i].executor, new Rectangle(0, ecy, _executedCommands[i].executor.Width * 5, _executedCommands[i].executor.Height * 5)); cg.g.DrawString(_executedCommands[i].command, new Font("Arial", 12), Brushes.Black, _executedCommands[i].executor.Width * scale, ecy); ecy += _executedCommands[i].executor.Height * 5; } catch (ArgumentOutOfRangeException) { } } } } // while bmp.Dispose(); }