以前からOmniFocusとEvernoteの連携で、EvernoteのノートURIが存在しないのできないと考えていたのですが、OmniFocusのタスクのURIは取得できるので、それを使えばいいじゃないかということで、いくつかAppleScriptを書いてみました。
まず、Evernoteノートを作成するスクリプトです。
新規にノートを作成して、タイトルにタスクのname、ソースURLにタスク(プロジェクト/フォルダ)URIを記入、タグにプロジェクト名を設定、本文にタスクURIとOmniFocusタスクのノートを記入します。本文にもURIを記入するのは、EvernoteでのソースURLの検索方法が無いみたいだからです。
tell front window of application "OmniFocus" try set theTrees to selected trees of content if (count of theTrees) < 1 then set theTrees to selected trees of sidebar end if if (count of theTrees) < 1 then return end if set theSelection to value of item 1 of theTrees if class of theSelection is folder then set theURI to "omnifocus:///folder/" & id of theSelection set theNote to "" else if class of theSelection is project then set theURI to "omnifocus:///project/" & id of theSelection set theNote to "" else set theURI to "omnifocus:///task/" & id of theSelection set theNote to note of theSelection set theProjectName to name of containing project of theSelection end if set theName to name of theSelection tell application "Evernote" set newNote to create note with text theURI & return & theNote set title of newNote to theName set source URL of newNote to theURI if (count of theProjectName) > 0 then if (not (tag named theProjectName exists)) then make tag with properties {name:theProjectName} end if set theTag to tag named theProjectName assign theTag to newNote end if open note window with newNote activate end tell end try end tell |
次にタスクURIをクリップボートに取得するスクリプトです。取得したURIは、既に存在するEvernoteノートに貼り付けるといいです。ソースURLにだけでなく、本文にも貼り付けておかないとURIで検索できません。
tell front window of application "OmniFocus" try set theTrees to selected trees of content if (count of theTrees) < 1 then set theTrees to selected trees of sidebar end if if (count of theTrees) < 1 then return end if set theSelection to value of item 1 of theTrees if class of theSelection is folder then set the clipboard to "omnifocus:///folder/" & id of theSelection else if class of theSelection is project then set the clipboard to "omnifocus:///project/" & id of theSelection else set the clipboard to "omnifocus:///task/" & id of theSelection end if end try end tell |
そして、上記二つのスクリプトで作成したEvernoteをタスクURIで検索するためのスクリプトです
tell front window of application "OmniFocus" try set theTrees to selected trees of content if (count of theTrees) < 1 then set theTrees to selected trees of sidebar end if if (count of theTrees) < 1 then return end if set theSelection to value of item 1 of theTrees if class of theSelection is folder then set theURI to "omnifocus:///folder/" & id of theSelection else if class of theSelection is project then set theURI to "omnifocus:///project/" & id of theSelection else set theURI to "omnifocus:///task/" & id of theSelection end if tell application "Evernote" open collection window with query string theURI activate end tell end try end tell |
EvernoteでURLの検索ができればいいのですが…。
ついでに、OmniFocusのプロジェクト名をEvernoteタグにしているので、プロジェクト名でタグを検索するスクリプトです。なんでもNozbeではプロジェクト名とEvernoteのタグが連動するらしいので、同様の機能をAppleScriptで実現しました。複数プロジェクト名での検索には対応してません。
tell front window of application "OmniFocus" try set theTrees to selected trees of content if (count of theTrees) < 1 then set theTrees to selected trees of sidebar end if set theSelection to value of item 1 of theTrees if class of theSelection is folder then set theQuery to "tag:" & name of theSelection else if class of theSelection is project then set theQuery to "tag:" & name of theSelection else set theProject to containing project of theSelection if theProject is equal to missing value then return end if set theQuery to "tag:" & name of theProject end if tell application "Evernote" open collection window with query string theQuery activate end tell end try end tell |
どのスクリプトもできたてホヤホヤでテストが不十分ですので、バグがあればコメントよろしくです。
Evernoteノートを作成するスクリプト を使わせて頂いていたのですが、どうやら Evernote 5 に上げてから機能しなくなりました。
Evernote 5 がまだβ版なので、今後機能するようになるかもしれませんが、お時間がありましたらチェックして頂けると幸いです。
残念ながら私はMac App StoreからEvernoteを入れてるのでBeta版は使えない状態です。
Evernoteから直接アプリをダウンロードしようと思ったんですが、どこにあるかわからないんですよね。
現在はEvernoteノートURLを取得できるのでOmniFocusにEvernoteノートURLを入れる方がいいと思いますが、まだ需要があるなら正式リリースしたらチェックしてみます。
Evernote beta は Preferences で β版のアップデートを含むにすれば可能だったと思うのですが、 Mac AppStore からの物はその項目も無いのかな?
僕の場合、デスクトップに浮かんだ事を咄嗟に控えるのに、OmniFocus のクイックエントリを使う事があるのですが、後から Inbox を見直して、必要な物を Evernote に記述することがあるのでかなり便利です。(Inbox からは機能しなかったですっけ?)
いずれにしてもお返事ありがとうございました。
Mac App StoreからダウンロードするとBetaにはアップデートできないんです。
Evernote 5が使えるようになったら検証してみますね。