private static string EditInOut(AutomationElement ae, bool isOut, string key, string windowName) { if (isOut) { ValuePattern pattern; pattern = ae.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern; return(pattern.Current.Value); } else { ValuePattern pattern; pattern = ae.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern; Utility.wait(2); try { pattern.SetValue(key); } catch (InvalidOperationException) { ControlOp co = new ControlOp(); co.SetForeground(windowName); Utility.wait(2); KeyboardOp.sendKey(key); Utility.wait(2); return("key sent"); } return("No key sent"); } }