/// <summary> /// Wait until the pixel changes its color to the specified one /// </summary> /// <param name="p">Database point</param> /// <param name="w">Target window rectangle</param> /// <param name="c">Target color</param> /// <param name="t">Cancellation token</param> /// <param name="k">Virtual key code for user abort</param> /// <param name="lim">Optional time limit (mS), 0 = no limit</param> /// <returns>False on timeout, true otherwise</returns> public static bool WaitForPixel(ClickPoint p, Rectangle w, Color c, CancellationTokenSource t, WindowsInput.Native.VirtualKeyCode k, int lim = 0) { Point d = p.GetPoint(PointReference.TopLeft, w); int cnt = 0; while (Native.GetPixelColor(d) != c) //This API has a high performance impact { Sleep(200); cnt += 200; if (lim > 0) { if (lim <= cnt) { return(false); } } if (t != null) { if (t.IsCancellationRequested) { break; } } if (CheckKeyPressed(k)) { break; } } return(true); }
/// <summary> /// Move to specified point and click left mouse button /// </summary> /// <param name="p">Database point</param> /// <param name="w">Target window rectangle</param> public static void MouseClick(ClickPoint p, Rectangle w) { //Point d = p.GetDesktopPoint(w); //simulatorInstance.Mouse.MoveMouseToPositionOnVirtualDesktop(d.X, d.Y).Sleep(1).LeftButtonClick(); //InputSimulator somehow has effective resolution of 800x600, API import provides real resolution Native.SetCursorPosition(p.GetPoint(PointReference.TopLeft, w)); simulatorInstance.Mouse.LeftButtonClick(); }
public static void LeftMouseDoubleClick(ClickPoint p, Rectangle w) { Native.SetCursorPosition(p.GetPoint(PointReference.TopLeft, w)); simulatorInstance.Mouse.LeftButtonDoubleClick(); }
/// <summary> /// Wait until the pixel changes its color to the specified one. /// Use default user abort key (right Control) /// </summary> /// <param name="p">Database point</param> /// <param name="w">Target window rectangle</param> /// <param name="c">Target color</param> /// <param name="t">Cancellation token</param> /// <param name="lim">Optional time limit (mS), 0 = no limit</param> /// <returns>False on timeout, true otherwise</param> /// <returns></returns> public static bool WaitForPixel(ClickPoint p, Rectangle w, Color c, CancellationTokenSource t, int lim = 0) { return(WaitForPixel(p, w, c, t, WindowsInput.Native.VirtualKeyCode.RCONTROL, lim)); }