public void Run(string command, double?timeoutInSeconds = 1) { if (_process == null || _process.HasExited) { throw new InvalidOperationException("The Sikuli process is not running"); } _asyncStreamsHandler.WriteLine(command); _asyncStreamsHandler.WriteLine(string.Empty); _asyncStreamsHandler.WriteLine(string.Empty); var result = _asyncStreamsHandler.ReadUntil((double)timeoutInSeconds, Constants.ErrorMarker, Constants.ResultPrefix); if (result.IndexOf(Constants.ErrorMarker, StringComparison.Ordinal) <= -1) { return; } result = result + Environment.NewLine + string.Join(Environment.NewLine, _asyncStreamsHandler.ReadUpToNow(0.1d)); if (!result.Contains("FindFailed")) { throw new ImageRecognitionException(result); } var regex = new Regex("FindFailed: .+"); throw new ImageRecognitionFindFailedException(regex.Match(result).Value); }
public string Run(string command, string resultPrefix, double timeoutInSeconds) { if (_process == null || _process.HasExited) { throw new InvalidOperationException("The Sikuli process is not running"); } _asyncTwoWayStreamsHandler.WriteLine(command); _asyncTwoWayStreamsHandler.WriteLine(""); _asyncTwoWayStreamsHandler.WriteLine(""); string result = _asyncTwoWayStreamsHandler.ReadUntil(timeoutInSeconds, ErrorMarker, resultPrefix); if (result.IndexOf(ErrorMarker, StringComparison.Ordinal) > -1) { result = result + Environment.NewLine + string.Join(Environment.NewLine, _asyncTwoWayStreamsHandler.ReadUpToNow(0.1d)); if (result.Contains("FindFailed")) { throw new SikuliFindFailedException(result); } throw new SikuliException(result); } return(result); }