Grab the "Active" Window in Applescript I have a script which perform the following:


Load a file into a program (Subler — done separately, not in this script)
Confirm the loading of the file (this is where the script begins)
Saves the file
In the save location window it selects a specific directory to save the file in
Presses "return"


I would like to know how to perform step 4 with the active (or last used) window instead of a specific window title.

This is the relevant code:

get every action of list 1 of scroll area 1 of scroll area 1 of browser 1 of splitter group 1 of group 2 of sheet 1 of window "untitled"


This is the entire code:

on run 

    tell application "Subler" to activate
    delay 1

    tell application "System Events"
        delay 0.5
        keystroke return
        delay 1
        keystroke "s" using command down
    end tell

    activate application "Subler"
    tell application "System Events"
        tell process "Subler"
            get every action of list 1 of scroll area 1 of scroll area 1 of browser 1 of splitter group 1 of group 2 of sheet 1 of window "untitled"
        end tell

    end tell

    tell application "Subler" to activate
    delay 1

    tell application "System Events"
    end tell

    return input
end run
It's been a while since I played with Applescript, but I think it's just 'window 1' [without quotes] for the frontmost window.