2012-03-02 38 views
0

我刚开始使用苹果脚本,我想制作一个提示用户输入URL的应用程序。在此之后,应用程序会在Safari的新选项卡中打开给定的URL。这是我的,但它不工作。想要在Safari的新选项卡中打开用户生成的URL

tell me 
     activate 
     set s to display dialog "Which website do you want to open?" default answer "https://www." 
    end tell 
    tell application "System Events" 
     tell application "Safari" to activate 
     tell process "Safari" 
      click menu item "New Tab" of menu "File" of menu bar 1 
     end tell 
    end tell 

    tell application "Safari" 
     set URL of document 1 to "text returned of s" 
    end tell 

回答

1

通过封闭“文本返回S的”引号,你已经是一个字符串,而不是你想要使用记录属性 - 去掉引号将使其工作。您不必脚本化用户界面以制作标签,但该命令位于Safari的脚本字典中,例如:

tell me to activate 
set s to text returned of (display dialog "Which website do you want to open?" default answer "https://www.") 
tell application "Safari" 
    activate 
    tell window 1 
     set current tab to (make new tab) 
     set URL of current tab to s 
    end tell 
end tell 
相关问题