Thanks for your answer.
”Application windows are referenced by index, their position in their application's window stack, front to back, with 1 being frontmost, 2 being the window behind that, and so on.”
I know that, and that's precisely the problem!
I need to bring a specific window to the foreground so that I can then interact with it. The “relative” position of a window in the window stack is therefore of no use to me, as the index can change at any time.
Currently, I have positioned my windows with a natural offset (automatic positioning when each new window is opened).
To bring one of them to the foreground, I click on the corner of the correct window that is always visible.
This has been working for months, but it's not very “clean” programming. The slightest accidental movement of a window, or if another window is opened on top of my improvised “handles,” and my whole process collapses.
The ideal solution would be to have a UNIQUE and INVARIABLE identifier for each window so that I can always bring the right window to the foreground when I need to.
And as I mentioned, I can't call a window by its name, because they all have the same name, generated by Mac OS.
Nothing mysterious: I'm monitoring several instances of the same iOS app running on multiple sessions on a Mac Studio M1Ultra.
This monitoring allows me to view and perform actions on these app instances through shared windows.
The problem is that Mac OS itself defines the name of my screen sharing windows (it's always the name of the Mac Studio) and it's impossible to change this name.
So I have a stack of windows with the same name and I want a sure and precise way to address the right window to perform my actions.