AppleScript

How to Shoot Yourself in the Foot in Any Programming Language

June 27th, 2007  |  Published in AppleScript, Code Development, Developer, JAVA, JavaScript/AJAX, PHP, RealBASIC, Unix

How to Shoot Yourself in the Foot in Any Programming Language:

fullduplex.org » How to Shoot Yourself in the Foot in Any Programming Language The proliferation of modern programming languages (all of which seem to have stolen countless features from one another) sometimes makes it difficult to remember what language you’re currently using. This guide is offered as a public service to help programmers who [...]

Oh man so true so true

(Via Mind-NOX.)

System-Wide iPhoto Browser

May 3rd, 2006  |  Published in AppleScript, Tools I Use

System-Wide iPhoto Browser:

Great tip from MacOSXHints.com — a simple Automator action lets you access a browser for your iPhoto photos, without having to launch iPhoto itself. I’ve added this to my Scripts menu. (Via Michael Tsai.)

This is a slick trick and works for iTunes too

(Via Daring Fireball Linked List.)

tow.com » blog » Aperture Scripting

December 7th, 2005  |  Published in AppleScript, Photography

tow.com » blog » Aperture Scripting:

[He] is writing an AppleScript that transfers annotations from my iView catalogs into Aperture image versions. My file structure for my annotated RAW images has been well-documented, and it will make writing this script relatively straightforward — if anything in AppleScript can be straightforward! A tricky part was mapping iView’s annotation field names

Will be interesting to see what dirvers people use with aperture…

(Via .)

AppleScript Resources

October 15th, 2004  |  Published in AppleScript

AppleScript Resources:

Download these AppleScript Reference Guides and sample scripts for Microsoft Office 2004. Check back frequently to access new AppleScript guides and sample scripts. Microsoft Office 2004 AppleScript Reference guides provide documentation of the AppleScript dictionaries for Office 2004 programs. Learn how to use the classes and commands to create your own scripts.

(Via Studio Log.)

NetNewsWire 2 to Tasks Script

October 12th, 2004  |  Published in AppleScript

NetNewsWire 2 to Tasks Script:

I’ve made an updated version of my NetNewsWire to Tasks scripts available. This version works with the new tabbed browsing feature in NetNewsWire 2. If a browser tab is the current tab, it uses that URL and page title, otherwise it uses the selected news item as it did previously.

NetNewsWire to Tasks AppleScripts (nnw2_to_tasks.zip 10kB)

Kewl Alex, adding to my menu, I have some ideas to speed these up a little bit

(Via alexking.org: Blog.)

Sample AppleScript Test

June 29th, 2004  |  Published in AppleScript

<

div class=’codeblock’> Open this script in a new Script Editor window.

change this to be the base path of your tasks site

property kUrlToTasks : "http://tasks.samdevore.com/"
property kDefaultTasksID : 27


on encode_text(this_text)
    set the acceptable_characters to "abcdefghijklmnopqrstuvwxyz0123456789_"
    set the encoded_text to ""
    set the character_list to {}
    repeat with this_char in this_text
        set this_char to the contents of this_char
        if this_char is in the acceptable_characters then
            set the end of the character_list to this_char
        else
            set the end of the character_list to encode_char(this_char)
        end if
    end repeat
    return (the character_list) as string
end encode_text

this sub-routine is used to encode a character
on encode_char(this_char)
    set the ASCII_num to (the ASCII number this_char)
    set the hex_list to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
    set x to item ((ASCII_num div 16) + 1) of the hex_list
    set y to item ((ASCII_num mod 16) + 1) of the hex_list
    return ("%" & x & y) as string
end encode_char

on addToTask(theTitle, theUrl, theID)
    set theLocation to kUrlToTasks & "index.php?screen=edit&id=" & theID & "&task_notes_append="
    set theLocation to theLocation & encode_text("<li><a href=\"" & theUrl & "\" rel=\"external\">" & theTitle & "</a></li>")
    tell application "System Events"
        open location theLocation
    end tell
end addToTask

tell application "NetNewsWire"
    set theTitle to title of selectedHeadline
    set theUrl to URL of selectedHeadline
    tell application "Safari"
        set this_URL to the URL of document 1
    end tell
    – default id to append to
    set idNumber to kDefaultTasksID
    set AppleScript’s text item delimiters to "?"
    set the item_list to every text item of this_URL
    set AppleScript’s text item delimiters to ""
    if item 1 of item_list contains kUrlToTasks then
        set params to item 2 of item_list
        set AppleScript’s text item delimiters to "&"
        set the param_list to every text item of this_URL
        set AppleScript’s text item delimiters to ""
        repeat with param in param_list
            if param contains "id" then
                set AppleScript’s text item delimiters to "="
                set idNumber to text item 2 of param
                set AppleScript’s text item delimiters to ""
            end if
        end repeat
        –else
        –    display dialog "Not your tasks page in Safari" & item 1 of item_list
    end if
    
    my addToTask(theTitle, theUrl, idNumber)
end tell

A script for Tasks

June 21st, 2004  |  Published in AppleScript, Code Development, Tools I Use

This is a sample script to create an entry in Tasks.

This script will take the current message that you are reading in mail.app and open a window in Safari with the tasks new new task screen, the subject of the mail message is the title of the task and the body of the email is the description of the task.

<div class="codeblock"><!-- AppleScript Formatting Start -->

Open this script in a new Script Editor window.

change this to be the base path of your tasks site

property kUrlToTasks : "http://tasks.samdevore.com/"


on encodeText(thisText)
    set the acceptableCharacters to "abcdefghijklmnopqrstuvwxyz0123456789"
    set the encodedText to ""
    set the characterList to {}
    repeat with thisChar in thisText
        set thisChar to the contents of thisChar
        if thisChar is in the acceptableCharacters then
            set the end of the characterList to thisChar
        else
            set the end of the characterList to encodeChar(thisChar)
        end if
    end repeat
    return (the characterList) as string
end encodeText

this sub-routine is used to encode a character
on encodeChar(thisChar)
    set the ASCIINum to (the ASCII number thisChar)
    set the hexList to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
    set x to item ((ASCIINum div 16) + 1) of the hexList
    set y to item ((ASCIINum mod 16) + 1) of the hexList
    return ("%" & x & y) as string
end encodeChar
using terms from application "Mail"
    on perform mail action with messages theSelectedMessages
        tell application "Mail"
            if (count of theSelectedMessages) is equal to 0 then
                display dialog "Please select a message in Mail first, then run this script again."
            else if (count of theSelectedMessages) is equal to 1 then
                set eachMessage to item 1 of theSelectedMessages
                set theSource to content of eachMessage
                set theSubject to subject of eachMessage
                my createMessageWithSource(theSource, theSubject)
            else
                display dialog "Please select only one message in Mail first, then run this script again."
            end if
        end tell
    end perform mail action with messages
end using terms from

on createMessageWithSource(theSource, theSubject)
    set theUrl to kUrlToTasks & "index.php?screen=edit&taskNotes="
    
    set theUrl to theUrl & encodeText(theSource)
    set theUrl to theUrl & "&taskTitle=" & encodeText(theSubject)
    tell application "System Events"
        open location theUrl
    end tell
    
    
end createMessageWithSource

This combines really well with AppleScript keyboard shortcuts in mail.app

download