Two programs with identical windows and ApplicationWindow

So I have two systems. When I sign into them the windows are identical, there is not a single unique selector.

I have been using the ApplicationWindow parameter inside of the Attach Window activity.
When you assing a variable to ApplicationWindow the variable will get an unique handle.

This has all worked good for a long time. But last week the systems started to be slow or act “strange” from before and the ApplicationWindow in the 2nd system the robot signed into
did not get an unique handle. the handle number now was exactly the same as in the 1st system. This made the REF-process do everything in system 1 only.

I have now implemented an IF activity that checks if the handles are identical or not. If they are identical it throws an error.

My questions:

  1. What is the best way to handle exceptions with ApplicationWindow and if they dont get their unique handle, is it the way I did it the best or is there a different way?

  2. How does Studio(UiPath) focus windows when they are multiple windows that are exactly the same. How can I be sure that ApplicationWindow doesnt “overwrite” the handle?
    Because when the system first starts there is no unique way to distinguish them.

Example:
Two identical notepad windows.

How does studio know what window to focus on before it has assigned an unique handle?

Is it the last focused window and if it is like that, how does the focus work in depth?

@atomic

If we deal with the two Identical notepad windows then we have an option to include the Title

As we don’t have your application which you are referring too, It’s difficult to say

Thanks

@Srini84 It was only an example.

I am wondering about when two programs/windows are exactly the same.

@atomic

So are you working those in parallel?

I think you can go one application at a one time

Maybe it’s wrong

Thanks

@Srini84

Yes, the robot work in these applications at the same time.
The only thing that is different between these two applications are the database.

Yes, making two REF-processes was one way to solve this but that is the last step/solution if nothing else works.

Anyone have any thoughts about this?

in such a case we can use the window variable (e.g. output from open application) and can control which instance is to access

@ppr

I had some question regarding this:

My questions:

  1. What is the best way to handle exceptions with ApplicationWindow and if they dont get their unique handle(“window variable”), is it the way(see above/topic start) I did it the best or is there a different way?
  2. How does Studio(UiPath) focus windows when they are multiple windows that are exactly the same. How can I be sure that ApplicationWindow doesnt “overwrite” the handle?
    Because when the system first starts there is no unique way to distinguish them.

Example:
Two identical notepad windows.

How does studio know what window to focus on before it has assigned an unique handle?

Is it the last focused window and if it is like that, how does the focus work in depth?

When two windows will have the same descriptive labels (e.g. the Window Title) so e.g. an Attach window will take the first found one.

internaly it is differentiated.

Thats why we are working in a scenario described above with the window variables.
Internally the window variable has a property e.g. Handle and can be used for the differentation.

Also we can create the window variable with the Handle (e.g. retrieved from the Windows.Process)
new Window(Process.GetProcessesByName(“notepad”).First().Handle) ← Line is for explanation and not for usage without exploring the topic in advance

1 Like

So Example:

  1. Robot opens “program 1” → attach window → gives it a unique handle(output)
  2. Robot opens “program 2”(exactly the same as “program 1”) → attach window → gives it a unique handle(output).

The robot cant mistakenly focus on program 1 in step 2?
Note that program 1 and program 2 are open constantly during the process.

I guess the system is smart and knows which program/window it is working with currently even if the programs/windows are exactly the same. Otherwise this would not work at all.
Maybe this is what you said: “internaly it is differentiated.”

Feel free to explore and get an entry to this knowledge area

New Empty Sequence:

  • Open Application - notepad.exe - assign to the output: WindowA
    grafik

  • Open Application - notepad.exe - assign to the output: WindowB

use an Attach Window- and use WindowA
grafik

  • let something type into notepad

use an Attach Window- and use WindowB

  • let something type into notepad

And check when it was written to A and when was it written B