public void LoginToPoker() { string username = textBox1.Text; string password = textBox2.Text; copyXML(); killPrevious(); while (true) { if (!isLoggedIn()) { Stopwatch s = new Stopwatch(); s.Start(); StartPoker(); IntPtr hWnd = GetHandleWindow("Poker"); MoveWindow(hWnd, 0, 40, 0, 0, true); bool l = TemplateMatching.WaitForElement(hWnd, LoginHeader, 15, new Rectangle(new Point(133 - 20, 192 - 20), new Size(294 + 35, 38 + 35))); if (!l) { TemplateMatching.WaitForElement(hWnd, LoginHeader, 60); } Keyboard.sendKeys(hWnd, username); Keyboard.sendTab(hWnd); Keyboard.sendKeys(hWnd, password); Keyboard.sendEnter(hWnd); bool srh = TemplateMatching.WaitForElement(hWnd, SelectRoomHeader, 15, new Rectangle(new Point(16 - 10, 129 - 20), new Size(101 + 35, 26 + 35))); if (!srh) { TemplateMatching.WaitForElement(hWnd, SelectRoomHeader, 60); } ClickableCoordinate ko2 = TemplateMatching.getClickableCoordinate(hWnd, Players, 15, 0, 0, new Rectangle(new Point(469 - 10, 149 - 20), new Size(50 + 12, 27 + 23))); if (ko2 == null) { ClickableCoordinate login2 = TemplateMatching.getClickableCoordinate(hWnd, Players, 60, 0, 0); Mouse.leftClick(hWnd, login2); } else { Mouse.leftClick(hWnd, ko2); } ClickableCoordinate ko3 = TemplateMatching.getClickableCoordinate(hWnd, Players, 15, 0, 0, new Rectangle(new Point(469 - 10, 149 - 20), new Size(50 + 12, 27 + 23))); if (ko3 == null) { ClickableCoordinate login3 = TemplateMatching.getClickableCoordinate(hWnd, Players, 60, 0, 0); Mouse.leftClick(hWnd, login3); } else { Mouse.leftClick(hWnd, ko3); } ClickableCoordinate dark2 = TemplateMatching.getClickableCoordinate(hWnd, Dark, 10, 0, 0, new Rectangle(new Point(16 - 12, 129 - 20), new Size(600 + 12, 360 + 23))); if (dark2 != null) { Mouse.leftClick(hWnd, dark2); } else { ClickableCoordinate dark = TemplateMatching.getClickableCoordinate(hWnd, Dark, 0, 0, 0); if (dark != null) { Mouse.leftClick(hWnd, dark); } else { ClickableCoordinate light2 = TemplateMatching.getClickableCoordinate(hWnd, Light, 10, 0, 0, new Rectangle(new Point(16 - 12, 129 - 20), new Size(600 + 12, 360 + 23))); if (light2 != null) { Mouse.leftClick(hWnd, light2); } else { ClickableCoordinate light = TemplateMatching.getClickableCoordinate(hWnd, Light, 0, 0, 0); if (light != null) { Mouse.leftClick(hWnd, light); } } } } Keyboard.sendEnter(hWnd); bool b = isLoggedIn(30); Thread.Sleep(1000); } } }
public static void leftClick(IntPtr Handle, ClickableCoordinate cc) { PostMessage(Handle, WM_LBUTTONDOWN, 1, MakeLParam(cc.X, cc.Y)); PostMessage(Handle, WM_LBUTTONUP, 0, MakeLParam(cc.X, cc.Y)); }