How can I use a Window Handle with an Application/Browser Card?

I have several windows with duplicate title bar text. Therefore, my Applicaton Card’s selector targets the most recently active window (most of the time). I understand how to pass a window handle id number into the workflow and use it in an Attach Window activity.

In this case, however, I am asking:

How can I use a Window Handle id with the Application/Browser card?

Additional info:
I have several windows open with the exact same name (e.g. Notepad)
I desire to target my workflow to act a particular application instance, using only the window handle in an Use Application/Browser activity, to identify the window.

For how to accomplish this with an Attach Window activity, please see the solution provided by: @ptrobot: How can I use a Window Handle with an Attach Window activity?

Hi,

We can achieve it using Input Element property with the following expression, for example. Can you try this?

new UiPath.Core.UiElement(new UiPath.Core.Window(winHandle))

In general, we can set appWindow variable at InputElement property in the above image, to operate at same window.

Regards,

1 Like

Perfect! Thank you!

In my particular case, I pass the winHandle as an Int32 argument. Therefore, the slightly modified line of code that I used for the Input Element is:

new UiPath.Core.UiElement(new UiPath.Core.Window(new System.IntPtr(winHandle)))

Again, @Yoichi, thank you for your perfect answer!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.