2012-12-15 19 views
5

मैं एक मेल प्लगइन बनाने है और बगल में "भेजें" बाहर जाने वाले मेल के बटन "बटन" जोड़ने के भीतर AppleScript निष्पादित करने के लिए,"मेल" आवेदन

enter image description here

में सक्षम नहीं है और अब मैं बाहर जाने वाले भेजना चाहते हैं भी मेरी बटन से मेल और मैं भी 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 

यह स्क्रिप्ट Apple स्क्रिप्ट संपादक में काम कर रहा है, लेकिन मेरे बटन पर क्लिक करें से काम नहीं लिख

मैं भी तरह

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

Xcode में applescript पर अमल किया है और बाद स्क्रिप्ट मैं त्रुटि हो रही है निष्पादित करें: -

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}"; 

तो मैं कोशिश की है सब बात लेकिन सफलता नहीं मिलता है।

तो कृपया मुझे करने में मदद इस समस्या बाहर

कोई सुझाव या मदद के लिए धन्यवाद।

उत्तर

4

उस मेनू आइटम में कीबोर्ड शॉर्टकट होता है, इसलिए आप इसका भी उपयोग कर सकते हैं। क्या आपने यह कोशिश की?

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