Love MarsEdit - Newbie to AppleScript
  • Hi,

    I've been using ME for several months now, previously I've bee using quickeys to automate some functions. But I'm looking at learning applescript to streamline things, make them faster, and let them run in the background.

    Is there a document with all the Possible variables/fields in MarsEdit ?

    I'm also looking for a good reference to get some actual basic Applescript knowledge.

    My first task is to create a script that automatically fills out tags and puts some lines in the post.

    Thank you
    -Sam
  • Daniel JalkutDaniel Jalkut
    Accepted Answer
    Hi Sam - unfortunately I don't have a comprehensive document for scripting MarsEdit. Mostly it's a trial and error process and poking around at the app's scripting dictionary from AppleScript Editor.

    For a general AppleScript guidebook one of the classics is Matt Neuberg's book:

    http://shop.oreilly.com/product/9780596102111.do

    As for your immediate interest, this should get you started:

    tell application \"MarsEdit\"
    activate

    make new document
    set title of document 1 to \"My new post...\"
    set tags of document 1 to \"Tag1, Tag2, Tag3\"
    set body of document 1 to \"Hello there, this is my new blog post!\"
    end tell


    (Sorry about the backslashes before the quotes - my forum software is adding those. You'll want to delete those in AppleScript editor).
  • Awesome Daniel,

    Thanks for the link, example and super quick reply. I'll keep tinkering!

    -Sam

    PS - everytime I come to the forum is tells me I need to confirm my email address, which I've done at least twice.
  • Daniel JalkutDaniel Jalkut
    Accepted Answer
    Hi Sam - glad to help. Thanks for the note about the verified email address. I'll look into this!
  • Hey Daniel,

    Is there an easy way to figure out what the variables for certain fields in MarsEdit are called?

    I'm looking for the 'Post Status' and 'blog title' fields right now, but I'm sure the more I figure out the more I'm going to try to write Apple scripts to play with :D

    Thanks again!
    -Sam
  • (thought I had it... i didn't)
  • Hi Sam - if you haven't already discovered AppleScript Editor's "Dictionary Browser" feature, be sure to check it out. This is generally how you find the names of the various fields that you can access by scripting. From AppleScript Editor select File -> Open Dictionary and then select MarsEdit.

    When you say blog title do you mean the name of the whole blog, or just the title of a given post? Here are some examples:

    tell app \"MarsEdit\" to set published status of document 1 to \"Draft\"


    tell app \"MarsEdit\" to get name of current blog of document 1

  • OMG - I did not know about the Dictionary. That's exactly what I've been looking for, thank you!

    And yea I was talking about the blog's title itself not the post entry. Thanks for the examples, I was actually able to come up with the same string from the dictionary! Yay learning!

    Hopefully the next time I return will be with a few scripts to share.

  • Glad to help! Let us know how things go.
  • One more MarsEdit Applescript question.

    I'm calling up the Upload Utility

    is there a way to have applescript click the 'Choose File' button?

    This is what I've tried so far

    tell application "System Events"
    tell process "MarsEdit"
    click button "Choose File..." of window of window 1
    end tell
    end tell

    also

    click button 2 of window of window 1

    Thanks!
  • Daniel JalkutDaniel Jalkut
    Accepted Answer
    Hi there - it looks like you might have to specify the title of the button with the special ellipsis character (…) instead of the three dots:

    tell application "System Events" to tell application process "MarsEdit"
    click button "Choose File…" of window "Upload Utility"
    end tell

    And just as an illustration of another trick, you can sometimes locate buttons with AppleScript's accessibility support using substrings:

    tell application "System Events" to tell application process "MarsEdit"
    click (first button of window "Upload Utility" whose title starts with "Choose")
    end tell
Start a New Discussion

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!