(* http://veritrope.com Single Headline or Tab -- NNW to Evernote Version 1.0 October 14th, 2008 Project Status, Latest Updates, and Comments Collected at: http://veritrope.com/tips/netnewswire-to-evernote-single-headline-or-tab-export-applescript                 Some choices inspired by the following scripts/authors:         -- Ernie Soffronoff         -- Daniel N. Byler's DEVONthink script         -- NetNewsWire To Pukka and Yojimbo         -- Jan Erik Mostrom's script         -- David Nunez scripts         -- MANY, MANY OTHERS!                         Installation: Just drop it into the NetNewsWire Script Folder!                  FastScripts Installation (Optional, but recommended): --Download and Install FastScripts from http://www.red-sweater.com/fastscripts/index.html --Copy script or an Alias to ~/Library/Scripts/Applications/NetNewsWire --Set up your keyboard shortcut *) property NNWTitle : "" (* CHECK FOR GROWL *) tell application "System Events"         set processnames to name of every process end tell if "GrowlHelperApp" is in processnames then         tell application "GrowlHelperApp"                 set the allNotificationsList to {"Success Notification", "Failure Notification"}                 set the enabledNotificationsList to {"Success Notification", "Failure Notification"}                 register as application ¬                         "NetNewsWire to Evernote" all notifications allNotificationsList ¬                         default notifications enabledNotificationsList ¬                         icon of application "Evernote"         end tell end if (*MAIN PROGRAM *) tell application "NetNewsWire"         activate         try --IS IT A TAB OR A HEADLINE?                 if (index of selected tab is not 0) then --IT'S A TAB!                         set urlsList to URLs of tabs                         set ixCurrentTab to index of selected tab                         set titleList to titles of tabs                         set defaultTag to (display name of selectedSubscription) --DEFAULT TAG IS SELECTED SUBSCRIPTION NAME/FOLDER                         set userInput to ¬                                 text returned of ¬                                 (display dialog "Enter Tags, separated by colons or commas:" & return & return & ¬                                         "NOTE: Default Tag is selected Subscription/Parent Folder" default answer defaultTag)                         set theDelims to {":", ","}                         set NNWTag to my Tag_List(userInput, theDelims)                         set EVnotebook to my Notebook_List()                         tell application "Evernote" -- CREATE THE NOTE FROM TAB                                 create note from url (item (ixCurrentTab + 1) of urlsList) ¬                                         title (item (ixCurrentTab + 1) of titleList) ¬                                         tags NNWTag ¬                                         notebook EVnotebook                         end tell                                                 if "GrowlHelperApp" is in processnames then -- GROWL SUCCESS                                 tell application "GrowlHelperApp"                                         notify with name ¬                                                 "Success Notification" title ¬                                                 "Import Success" description ¬                                                 "Successfully exported \"" & (item (ixCurrentTab + 1) of titleList) & ¬                                                 "\" to Evernote" application name "NetNewsWire to Evernote"                                 end tell                         end if                 else if exists selectedHeadline then --IT'S A HEADLINE!                         set defaultTag to (display name of selectedSubscription) --DEFAULT TAG IS SELECTED SUBSCRIPTION NAME/FOLDER                         set userInput to ¬                                 text returned of (display dialog "Enter Tags, separated by colons or commas:" & return & return & ¬                                 "NOTE: Default Tag is selected Subscription/Folder" default answer defaultTag)                         set theDelims to {":", ","}                         set NNWTag to my Tag_List(userInput, theDelims)                         set EVnotebook to my Notebook_List()                         set NNWURL to (URL of selectedHeadline)                         set NNWTitle to (title of selectedHeadline)                         set NNWBody to (description of selectedHeadline)                         tell application "Evernote" -- CREATE THE NOTE FROM HEADLINE                                 create note with html NNWBody title NNWTitle notebook EVnotebook tags NNWTag                         end tell                         if "GrowlHelperApp" is in processnames then                                 tell application "GrowlHelperApp" -- GROWL SUCCESS                                         notify with name ¬                                                 "Success Notification" title ¬                                                 "Import Success" description "Successfully exported \"" & NNWTitle & ¬                                                 "\" to Evernote" application name "NetNewsWire to Evernote"                                 end tell                         end if                 else                         if "GrowlHelperApp" is in processnames then                                 tell application "GrowlHelperApp" -- GROWL FAILURE FOR NO SELECTION                                         notify with name ¬                                                 "Failure Notification" title ¬                                                 "Import Failure" description ¬                                                 "No headline or tab selected!" application name "NetNewsWire to Evernote"                                 end tell                         else if "GrowlHelperApp" is not in processnames then -- NON-GROWL ERROR MSG. FOR NO SELECTION                                 display dialog "No headline or tab selected!" with icon 0                         end if                 end if                                 (* ERROR HANDLING *)         on error errText number errNum                 if "GrowlHelperApp" is in processnames then                         tell application "GrowlHelperApp" -- GROWL FAILURE FOR ERROR                                 notify with name ¬                                         "Failure Notification" title ¬                                         "Import Failure" description "Failed to export " & return & NNWTitle & ¬                                         "\"  due to the following error: " & return & errText ¬                                         application name "NetNewsWire to Evernote"                         end tell                 else if "GrowlHelperApp" is not in processnames then -- NON-GROWL ERROR MSG. FOR ERROR                         display dialog "Item Failed to Import: " & errNum & return & errText with icon 0                 end if         end try end tell tell application "NetNewsWire"         activate end tell (* SUBROUTINES *) --TAG SELECTION SUBROUTINE on Tag_List(userInput, theDelims)         set oldDelims to AppleScript's text item delimiters         set theList to {userInput}         repeat with aDelim in theDelims                 set AppleScript's text item delimiters to aDelim                 set newList to {}                 repeat with anItem in theList                         set newList to newList & text items of anItem                 end repeat                 set theList to newList         end repeat         return theList         set AppleScript's text item delimiters to oldDelims end Tag_List --EVERNOTE NOTEBOOK SELECTION SUBROUTINE on Notebook_List()         tell application "Evernote"                 activate                 set listOfNotebooks to {} (*PREPARE TO GET EVERNOTE'S LIST OF NOTEBOOKS *)                                 (*GET THE NOTEBOOK LIST *)                 set EVNotebooks to every notebook                 repeat with currentNotebook in EVNotebooks                         set currentNotebookName to (the name of currentNotebook)                         copy currentNotebookName to the end of listOfNotebooks                 end repeat                                 (*SORT THE LIST *)                 set Folders_sorted to my simple_sort(listOfNotebooks)                                 (*USER SELECTION FROM NOTEBOOK LIST *)                 set SelNotebook to choose from list of Folders_sorted with title "Select Evernote Notebook" with prompt ¬                         "Current Evernote Notebooks" OK button name "OK" cancel button name "New Notebook"                                 if (SelNotebook is false) then (*CREATE NEW NOTEBOOK OPTION *)                         set userInput to ¬                                 text returned of (display dialog "Enter New Notebook Name:" default answer "")                         set EVnotebook to userInput                 else                         set EVnotebook to item 1 of SelNotebook                 end if                         end tell end Notebook_List --SORT SUBROUTINE on simple_sort(my_list)         set the index_list to {}         set the sorted_list to {}         repeat (the number of items in my_list) times                 set the low_item to ""                 repeat with i from 1 to (number of items in my_list)                         if i is not in the index_list then                                 set this_item to item i of my_list as text                                 if the low_item is "" then                                         set the low_item to this_item                                         set the low_item_index to i                                 else if this_item comes before the low_item then                                         set the low_item to this_item                                         set the low_item_index to i                                 end if                         end if                 end repeat                 set the end of sorted_list to the low_item                 set the end of the index_list to the low_item_index         end repeat         return the sorted_list end simple_sort