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

发布于 2024-11-05 05:08:38 字数 544 浏览 0 评论 0原文

每次运行此脚本时,我都会收到此错误:系统事件收到错误:“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

我尝试

my notify of "Test123" thru "Test"

用以下内容替换,但没有成功:

notify of "Test123" thru "Test" of me
(notify of "Test123" thru "Test") of me

I get this error everytime i run this script: System Events got an error: "Test123" doesn’t understand the notify message.

Code:

--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

I have tried to replace

my notify of "Test123" thru "Test"

with the following, without any success:

notify of "Test123" thru "Test" of me
(notify of "Test123" thru "Test") of me

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一个人的旅程 2024-11-12 05:08:38

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

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

not exactly sure what your trying to do but here is an example of how to call a function and pass parameter

tell application "System Events"
    set m to "message content"
    my notify(m)
end tell
--more code...
on notify(message)
    display dialog (message)
end notify
[浮城] 2024-11-12 05:08:38

尝试一下:

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

虽然我也会说我从不使用 AppleScript 处理程序的直接参数语法,但更喜欢位置参数(即 notify( message, level )),因为它避免了不明确的语法给您带来麻烦发现了。

Try this:

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

Although I'll also say that I never use the direct parameter syntax for AppleScript handlers, preferring positional parameters (i.e., notify( message, level )), as it avoids the ambiguous syntax troubles you discovered.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文