AppleScript:在tell语句中调用处理程序

Tyi*_*ilo 6 applescript handler tell

每次运行此脚本时都会出现此错误:系统事件出错:"Test123"无法理解通知消息.

码:

--more code...
tell application "System Events"
    if some_system_events_property then
         my notify of "Test123" thru "Test"
    end if
end tell
--more code...
to notify of message thru level
    display dialog message with titel level
end notify
Run Code Online (Sandbox Code Playgroud)

我试图替换

my notify of "Test123" thru "Test"
Run Code Online (Sandbox Code Playgroud)

以下,没有任何成功:

notify of "Test123" thru "Test" of me
(notify of "Test123" thru "Test") of me
Run Code Online (Sandbox Code Playgroud)

mcg*_*ilm 5

不确定您要做什么,但这是如何调用函数并传递参数的示例

tell application "System Events"
    set m to "message content"
    my notify(m)
end tell
--more code...
on notify(message)
    display dialog (message)
end notify
Run Code Online (Sandbox Code Playgroud)


Chu*_*uck 4

尝试这个:

tell application "System Events"
    if some_system_events_property then
        tell me to notify of "Test123" thru "Test"
    end if
end tell

to notify of message thru level
    display dialog message with title level
end notify
Run Code Online (Sandbox Code Playgroud)

尽管我也会说我从不使用 AppleScript 处理程序的直接参数语法,而是更喜欢位置参数(即notify( message, level )),因为它避免了您发现的不明确的语法问题。