¿Hay alguna forma en AppleScript de usar "X de cada" para obtener múltiples propiedades de cada objeto para crear un registro?

Es posible con el script:

tell application "Safari"
    set urls to URL of every tab of every window
end tell

cuando se ejecuta, obtiene todas las URL de cada pestaña de cada ventana (lista bidimensional)

Result:
 {{"http://domain1", "http://domain2", ...}, {"http://domain3", "http://domain4", ...}, {...}}

Pero es posible con:

tell application "Safari"
    set (urls & name) to URL of every tab of every window
end tell

para obtener un registro en lugar de una lista:

Result:
 {{{url: "http://domain1", name: "domain1 - foo"}, {url: "http://domain2", name: "domain2 - bar2"}, {...}}, {{url: "http://domain3", name: "domain3 - foo3"}, {url: "http://domain4", name: "domain4 - bar4"}, {...}}}

¿Es posible o debo usar solo repeat?

Respuestas (1)

No es posible obtener un registro con un solo especificador de objeto, pero puede obtener una lista:

tell application "Safari"
    {URL, name} of tabs of windows
end tell
-- {{{"http://url1", "title 1"}, {"http://url2", "title 2"}}}

Para un registro, puede usar un bucle de repetición:

set r to {}
tell application "Safari"
    repeat with t in tabs of windows
        set end of r to {|url|:URL of t, |name|:name of t}
    end repeat
end tell
r
-- {{|url|:"http://url1", |name|:"title 1"}, {|url|:"http://url2", |name|:"title 2"}}
¡excelente! ¿ Es posible obtener todo esto con {|safari|: {{|window_1|: {|url|: "http://url1", |name|: "title 1"}, {|url|:"http://url2", |name|:"title 2"}},{|window_2|: {|url|: "http://url3", |name|: "title 3"}, {|url|:"http://url4", |name|:"title 4"}}}}? ¿Para poder convertir el registro a json (por ejemplo, con JSON Helper) y aún tener una estructura de ventanas de safari? Escribí un script para todo eso para obtener una cadena (no basada en registros/listas, lo que me gustaría tener), y tiene aproximadamente 200 líneas de código con 3 subrutinas y se ve feo incluso para mí.
Si lo pruebo: {|safari|: {|window1|: {{|url1|: "http1", |name1|: "title1"},{|url2|: "http2", |name2|: "title2"},{|url3|: "http3", |name3|: "title3"}}}} & {|safari|: {|window2|: {{|url1|: "http1", |name1|: "title1"},{|url2|: "http2", |name2|: "title2"},{|url3|: "http3", |name3|: "title3"}}}}solo devuelve: {safari:{window1:{{url1:"http1", name1:"title1"}, {url2:"http2", name2:"title2"}, {url3:"http3", name3:"title3"}}}}y no la variante fusionada, donde hay una lista dewindows
Los corchetes dobles (por ejemplo, lista): {|safari|: -->{{<-- |window1|: ...no hace ningún cambio
Perdón por tantos comentarios fuera de tema, pero casi me resolví esto: ¿cómo configurar la clave del registro en el tiempo de ejecución? entonces set end of w_l to {|window & "_" & window_i :t_l}?