public void SendKey(TnKey tnKey) { var keySent = Emulator3270.SendKey(true, tnKey, _emulatorConfig.TimeOut); if (keySent) { if (!Emulator3270.WaitForHostSettle(200, _emulatorConfig.TimeOut)) { RaiseException(new Exception("Timeout waitting for host to settle!")); } } else { RaiseException(new Exception("Timeout sending Key '" + tnKey.ToString() + "'")); } }
private void SendKey_Click(object sender, RoutedEventArgs e) { try { TnKey key = (TnKey)Enum.Parse(typeof(TnKey), KeytoSend.SelectedValue.ToString()); mDriver.MFE.SendKey(key); if (RecordBtn.IsChecked == true) { if (mDriver.mBusinessFlow == null) { return; } ActMainframeSendKey AMSK = new ActMainframeSendKey(); AMSK.Description = ("Send " + key.ToString() + " Key to Mainframe "); mDriver.mBusinessFlow.CurrentActivity.Acts.Add((Actions.Act)AMSK); } Refresh(); } finally { } }
/// <summary> /// Sends the specified key stroke to the emulator. /// </summary> /// <param name="waitForScreenToUpdate"></param> /// <param name="key"></param> /// <param name="timeout"></param> /// <returns></returns> public bool SendKey(bool waitForScreenToUpdate, TnKey key, int timeout) { bool triggerSubmit = false; bool success = false; string command; //This is only used as a parameter for other methods when we're using function keys. //e.g. F1 yields a command of "PF" and a functionInteger of 1. int functionInteger = -1; if (sout != null && Debug == true) { sout.WriteLine("SendKeyFromText(" + waitForScreenToUpdate + ", \"" + key.ToString() + "\", " + timeout + ")"); } if (currentConnection == null) { throw new TNHostException("TNEmulator is not connected", "There is no currently open TN3270 connection", null); } //Get the command name and accompanying int parameter, if applicable if (Constants.FunctionKeys.Contains(key)) { command = "PF"; functionInteger = Constants.FunctionKeyIntLUT[key]; } else if (Constants.AKeys.Contains(key)) { command = "PA"; functionInteger = Constants.FunctionKeyIntLUT[key]; } else { command = key.ToString(); } //Should this action be followed by a submit? triggerSubmit = this.Config.SubmitAllKeyboardCommands || this.currentConnection.KeyboardCommandCausesSubmit(command); if (triggerSubmit) { lock (this) { this.DisposeOfCurrentScreenXML(); currentScreenXML = null; if (sout != null && Debug) { sout.WriteLine("mre.Reset. Count was " + semaphore.Count); } // Clear to initial count (0) semaphore.Reset(); } } success = this.currentConnection.ExecuteAction(triggerSubmit, command, functionInteger); if (sout != null && Debug) { sout.WriteLine("SendKeyFromText - submit = " + triggerSubmit + " ok=" + success); } if (triggerSubmit && success) { // Wait for a valid screen to appear if (waitForScreenToUpdate) { success = this.Refresh(true, timeout); } else { success = true; } } return(success); }