Applescript - 如何从内部访问顶级处理函数告诉应用程序
Applescript - how to access top level handler function from inside tell Application
我正在尝试编写一个自定义的 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()
.
如何修复此错误?
这是一个很常见的错误。
To call a handler from within a tell
statement, you must use the reserved words of me
or my
to indicate that the handler is part of the script and not a command that should be sent to the target of the tell
statement.
my processCheck()
我正在尝试编写一个自定义的 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()
.
如何修复此错误?
这是一个很常见的错误。
To call a handler from within a
tell
statement, you must use the reserved wordsof me
ormy
to indicate that the handler is part of the script and not a command that should be sent to the target of thetell
statement.
my processCheck()