Jump to content
etm117

mac Applescript to create note does not work after 3.3.0 upgrade

Recommended Posts

I have Evernote installed through the App Store. I upgraded to 3.3.0 this week. Afterwards, I can no longer create notes using Applescripts. I am running ML 10.8 and this was working the other day in ML before upgrading to 3.3.0.

I have the below script running which is fired as a Folder Action and PDFPens the file, adds to Evernote and then deletes the file. The error handling does not go off, so it is like Evernote is accepting the command and returning success. The Alert in the Evernote section is firing and the script is deleting the file, so I know the call to Evernote is happening.

Please note, I am not an Applescript pro, this is a copy/paste/tweak from "Justin Williams, Second Gear". But this was working a few days ago before the 3.3.0 upgrade.

Any help is appreciated.

- Erik


-- OCR This (PDFpen)
--
-- Justin Williams, Second Gear
-- work: http://secondgearsoftware.com/
-- play: http://carpeaqua.com/
--
-- Credits:
-- Based on Acrobat scripts by Joe Kissel (http://www.macworld.com/article/60229/2007/10/nov07geekfactor.html)
on adding folder items to this_folder after receiving added_items
repeat with anItem from 1 to number of items in added_items
set this_item to item anItem of added_items
tell application "Finder"
if name of this_item is ".DS_Store" then exit repeat
end tell
try
tell application "PDFpen"
open this_item as alias
tell document 1
ocr
repeat while performing ocr
delay 1
end repeat
delay 1
close with saving
end tell
end tell
on error error_message number error_number
display alert "PDFpen Error" message "Error(" & error_number & "): " & error_message as warning
end try

set the item_info to info for this_item
set the item_path to this_item as text

tell application "Evernote"
try
display alert "Importing file"
create note from file item_path notebook "* Scanner In"
on error error_message number error_number

if the error_number is equal to 4 then
-- The file being imported is not supported
set userCanceled to false
try
display dialog "Your Evernote account does not support the import of this type of file. Why not consider upgrading?" buttons {"Cancel", "Go Premium"} default button "Cancel" cancel button "Cancel" with icon caution
on error number -128
set userCanceled to true
end try

-- If the user wishes they can be taken to the Evernote premium upgrade page
if userCanceled is false then
tell application "Safari"
activate
open location "https://www.evernote.com/Checkout.action"
end tell
end if
else
-- Unspecified failure
display alert "Import into Evernote failed" message "Error(" & error_number & "): " & error_message as warning
end if
end try
end tell

try
tell application "Finder"
delete the this_item
end tell
on error error_message number error_number
display alert "Failed to delete file after adding to Evernote" message "Error(" & error_number & "): " & error_message as warning
end try
end repeat
end adding folder items to

-- Release Notes
-- Version 1.0 (January 8, 2009) - Initial Release
-- Version 1.1 (July 1, 2009) - Updated for PDFpen 4.1.4's better OCR scripting abilities

  • Like 1

Share this post


Link to post

You may want to uninstall Evernote from the Appstore version and install directly from Evernote - the script *should* start working again.

Share this post


Link to post

Hi,

I have what I think is a related issue. Since 3.3.0 I can no longer drag/drop from mail attachments directly to the Evernote icon in the dock.

I can still drag, say, a PDF open in Preview to the dock item, and Evernote creates a new note.

If I drag a PDF attachment from Mail, however, the Evernote icon highlights, but dropping there does nothing at all.

Is this related, or should it be a new topic?

Thanks,

Craig.

Share this post


Link to post

You may want to uninstall Evernote from the Appstore version and install directly from Evernote - the script *should* start working again.

Heather,

Do you know if there is a page I can follow so I ensure my local notebooks (I do not sync everything) stay when I uninstall? I don't want to lose anything accidentally.

Thanks,

Erik

Share this post


Link to post

I have the same problems related to Applescript and clippings. Evernote will not create new notes from clippings, Applescript, or Print -> Send to Evernote since the 3.3 upgrade.

I am running Mountain Lion on a MBP.

Everything worked flawlessly before.

Share this post


Link to post

You may want to uninstall Evernote from the Appstore version and install directly from Evernote - the script *should* start working again.

Why is this the case? Shouldn't the two versions be the same?

I like being able to track my app installations and updates through the Mac app store. If I do what you are suggesting then I have to separately track Evernote from my other apps.

  • Like 2

Share this post


Link to post

I'm having an almost identical problem to Erik with applescript creation of a new note now failing after upgrading to EN 3.3.0 (also via Mac app store). We even share the same workflow (scan -> OCR with PDFpen -> import to Evernote via applescript). For me though under Lion 10.7.2.

I share Chris Lee's reluctance to remove EN and reinstall from a source outside the app store - it seems we would be potentially replacing one problem with another in the future.

My applescript code is abstracted using the Ruby library 'appscript' and worked flawlessly until the recent EN update. Now my script creates the new note, with an appropriate title, file creation dates and note text (the original filename of the scanned PDF), but instead of attaching the PDF the note contains "(null)" in its place.

The problem seems to be with the EN applescript bindings for attaching a file to a note rather than creating a note itself. Presumably note creation fails when a note containing only an attachment is attempted.

The meaty part of my code for other's interest:


# Create the note and attach the pdf file
app("Evernote").create_note(:title => title, :with_text => File.basename(filename),
:tags => tags, :notebook => notebook, :created => creation_time,
:attachments => [filename])

After scanning a doc I manually name the file with something meaningful via a ruby-applescript dialogue box (ie. "MobilePhone.bill.house.051112.pdf"). After OCR'ed with PdfPen, Note tags are extracted from the filename (e.g.. "bill" & "house"), the title then becomes a beautified version of the filename without tags (eg. "Mobile Phone 05112"), and the note creation date/time is set to the last 6 digits of the filename (eg. "5th Nov 2012"). Like Erik uses, my scripts are all activated via folder action scripts.

Evernote guys, any other suggestions for getting file-attachment via an applescript working again? My workflow has been nicely automated and humming along for some time now and it's a real pain to have this break.

Thanks!

Share this post


Link to post

My guess is it has to do with the difference in the location of the datastore in the Sandboxed build vs the Direct Download build, and the permissions to write in each. Hence why it would work on the direct download build.

Share this post


Link to post

Thanks Heather - that makes sense, so I will give it a try. Do you have a link to a non-Appstore Evernote dmg for download? All the Mac download links on evernote.com are to the Mac Appstore.

Thanks.

Share this post


Link to post

I have Evernote installed through the App Store. I upgraded to 3.3.0 this week. Afterwards, I can no longer create notes using Applescripts. I am running ML 10.8 and this was working the other day in ML before upgrading to 3.3.0.

I have the below script running which is fired as a Folder Action and PDFPens the file, adds to Evernote and then deletes the file. The error handling does not go off, so it is like Evernote is accepting the command and returning success. The Alert in the Evernote section is firing and the script is deleting the file, so I know the call to Evernote is happening.

Please note, I am not an Applescript pro, this is a copy/paste/tweak from "Justin Williams, Second Gear". But this was working a few days ago before the 3.3.0 upgrade.

Any help is appreciated.

- Erik


-- OCR This (PDFpen)
--
-- Justin Williams, Second Gear
-- work: http://secondgearsoftware.com/
-- play: http://carpeaqua.com/
--
-- Credits:
-- Based on Acrobat scripts by Joe Kissel (http://www.macworld.com/article/60229/2007/10/nov07geekfactor.html)
on adding folder items to this_folder after receiving added_items
repeat with anItem from 1 to number of items in added_items
set this_item to item anItem of added_items
tell application "Finder"
if name of this_item is ".DS_Store" then exit repeat
end tell
try
tell application "PDFpen"
open this_item as alias
tell document 1
ocr
repeat while performing ocr
delay 1
end repeat
delay 1
close with saving
end tell
end tell
on error error_message number error_number
display alert "PDFpen Error" message "Error(" & error_number & "): " & error_message as warning
end try

set the item_info to info for this_item
set the item_path to this_item as text

tell application "Evernote"
try
display alert "Importing file"
create note from file item_path notebook "* Scanner In"
on error error_message number error_number

if the error_number is equal to 4 then
-- The file being imported is not supported
set userCanceled to false
try
display dialog "Your Evernote account does not support the import of this type of file. Why not consider upgrading?" buttons {"Cancel", "Go Premium"} default button "Cancel" cancel button "Cancel" with icon caution
on error number -128
set userCanceled to true
end try

-- If the user wishes they can be taken to the Evernote premium upgrade page
if userCanceled is false then
tell application "Safari"
activate
open location "https://www.evernote.com/Checkout.action"
end tell
end if
else
-- Unspecified failure
display alert "Import into Evernote failed" message "Error(" & error_number & "): " & error_message as warning
end if
end try
end tell

try
tell application "Finder"
delete the this_item
end tell
on error error_message number error_number
display alert "Failed to delete file after adding to Evernote" message "Error(" & error_number & "): " & error_message as warning
end try
end repeat
end adding folder items to

-- Release Notes
-- Version 1.0 (January 8, 2009) - Initial Release
-- Version 1.1 (July 1, 2009) - Updated for PDFpen 4.1.4's better OCR scripting abilities

I haven't tried etm17 script yet, but I have tried a similar script. My script will open Evernote, but Evernote freezes up and the note doesn't transfer. I'm running version 5.02 of Evernote that was downloaded from Evernote and not from the App Store.

Share this post


Link to post

Scripting still works, but you need to change the tell:

tell application id "com.evernote.evernote"

For some reason AppleScript confuses "EvernoteHelper" for "Evernote" when Evernote is not open. Changing the tell to the application ID eliminates the problem.

Share this post


Link to post

Scripting still works, but you need to change the tell:

tell application id "com.evernote.evernote"

For some reason AppleScript confuses "EvernoteHelper" for "Evernote" when Evernote is not open. Changing the tell to the application ID eliminates the problem.

 

Thank you much swbuehler!

 

I did need to make another tweak and pass the {this_item} to the create note from file command instead of file_path. For reference below is the working script I am using now.

-- OCR This (PDFpen)---- Justin Williams, Second Gear-- work: http://secondgearsoftware.com/-- play: http://carpeaqua.com/---- Credits:-- Based on Acrobat scripts by Joe Kissel (http://www.macworld.com/article/60229/2007/10/nov07geekfactor.html)on adding folder items to this_folder after receiving added_items	repeat with anItem from 1 to number of items in added_items		set this_item to item anItem of added_items		tell application "Finder"			if name of this_item is ".DS_Store" then exit repeat		end tell		try			tell application "PDFpen"				open this_item as alias				tell document 1					ocr					repeat while performing ocr						delay 1					end repeat					delay 1					close with saving				end tell			end tell		on error error_message number error_number			display alert "PDFpen Error" message "Error(" & error_number & "): " & error_message as warning		end try				tell application id "com.evernote.evernote"			try				activate				create note from file this_item notebook {"* Scanner In"}			on error error_message number error_number								if the error_number is equal to 4 then					-- The file being imported is not supported					set userCanceled to false					try						display dialog "Your Evernote account does not support the import of this type of file. Why not consider upgrading?" buttons {"Cancel", "Go Premium"} default button "Cancel" cancel button "Cancel" with icon caution					on error number -128						set userCanceled to true					end try										-- If the user wishes they can be taken to the Evernote premium upgrade page					if userCanceled is false then						tell application "Safari"							activate							open location "https://www.evernote.com/Checkout.action"						end tell					end if				else					-- Unspecified failure					display alert "Import into Evernote failed" message "Error(" & error_number & "): " & error_message as warning				end if			end try		end tell				try			tell application "Finder"				delete the this_item			end tell		on error error_message number error_number			display alert "Failed to delete file after adding to Evernote" message "Error(" & error_number & "): " & error_message as warning		end try	end repeatend adding folder items to-- Release Notes-- Version 1.0 (January 8, 2009) - Initial Release-- Version 1.1 (July 1, 2009) - Updated for PDFpen 4.1.4's better OCR scripting abilities

Share this post


Link to post

×
×
  • Create New...