Finder收到错误:无法获取Finder窗口ID 12575返回的按钮

时间:2014-05-07 14:16:31

标签: macos applescript

我一直在研究的AppleScript应用程序给出了错误“Finder收到错误:Finder窗口ID 12575无法返回按钮”。每当我尝试从我的应用程序打开一个查找器窗口时,就会发生这种情况。以下是发生此错误的应用程序的主要部分:

display dialog "What would you like to do? Sleep = Go to sleep Finder = Open Finder Time = Display current time and date 2048 = Play 2048 Quit = Quit application" default answer "" with title "Control panel" if the text returned of the result is "Sleep" then tell application "System Events" to sleep display dialog "Hello, welcome back!" buttons {"Thank you!"} default button 1 return else if the text returned of the result is "Finder" then tell application "Finder" to make new Finder window else if the text returned of the result is "Time" then set a to (current date) as list set AppleScript's text item delimiters to linefeed set a to a as text display dialog a buttons {"OK"} default button 1 else if the text returned of the result is "Quit" then return else if the text returned of the result is "2048" then tell application "Terminal" do script "/Users/student/Documents/2048.sh" activate end tell return else display dialog "Invalid response" with title "Invalid response" buttons {"Go back", "Quit"} default button 1 end if if the button returned of the result is "Go back" then display dialog "What would you like to do? Sleep = Go to sleep Finder = Open Finder Time = Display current time and date 2048 = Play 2048 Quit = Quit application" default answer "" with title "Control panel" else return end if if the text returned of the result is "Sleep" then tell application "System Events" to sleep display dialog "Hello, welcome back!" buttons {"Thank you!"} default button 1 return else if the text returned of the result is "Finder" then tell application "Finder" to make new Finder window return else if the text returned of the result is "Time" then set a to (current date) as list set AppleScript's text item delimiters to linefeed set a to a as text display dialog a buttons {"OK"} default button 1 else if the text returned of the result is "Quit" then return else if the text returned of the result is "2048" then tell application "Terminal" do script "/Users/student/Documents/2048.sh" activate end tell return end if

1 个答案:

答案 0 :(得分:1)

来自ASLG的报价:

  

“执行语句时,AppleScript将结果值(如果有)存储在预定义的属性结果中。值保持不变,直到执行另一个生成值的语句。在执行生成结果的语句之前,结果的值是未定义的。您可以通过查看脚本窗口的“结果”窗格来检查“脚本编辑器”中的结果。“

结果属性由前一个已执行的语句错误地设置tell application "Finder" to make new finder window我建议您(任何脚本编写者)是当您希望语句的结果稍后在代码中使用而不是下一行时应该使用变量。这里和示例如何使用变量。

set dialogResult to display dialog "What would you like to do?" default answer "Continue"

if button returned of dialogResult is not "OK" then
    return false
end if

if text returned of dialogResult is not "Continue" then
    return false
end if

return true
相关问题