0

In FLAUI trying to get a reference to a child element that starts with some letters or contains some for letters. example start with or "DOC" or contains "DOC" what I'm trying to do is that I'm opening some office files like doc,xls, ppt. and want to attach the file as he is open to the screen.

      foreach (var file in listOfFiles)
        {
            if (file.Name.Contains("DOC") || file.Name.Contains("PPT") || file.Name.Contains("XLS") || file.Name.Contains("TXT"))
            {                
                file.AsButton().Invoke();
                
                var window = new UIA3Automation();
                desktopWindow = window.GetDesktop();
                desktopWindow = WaitForElement(() => desktopWindow.FindFirstChild(cr => cr.ByName("// Here want to put name that start with ... or contains ...")));
                var app = FlaUI.Core.Application.Attach(desktopWindow.Properties.ProcessId);
                var application = app.GetMainWindow(new UIA3Automation());
                CloseingProcess(application.Name);
                

img

phux
  • 1
  • 1

1 Answers1

1

If I understood you correctly, you want to check if a file that's already open has the extension you need. Correct?

For that, you have to get a hold of the window with FlaUI and with that you can check for the property .Title on the Window class, like below:

var automation = new UIA3Automation();
var app = FlaUI.Core.Application.Attach(application.Process.Id); //attach or start application here
var window = app.GetMainWindow(automation); //Get hold
window.Title //Use the .Title or .TitleBar property to check for your extension.
ojonasplima
  • 411
  • 2
  • 12