【发布时间】:2018-07-15 17:21:36
【问题描述】:
我正在尝试编写一个自定义 Apple 脚本来打开一个应用程序 (Slack),并在继续之前运行检查以确保它已完全加载。我目前收到一个错误:
Slack got an error: Can’t continue processCheck. -1708
1708 是错误:The script doesn’t understand the <message> message. The event was not handled.
这是我的代码:
tell application "Slack" to activate
global is_loaded
set is_loaded to false
processCheck()
on processCheck()
tell application "System Events" to get name of every process
if the result contains "Slack" then
log "running"
tell application "Slack"
if (count of windows) > 0 then
set window_name to name of front window
log window_name
#when window_name is just Slack, it should mean Slack is still loading
if window_name is equal to "Slack" then
log "loading"
delay 0.5
if is_loaded is equal to false then
processCheck()
end if
else
is_loaded = true
#if it is something else, it should mean Slack has loaded the user's default workspace
log "loaded"
end if
end if
end tell
else
log "not running"
delay 5
processCheck()
end if
end processCheck
我认为正在发生的事情是我的脚本认为我试图告诉 Slack 运行函数 processCheck(),但实际上我只是试图告诉我的苹果脚本运行 processCheck()。
如何解决这个错误?
【问题讨论】:
标签: macos scripting applescript handler