In Applescript, how can I correctly obtain values for a process window that is the not the front window? I currently have an Applescript that takes values from Google Chrome, but it only works if Chrome is the front window. In the case Chrome is behind another window, it no longer works:
tell application &quot;System Events&quot;
    repeat while &quot;Chrome&quot; is in (name of application processes)
        try
            tell process &quot;Chrome&quot; to set VALUE to value of every static text of every sheet of front window
            if {{&quot;somevalue&quot;}} is in VALUE then
                s
                tell application &quot;System Events&quot; to key code 39
            else
                delay 1
            end if
        end try
    end repeat
end tell

The problematic line is:
tell process &quot;Chrome&quot; to set VALUE to value of every static text of every sheet of front window

Is there a way to specify something else other than front window while not running into bugs or bringing it to the front? Thanks!
You could specify a different window, e.g. second window; however, it will do you no good to specify a different window as System Events can only send a keystroke or key code to what's frontmost.