Skip to content

MenuItem Invoke() is blocking #203

@jakubsuchybio

Description

@jakubsuchybio

In MSFT Docs: https://docs.microsoft.com/en-us/windows/desktop/api/UIAutomationClient/nf-uiautomationclient-iuiautomationinvokepattern-invoke
there is

Remarks
Calls to this method should return immediately without blocking. However, this behavior depends on the implementation.

So on Windows 10 with Win.Forms app it is blocking.

The problem with this is, that this MenuItem which I am Invoking creates modal window and I need to perform some action on that modal window with FlaUI, but I can't, because that Invoke won't return until the modal window is closed.

I tried to go around by making invoke as non-awaited task, which in theory would result in that Task getting blocked by Invoke, but the rest of the code would find that modal window, close it and in that instant the blocked Task would end.

However this doesn't work and I don't know why :(

I tried to reproduce it with notepad.exe, but I couldn't. It works in notepad. I then looked at FlaUIInspect if there is a difference between notepad's Help->About and our software Help->About and it is...
See here: https://i.imgur.com/PoqoHLr.png
For some reason FlaUIInspect can't find our HelpDropDown Items.

Here are selected menus from both apps:
https://i.imgur.com/2zr7uNN.png
https://i.imgur.com/mr5oOxO.png

I looked into our code for something that could be breaking this, but I found only standard things. The only difference that could do this is that our HelpMenu is not statically set from designer at startup, but it is dynamically created at runtime after some logic is checked.

Any ideas about this? :/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions