Applescript代码凌乱,如何修复

时间:2016-02-10 04:05:57

标签: applescript

display dialog "Play Nillys Realm?" buttons {"Yes please", "No"} default button 1

if result = {button returned: "Yes please"} then
  display dialog "Long time loading, u think?" buttons {"Yes", "No"} 
end if

if result = {button returned:"No"} then
  tell application "Google Chrome"
    repeat 5 times
        open location "http://test.nillysrealm.com"
        activate
    end repeat


    if result = {button returned:"Yes"} then
      tell application "Google Chrome"
        repeat 10 times
          open location "http://test.nillysrealm.com"
          activate
        end repeat

这就是我的代码,它是一个MESS。任何人都可以帮我解决?永远不会加载

1 个答案:

答案 0 :(得分:0)

在您的脚本中提供帮助并不容易,因为阅读它,我不明白您想要做什么。但是,您没有使用'结果'变量正确。此变量始终包含最后一个对话框的结果,因此当您有2个对话框时,对该变量的任何测试将始终为您提供第二个对话框的结果,而不是第一个对话框的结果。

解决方案是将结果专门分配给单独的变量,例如下面的示例:

set Dialog1 to display dialog "do you agree ?" buttons {"Yes please", "No"} default button 1
if button returned of Dialog1 is "Yes please" then
-- do something here when user click "yes please"
else
-- do somthing here when user click "No"
end if