public override ScreenSearchResult IsActive(Image<Bgra, byte> windowContents) { var image = windowContents.Copy(_rectangle); var text = (RequiresZoom ? GetZoomedOutText(image, 8, AdditionalCharacters) : GetText(image, AdditionalCharacters)).Trim(); var result = new ScreenSearchResult { Success = text == _text }; if (result.Success) { result.Screen = this; } return result; }
public ScreenSearchResult WaitForTemplate(params Image<Bgra, byte>[] templates) { var endTime = DateTime.Now.Add(_controlTimeout); var search = new ScreenSearchResult(); do { Thread.Sleep(100); if (AutoItNative.AU3_WinActive(_windowTitle, String.Empty) == 0) { return search; } var windowContents = GetWindowImage(); foreach (var template in templates) { search = IsTemplateInWindow(windowContents, template); if (search.Success) { break; } } } while (DateTime.Now < endTime && !search.Success); return search; }
public ScreenSearchResult WaitForScreen(params IGameScreen[] screens) { if (AutoItNative.AU3_WinActive(_windowTitle, String.Empty) == 0) { return new ScreenSearchResult(); } // Don't want the mouse to be in any of the screenshots we use MoveMouseOffscreen(); var endTime = DateTime.Now.Add(_controlTimeout); var search = new ScreenSearchResult(); do { Thread.Sleep(100); if (AutoItNative.AU3_WinActive(_windowTitle, String.Empty) == 0) { return search; } var windowContents = GetWindowImage(); foreach (var screen in screens) { search = screen.IsActive(windowContents); if (search.Success) { search.Screen = screen; break; } } } while (DateTime.Now < endTime && !search.Success); return search; }