Check if a window of the OS is open (and foreground)

With the current API 6, is there a way to detect that a window whose path is known is open, to avoid opening it again in another window and placing it in the foreground?

  • For example, to open a window:
  • But if the window is already open, how to place it in the foreground?