public Form1() { try { connection.Open(); sql_send_unmute.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.Message); Application.Exit(); } InitializeComponent(); gameWatcher.Show(); p_Colors[0] = ColorTranslator.FromHtml("#c71013"); //red p_Colors[1] = ColorTranslator.FromHtml("#142ed0"); //blue p_Colors[2] = ColorTranslator.FromHtml("#13832d"); //green p_Colors[3] = ColorTranslator.FromHtml("#ec55ba"); //pink p_Colors[4] = ColorTranslator.FromHtml("#ef7d12"); //orange p_Colors[5] = ColorTranslator.FromHtml("#f7f75c"); //yellow p_Colors[6] = ColorTranslator.FromHtml("#3c4950"); //black p_Colors[7] = ColorTranslator.FromHtml("#d7e2f1"); //white p_Colors[8] = ColorTranslator.FromHtml("#6b30bc"); //purple p_Colors[9] = ColorTranslator.FromHtml("#71491e"); //brown p_Colors[10] = ColorTranslator.FromHtml("#39fddd"); //Cyan p_Colors[11] = ColorTranslator.FromHtml("#4ff03a"); //lime AmongState thd_temp = new AmongState(); thd_temp.NameOf = "Start"; thd_temp.Enable = true; thd_temp.Pan = gameWatcher.panel_CrewImp; thd_temp.Lab = label_start; thd_temp.Lab_o = label_start_o; thd_temp.Size = thd_temp.Pan.ClientSize; thd_temp.PxColors = new Color[4]; thd_temp.PxLocation = new Point[4]; thd_temp.PxColors[0] = ColorTranslator.FromHtml("#8cffff"); thd_temp.PxLocation[0] = new Point(25, 112); thd_temp.PxColors[1] = ColorTranslator.FromHtml("#000000"); thd_temp.PxLocation[1] = new Point(147, 123); thd_temp.PxColors[2] = ColorTranslator.FromHtml("#8cffff"); thd_temp.PxLocation[2] = new Point(867, 122); thd_temp.PxColors[3] = ColorTranslator.FromHtml("#8cffff"); thd_temp.PxLocation[3] = new Point(968, 82); AS.Add(thd_temp); thd_temp = new AmongState(); thd_temp.NameOf = "Start"; thd_temp.Enable = true; thd_temp.Pan = gameWatcher.panel_CrewImp; thd_temp.Lab = label_start; thd_temp.Lab_o = label_start_o; thd_temp.Size = thd_temp.Pan.ClientSize; thd_temp.PxColors = new Color[4]; thd_temp.PxLocation = new Point[4]; thd_temp.PxColors[0] = ColorTranslator.FromHtml("#ff1919"); thd_temp.PxLocation[0] = new Point(74, 101); thd_temp.PxColors[1] = ColorTranslator.FromHtml("#000000"); thd_temp.PxLocation[1] = new Point(146, 124); thd_temp.PxColors[2] = ColorTranslator.FromHtml("#ff1919"); thd_temp.PxLocation[2] = new Point(820, 120); thd_temp.PxColors[3] = ColorTranslator.FromHtml("#ff1919"); thd_temp.PxLocation[3] = new Point(1064, 120); AS.Add(thd_temp); //------------------------------------------------------------- thd_temp = new AmongState(); thd_temp.NameOf = "TabletCorner"; thd_temp.Pan = gameWatcher.panel_TabletCorner; thd_temp.Lab = label_tabletcorner; thd_temp.Lab_o = label_tabletcorner_o; thd_temp.Size = thd_temp.Pan.ClientSize; thd_temp.PxColors = new Color[4]; thd_temp.PxLocation = new Point[4]; thd_temp.PxColors[0] = ColorTranslator.FromHtml("#b4bfcc"); thd_temp.PxLocation[0] = new Point(35, 2); thd_temp.PxColors[1] = ColorTranslator.FromHtml("#a2acb7"); thd_temp.PxLocation[1] = new Point(35, 10); thd_temp.PxColors[2] = ColorTranslator.FromHtml("#8f97a4"); thd_temp.PxLocation[2] = new Point(35, 24); thd_temp.PxColors[3] = ColorTranslator.FromHtml("#848b96"); thd_temp.PxLocation[3] = new Point(15, 15); AS.Add(thd_temp); //------------------------------------------------------------- thd_temp = new AmongState(); thd_temp.NameOf = "End"; thd_temp.Pan = gameWatcher.panel_WinDef; thd_temp.Lab = label_end; thd_temp.Lab_o = label_end_o; thd_temp.Size = thd_temp.Pan.ClientSize; thd_temp.PxColors = new Color[4]; thd_temp.PxLocation = new Point[4]; thd_temp.PxColors[0] = ColorTranslator.FromHtml("#008cff"); thd_temp.PxLocation[0] = new Point(359, 88); thd_temp.PxColors[1] = ColorTranslator.FromHtml("#000000"); thd_temp.PxLocation[1] = new Point(403, 93); thd_temp.PxColors[2] = ColorTranslator.FromHtml("#008cff"); thd_temp.PxLocation[2] = new Point(529, 69); thd_temp.PxColors[3] = ColorTranslator.FromHtml("#008cff"); thd_temp.PxLocation[3] = new Point(697, 69); AS.Add(thd_temp); thd_temp = new AmongState(); thd_temp.NameOf = "End"; thd_temp.Pan = gameWatcher.panel_WinDef; thd_temp.Lab = label_end; thd_temp.Lab_o = label_end_o; thd_temp.Size = thd_temp.Pan.ClientSize; thd_temp.PxColors = new Color[4]; thd_temp.PxLocation = new Point[4]; thd_temp.PxColors[0] = ColorTranslator.FromHtml("#ff0000"); thd_temp.PxLocation[0] = new Point(73, 75); thd_temp.PxColors[1] = ColorTranslator.FromHtml("#000000"); thd_temp.PxLocation[1] = new Point(261, 91); thd_temp.PxColors[2] = ColorTranslator.FromHtml("#ff0000"); thd_temp.PxLocation[2] = new Point(309, 95); thd_temp.PxColors[3] = ColorTranslator.FromHtml("#ff0000"); thd_temp.PxLocation[3] = new Point(611, 87); AS.Add(thd_temp); thd_temp = new AmongState(); thd_temp.NameOf = "Player0"; thd_temp.Pan = gameWatcher.panel_p0; thd_temp.Lab = null; thd_temp.Lab_o = null; thd_temp.Size = thd_temp.Pan.ClientSize; AS.Add(thd_temp); }
private bool GetTextFromPanel(AmongState item) { Bitmap bmp; try { bmp = new Bitmap(item.Size.Width, item.Size.Height); //System.ArgumentException: 'Parameter is not valid.' Graphics g = Graphics.FromImage(bmp); g.CopyFromScreen(item.Pan.PointToScreen(new Point(0, 0)), new Point(0, 0), new Size(item.Size.Width, item.Size.Height)); } catch (Exception) { return(false); } for (int i = 0; i < item.PxLocation.Length; i++) { if (item.PxColors[i] != bmp.GetPixel(item.PxLocation[i].X, item.PxLocation[i].Y)) { /* * if (item.NameOf == "End") * { * timer_tester.Stop(); * DialogResult dr = MessageBox.Show( * (item.PxColors[0] == bmp.GetPixel(item.PxLocation[0].X, item.PxLocation[0].Y)).ToString() + "\n" + * (item.PxColors[1] == bmp.GetPixel(item.PxLocation[1].X, item.PxLocation[1].Y)).ToString() + "\n" + * (item.PxColors[2] == bmp.GetPixel(item.PxLocation[2].X, item.PxLocation[2].Y)).ToString() + "\n" + * (item.PxColors[3] == bmp.GetPixel(item.PxLocation[3].X, item.PxLocation[3].Y)).ToString() * * ); * if (dr == DialogResult.OK) * timer_tester.Start(); * } */ return(false); } } return(true); /* * if (item.Px) * { * item.PxColors[0] = item.Bmp.GetPixel(35, 2); //180, 191, 204 b4bfcc * item.PxColors[1] = item.Bmp.GetPixel(35, 10); //162, 172, 183 a2acb7 * item.PxColors[2] = item.Bmp.GetPixel(35, 24); //143, 151, 164 8f97a4 * item.PxColors[3] = item.Bmp.GetPixel(15, 15); //132, 139, 150 848b96 * * for (int i = 0; i < item.PxColors.Length; i++) * { * if (item.PxColors[i] != PxLookFor[i]) * return false; * } * return true; * } * else * { * try * { * item.Engine = new TesseractEngine("./tessdata", "eng", EngineMode.Default); * Page page = item.Engine.Process(item.Bmp, PageSegMode.Auto); * foreach (var element in item.LookFor) * { * item.Lab_o.Text = page.GetText(); //System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt. * if (item.Lab_o.Text.Contains(element)) * return true; * } * return false; * } * catch (Exception) * { * return false; * } * } */ }