相关疑难解决方法(0)

无法在"Mail"应用程序中执行AppleScript

我创建了一个邮件插件,并在外发邮件的"发送"按钮旁添加"按钮",

在此输入图像描述

现在我想从我的按钮发送传出的邮件,我也写了这样的AppleScript

activate application "Mail"
tell application "System Events"
    tell application process "Mail"
        log "foo"
        tell menu bar 1
            tell menu bar item "Message"
                tell menu "Message"
                    click menu item "Send"
                end tell
            end tell
        end tell
    end tell
end tell
Run Code Online (Sandbox Code Playgroud)

这个脚本在Applescript编辑器中工作,但不是从我的按钮点击工作

我也在Xcode中执行applescript

NSURL* url = [NSURL fileURLWithPath:path];
NSDictionary* errors = [NSDictionary dictionary];    
NSAppleScript* appleScript = [[NSAppleScript alloc] initWithContentsOfURL:url error:&errors];
[appleScript executeAndReturnError:&errors];
Run Code Online (Sandbox Code Playgroud)

执行脚本后我得到错误: -

NSAppleScriptErrorAppName = "System Events";
NSAppleScriptErrorBriefMessage = "Can't get menu bar 1 of application process \"Mail\". Invalid …
Run Code Online (Sandbox Code Playgroud)

macos xcode plugins applescript apple-mail

5
推荐指数
1
解决办法
720
查看次数

标签 统计

apple-mail ×1

applescript ×1

macos ×1

plugins ×1

xcode ×1