internal void CallInvokePattern(PatternCmdletBase cmdlet, IUiElement control, IUiElement inputObject)
{
try {
// IInvokePattern invokePattern = control.GetInvokePattern();
// IInvokePattern invokePattern = control.GetCurrentPattern<IInvokePattern, InvokePattern>();
IInvokePattern invokePattern = control.GetCurrentPattern<IInvokePattern>(classic.InvokePattern.Pattern);
if (invokePattern != null) {
invokePattern.Invoke();
if (PassThru && null != (inputObject as IUiElement)) {
WriteObject(this, inputObject);
} else {
WriteObject(this, true);
}
} else {
if (Preferences.PerformWin32ClickOnFail) {
// 20131230
// ClickControl(this, control, false, false, false, false, false, false, false, 0, 0,
// 0);
ClickControl(
this,
control,
new ClickSettings());
if (PassThru && null != (inputObject as IUiElement)) {
WriteObject(this, inputObject);
} else {
WriteObject(this, true);
}
} else {
WriteVerbose(this, "couldn't get InvokePattern");
WriteObject(this, false);
}
}
} catch (Exception eInvokePatternException) {
WriteVerbose(this, eInvokePatternException.Message + "\r\n" + eInvokePatternException.GetType().Name);
if (Preferences.PerformWin32ClickOnFail &&
"ElementNotAvailableException" != eInvokePatternException.GetType().Name) {
// 20131230
// ClickControl(this, control, false, false, false, false, false, false, false, 0, 0,
// 0);
ClickControl(
this,
control,
new ClickSettings());
if (PassThru && null != (inputObject as IUiElement)) {
WriteObject(this, inputObject);
} else {
WriteObject(this, true);
}
} else {
}
// no reaction
}
}