¿Cómo se abre una nueva ventana en Safari y luego se abren varias pestañas con diferentes URL en esa ventana usando Apple Script?¿Cómo abrir una nueva ventana y varias URL en Safari con Apple Script?
Respuesta
La manera de crear una nueva ventana de Safari es utilizar el comando make new document
:
make new document at end of documents with properties {URL:the_url}
Esto creará una nueva ventana con una sola pestaña que apunta a the_url
y hacer que la ventana del primer plano. Tenga en cuenta que make new window at end of windows
no funciona, y solo errores con "AppleEvent manejador falla".
Del mismo modo, para crear una nueva pestaña dentro de una ventana w
, puede utilizar make new tab
:
make new tab at end of tabs of w with properties {URL:the_url}
Esto creará una nueva pestaña en la ventana w
al final de la lista de pestañas; esta pestaña apuntará a the_url
, y no será la pestaña actual. En lugar de decir explícitamente tabs of w
, también se puede utilizar un bloque tell w
:
tell w
make new tab at end of tabs with properties {URL:the_url}
end tell
De esa manera, tabs
se refiere implícitamente a tabs of w
.
Poniendo todo esto junto, obtenemos el siguiente script. Dada una lista de URL en the_urls
, las abrirá todas en una nueva ventana; si the_urls
está vacío, abre una ventana con una pestaña en blanco.
property the_urls : {¬
"http://stackoverflow.com", ¬
"http://tex.stackexchange.com", ¬
"http://apple.stackexchange.com"}
tell application "Safari"
if the_urls = {} then
-- If you don't want to open a new window for an empty list, replace the
-- following line with just "return"
set {first_url, rest_urls} to {"", {}}
else
-- `item 1 of ...` gets the first item of a list, `rest of ...` gets
-- everything after the first item of a list. We treat the two
-- differently because the first item must be placed in a new window, but
-- everything else must be placed in a new tab.
set {first_url, rest_urls} to {item 1 of the_urls, rest of the_urls}
end if
make new document at end of documents with properties {URL:first_url}
tell window 1
repeat with the_url in rest_urls
make new tab at end of tabs with properties {URL:the_url}
end repeat
end tell
end tell
tell application "Safari"
activate
set the URL of document 1 to "http://www.XXXXXXX.com"
my new_tab()
set the URL of document 1 to "http://www.XXXXXX.com"
end tell
on new_tab()
tell application "Safari" to activate
tell application "System Events"
tell process "Safari"
«event prcsclic» «class menI» "New Tab" of «class menE» "File" of «class mbar» 1
end tell
end tell
end new_tab
Reemplazar las X con lo sitios que desee y seguir repitiendo el código (mi new_tab() y establecer la dirección URL ... líneas) para cada página que le gustaría tener abierta. Refiriéndonos a this page. Corrígeme si esto no es de lo que estabas hablando.
Gracias por la respuesta, Pugmatt. Está cerca de lo que quiero. Su secuencia de comandos abre la url en una ventana existente de Safari; deseo abrirla en una nueva ventana. – sevens
Base en la respuesta de Pugmatt me dio la siguiente para trabajar ...
on run {input, parameters}
tell application "Safari"
activate
make new document with properties {URL:"http://www.apple.com"}
my new_tab()
set the URL of document 1 to "http://www.example.com"
end tell
end run
on new_tab()
tell application "Safari" to activate
tell application "System Events"
tell process "Safari"
«event prcsclic» «class menI» "New Tab" of «class menE» "File" of «class mbar» 1
end tell
end tell
end new_tab
No estoy seguro de si este es el modo más eficiente de esto.
- 1. ¿Imprime una página web solo con url y sin abrir una nueva ventana?
- 2. enlace URL informe Abrir en una nueva ventana en blanco
- 3. abrir una nueva ventana en a4j: commandButton
- 4. Eclipse: Abrir en una nueva ventana
- 5. Abrir página en una nueva ventana sin ventana emergente
- 6. Abrir el enlace en una nueva ventana con Jquery
- 7. Abrir la imagen en una nueva ventana
- 8. ¿Cómo abrir una nueva ventana e insertar html usando jQuery?
- 9. Abrir respuesta en una nueva ventana
- 10. ¿Cómo puedo abrir un enlace en una nueva ventana?
- 11. Abrir una nueva ventana en silverlight
- 12. ¿Abrir el botón en una ventana nueva?
- 13. Google Apps Script para abrir una URL
- 14. Android WebView Ventana nueva URL
- 15. Cómo abrir una nueva ventana en el formulario enviar
- 16. ¿Cómo abrir una nueva ventana en Windows Forms en .NET?
- 17. Cómo abrir una nueva ventana en el modo independiente de iphone (pantalla completa)
- 18. Abrir el enlace en una nueva ventana con Capybara
- 19. html abrir una url en el nuevo objetivo y foco
- 20. ¿Cómo hago link_to para abrir URL externas en una nueva ventana?
- 21. Cómo abrir en una ventana nueva usando el control WebBrowser?
- 22. Abrir una nueva ventana del navegador con una nueva ID de sesión en ASP.NET
- 23. Ruby/Rails - Abrir una URL desde el controlador en una nueva ventana
- 24. ¿Abrir una nueva pestaña/ventana y escribirle algo?
- 25. cómo abrir la URL en una nueva pestaña de django?
- 26. Bookmarklet En ventana nueva
- 27. Mediawiki abrir enlaces externos en una nueva ventana
- 28. Crear un botón de tweet sin abrir una nueva ventana
- 29. Cómo abrir una nueva ventana usando MVVM Light Toolkit
- 30. Convertir lienzo a imagen y abrir en una nueva ventana usando ruby on rails y javascript
gracias por la explicación adicional, Antal. ¡Funciona! – sevens