/// <summary> /// Waits for the specified text to appear at the specified location. /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="text"></param> /// <param name="timeoutMS"></param> /// <returns></returns> public bool WaitForText(int x, int y, string text, int timeoutMS) { if (currentConnection == null) { throw new TNHostException("TNEmulator is not connected", "There is no currently open TN3270 connection", null); } var start = DateTime.Now.Ticks; //bool ok = false; if (Config.AlwaysRefreshWhenWaiting) { lock (this) { DisposeOfCurrentScreenXML(); currentScreenXML = null; } } do { if (CurrentScreenXML != null) { var screenText = CurrentScreenXML.GetText(x, y, text.Length); if (screenText == text) { if (Audit != null) { Audit.WriteLine("WaitForText('" + text + "') Found!"); } return(true); } } // if (timeoutMS == 0) { if (Audit != null) { Audit.WriteLine("WaitForText('" + text + "') Not found"); } return(false); } // Thread.Sleep(100); if (Config.AlwaysRefreshWhenWaiting) { lock (this) { DisposeOfCurrentScreenXML(); currentScreenXML = null; } } Refresh(true, 1000); } while ((DateTime.Now.Ticks - start) / 10000 < timeoutMS); // if (Audit != null) { Audit.WriteLine("WaitForText('" + text + "') Timed out"); } return(false); }
/// <summary> /// Dump current screen to the current audit output /// </summary> public void Dump() { lock (this) { if (sout != null) { CurrentScreenXML.Dump(sout); } } }
/// <summary> /// Dump current screen to the current audit output /// </summary> public void Dump() { lock (this) { if (Audit != null) { CurrentScreenXML.Dump(Audit); } } }
/// <summary> /// Waits for the specified text to appear at the specified location. /// </summary> /// <param name="timeoutMS"></param> /// <param name="text"></param> /// <returns>StreingPosition structure</returns> public StringPosition WaitForTextOnScreen2(int timeoutMS, params string[] text) { if (WaitForTextOnScreen(timeoutMS, text) != -1) { return(CurrentScreenXML.LookForTextStrings2(text)); } else { return(null); } }
/// <summary> /// Wait for some text to appear at the specified location /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="text"></param> /// <param name="timeoutMS"></param> /// <returns></returns> public bool WaitForText(int x, int y, string text, int timeoutMS) { if (currentConnection == null) { throw new TNHostException("TNEmulator is not connected", "There is no currently open TN3270 connection", null); } long start = DateTime.Now.Ticks; //bool ok = false; if (Config.AlwaysRefreshWhenWaiting) { lock (this) { this._currentScreenXML = null; } } do { if (CurrentScreenXML != null) { string screenText = CurrentScreenXML.GetText(x, y, text.Length); if (screenText == text) { return(true); } } // if (timeoutMS == 0) { return(false); } // System.Threading.Thread.Sleep(100); if (Config.AlwaysRefreshWhenWaiting) { lock (this) { this._currentScreenXML = null; } } Refresh(true, 1000); }while (((DateTime.Now.Ticks - start) / 10000) < timeoutMS); // return(false); }
/// <summary> /// Dump fields to the current audit output /// </summary> public void ShowFields() { if (currentConnection == null) { throw new TNHostException("TNEmulator is not connected", "There is no currently open TN3270 connection", null); } if (Audit != null) { Audit.WriteLine("-------------------dump screen data -----------------"); currentConnection.ExecuteAction(false, "Fields"); Audit.WriteLine("" + currentConnection.GetAllStringData(false)); CurrentScreenXML.Dump(Audit); Audit.WriteLine("-------------------dump screen end -----------------"); } else { throw new ApplicationException("ShowFields requires an active 'Audit' connection on the emulator"); } }
/// <summary> /// Waits for the specified text to appear at the specified location. /// </summary> /// <param name="timeoutMS"></param> /// <param name="text"></param> /// <returns>Index of text on screen, -1 if not found or timeout occurs</returns> public int WaitForTextOnScreen(int timeoutMS, params string[] text) { if (currentConnection == null) { throw new TNHostException("TNEmulator is not connected", "There is no currently open TN3270 connection", null); } long start = DateTime.Now.Ticks; //bool ok = false; if (Config.AlwaysRefreshWhenWaiting) { lock (this) { DisposeOfCurrentScreenXML(); this.currentScreenXML = null; } } do { lock (this) { if (CurrentScreenXML != null) { int index = CurrentScreenXML.LookForTextStrings(text); if (index != -1) { if (Audit != null) { Audit.WriteLine("WaitForText('" + text[index] + "') Found!"); } return(index); } } } // if (timeoutMS > 0) { // System.Threading.Thread.Sleep(100); if (Config.AlwaysRefreshWhenWaiting) { lock (this) { DisposeOfCurrentScreenXML(); this.currentScreenXML = null; } } Refresh(true, 1000); } }while (timeoutMS > 0 && ((DateTime.Now.Ticks - start) / 10000) < timeoutMS); // if (Audit != null) { string temp = ""; foreach (string t in text) { temp += "t" + "//"; } Audit.WriteLine("WaitForText('" + temp + "') Timed out"); } return(-1); }
/// <summary> /// Retrieves text at the specified location on the screen /// </summary> /// <param name="x">Column</param> /// <param name="y">Row</param> /// <param name="length">Length of the text to be returned</param> /// <returns></returns> public string GetText(int x, int y, int length) { return(CurrentScreenXML.GetText(x, y, length)); }