/// <summary> /// Powershell logic. /// </summary> protected override void ProcessRecord() { var ss = new ScreenScraper(); var pos = ss.Find(ss.CaptureScreen(), Image); if (pos.Right == -1 && pos.Left == -1) { throw new ApplicationException("Can't find image on screen!"); } ss.MoveMouse(pos.X + XOffset, pos.Y + YOffset); if (Click) { ss.MouseClick(Button == "Left" ? MouseButton.Left : MouseButton.Right); } else if (Up) { ss.MouseUp(Button == "Left" ? MouseButton.Left : MouseButton.Right); } else if (Down) { ss.MouseDown(Button == "Left" ? MouseButton.Left : MouseButton.Right); } }
/// <summary> /// Powershell logic. /// </summary> protected override void ProcessRecord() { var ss = new ScreenScraper(); while (true) { var result = ss.Find(ss.CaptureScreen(), Image); if (result.Left != -1 && result.Right != -1) { break; } } }
/// <summary> /// Powershell logic. /// </summary> protected override void ProcessRecord() { var ss = new ScreenScraper(); if (SearchInImage == null) { SearchInImage = ss.CaptureScreen(); } var result = ss.Find(SearchInImage, Image); //-1 indicates it didn't find the image. WriteObject(result.Left != -1 && result.Right != -1); }