【问题标题】:Not able to Execute AppleScript within "Mail" application无法在“邮件”应用程序中执行 AppleScript
【发布时间】:2012-12-03 03:28:10
【问题描述】:

我已经创建了一个邮件插件,并在外发邮件的“发送”按钮旁边添加了“按钮”,

现在我也想从我的 Button 发送外发邮件,我也为此编写了 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

此脚本在 Applescript 编辑器中运行,但无法通过我的按钮单击运行

我也在 Xcode 中执行了 applescript,比如

NSURL* url = [NSURL fileURLWithPath:path];
NSDictionary* errors = [NSDictionary dictionary];    
NSAppleScript* appleScript = [[NSAppleScript alloc] initWithContentsOfURL:url error:&errors];
[appleScript executeAndReturnError:&errors];

执行脚本后出现错误:-

NSAppleScriptErrorAppName = "System Events";
NSAppleScriptErrorBriefMessage = "Can't get menu bar 1 of application process \"Mail\". Invalid index.";
NSAppleScriptErrorMessage = "System Events got an error: Can't get menu bar 1 of application process \"Mail\". Invalid index.";
NSAppleScriptErrorNumber = "-1719";
NSAppleScriptErrorRange = "NSRange: {0, 0}";

所以我已经尝试了所有的东西但没有成功。

所以请帮我解决这个问题

感谢您的任何建议或帮助。

【问题讨论】:

    标签: xcode macos plugins applescript apple-mail


    【解决方案1】:

    那个菜单项确实有一个键盘快捷键,所以你也可以使用它。你试过了吗?

    activate application "Mail"
    tell application "System Events"
        tell application process "Mail"
            keystroke "d" using {command down, shift down}
        end tell
    end tell
    

    【讨论】:

      猜你喜欢
      • 2013-05-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-27
      • 1970-01-01
      • 1970-01-01
      • 2012-07-02
      • 1970-01-01
      相关资源
      最近更新 更多