protected async void attachFile()
{
_fileAttachment = String.Empty;
await getFileToAttach();
if (String.IsNullOrEmpty(_fileAttachment))
{
return;
}
Thread.Sleep(500);
EnumWindows.RestoreFocusToTopWindow();
Thread.Sleep(500);
AgentManager.Instance.Keyboard.Send(Keys.F10);
AgentManager.Instance.Keyboard.Send(Keys.H);
AgentManager.Instance.Keyboard.Send(Keys.A);
AgentManager.Instance.Keyboard.Send(Keys.F);
Thread.Sleep(1000);
for (int ii = 0; ii < 10; ii++)
{
var info1 = WindowActivityMonitor.GetForegroundWindowInfo();
if (info1.Title == "Insert File")
{
Log.Debug("YES! Found Attach file window");
var automationElement = AgentUtils.GetElementOrAncestorByAutomationId(
info1.FocusedElement,
"Edit",
"ControlType.Edit",
"1148");
if (automationElement != null)
{
Log.Debug("element is not null");
AgentUtils.InsertTextIntoElement(automationElement, _fileAttachment);
SendKeys.Send("{ENTER}");
}
else
{
Log.Debug("element is null");
}
break;
}
Thread.Sleep(500);
}
}