Giter Club home page Giter Club logo

Comments (9)

louislefevre avatar louislefevre commented on May 27, 2024

Could you provide some code with what you've done? Would be easier to get a better idea about what you're trying to do

from flaui.

SunnyDesignor avatar SunnyDesignor commented on May 27, 2024
var app = FlaUI.Core.Application.Attach("xxx.exe");
using (var automation = new UIA3Automation())
{
  var window = app.GetAllTopLevelWindows(automation).FirstOrDefault(t => t.Name == "Client.Main.Views.AppendViewModel");
  window.FindFirstDescendant(t => t.ByName("Accept")).AsButton()?.Invoke();
}

from flaui.

Roemer avatar Roemer commented on May 27, 2024

Can you please measure each call individually (app.GetAllTopLevelWindows, window.FindFirstDescendant) to see which of those 2 is the slower one?
If it indeed is the first one, you can always directly search the window directly:

var window  = automation.GetDesktop().FindFirstChild(cf =>
    cf.ByControlType(ControlType.Window)
    .And(cf.ByProcessId(app.ProcessId))
    .And(cf.ByName("Client.Main.Views.AppendViewModel"))
);

from flaui.

SunnyDesignor avatar SunnyDesignor commented on May 27, 2024

GetAllTopLevelWindows is slower, taking 3 seconds, but the new method you provided is effective, reducing the time to 0.2 seconds. Additionally, GetAllTopLevelWindows is not as slow as before, perhaps because my system has been restarted.

from flaui.

Roemer avatar Roemer commented on May 27, 2024

When it gets all windows from the top level (desktop), UIA queries the Windows-Objects underneath and it might encounter a window (application) that is hanging for some time until it responds, making the whole request slow. If you want, you could try to get each window from the GetDesktop individually and see, if there is one or a few that takes longer to get a response.

from flaui.

SunnyDesignor avatar SunnyDesignor commented on May 27, 2024

How do I enumerate it? The code in the loop passes quickly, and the time is concentrated on FindAllChildren.
foreach (var element in automation.GetDesktop().FindAllChildren(a => a.ByControlType(FlaUI.Core.Definitions.ControlType.Window)))
{
element.Name.Dump();
element.FindAllChildren();
}

from flaui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.