Applescript:从显示对话框打开新的Safari选项卡

Applescript:从显示对话框打开新的Safari选项卡,applescript,Applescript,我想从带有动态URL的显示对话框中打开Safari上的新选项卡 基本上,只有URL的最后一个数字在变化,结尾必须来自用户 ## dialogue box## set theResponse to display dialog "Show me the ID" default answer "" with icon note buttons {"Cancel", "Continue"} default button "Continue" ## Open URL## set myURL to "

我想从带有动态URL的显示对话框中打开Safari上的新选项卡

基本上,只有URL的最后一个数字在变化,结尾必须来自用户

## dialogue box##
set theResponse to display dialog "Show me the ID" default answer "" with icon note buttons {"Cancel", "Continue"} default button "Continue"

## Open URL##

set myURL to "https://myURL/"
on open location myURL
    set URL to myURL & theResponse
    tell application "Safari" to open URL
end open location
该框工作正常,我在脚本编辑器中看到,结果已被考虑在内:

tell application "Script Editor"
    display dialog "Show me the ID" default answer "" with icon note buttons {"Cancel", "Continue"} default button "Continue"
        {button returned:"Continue", text returned:"123456"}

我只是不知道如何打开来自两个不同来源的URL,以及我应该使用什么格式,如果只有几个URL,您可以使用按钮,例如“{”取消“,”继续使用X“,”继续使用Y“},并根据按钮和返回的文本使用不同的URL

on run
    set response to (display dialog "Show me the ID" default answer "" with icon note buttons {"Cancel", "Continue with X", "Continue with Y"} default button "Continue with Y")
    if button returned of response is "Continue with X" then
        set baseURL to "https://URLx/"
    else -- Continue with Y
        set baseURL to "https://URLy/"
    end if
    openNewTab(baseURL & text returned of response)
end run

on openNewTab(myURL)
    tell application "Safari"
        activate
        tell window 1 to set current tab to (make new tab with properties {URL:myURL})
    end tell
end openNewTab

非常感谢你!这正是我需要的。我修改了代码,一次点击就可以打开3个标签,这就完成了。