2016-05-09 12 views
0

私の小さなapplescriptでアクションプロパティエラーが発生しました。ここではスクリプトがあります:applescriptサブルーチンとアクションのプロパティ

tell application "evernote" to activate 
tell application "System Events" 
    --tell process "evernote" 
    set the clipboard to text_content() 
    keystroke "v" using command down 
    keystroke return 
    --end tell 
end tell 
return input 
end run 

ここではサブルーチンは、これが私のアクションプロパティのエラーを示しているメインプログラムの後

on text_content() 

delay 1 

tell application "Safari" to set theURL to URL of front document 
set theDate to do shell script "date +'%d-%m-%Y'' - '%T" 
set theusertext to " , " 
set get_text to (theURL & return & theusertext & theDate) as string 
return get_text 

end text_content 

です。私はスクリプト全体のさまざまな場所でプロパティとしてget_textを定義しようとしましたが、同じエラーが発生しています。どのようにそれに対処するためのガイダンス?

+0

あなたが提供したスクリプトを実行すると、まったくエラーは発生せず、予想される動作をします。スクリプトエディタで直接実行しますか?もしそうなら、お使いのOSのバージョンは? – rems4e

+0

はい、あなたは正しいです、私は自分の投稿を編集しました。スクリプトのさまざまな部分に問題があります。 – lawsome

+0

サブルーチンを実行できません。それはオートメーターにあり、リンゴのスクリプトではありません。 – lawsome

答えて

0

これは、ScriptsメニューまたはScript Editorから実行されるOSX 10.11.4のEvernote 6.6.1(453372)で動作します。

--- GET THE INFO FROM SAFARI FIRST --- 

set the clipboard to (text_content() & return) 

tell application "Evernote" to activate 
tell application "System Events" 
    tell process "evernote" 
     keystroke "v" using command down 
     delay 0.5 

     --- Evernote is NOT behaving properly --- 
     -- It should leave the cursor at the END of the paste 
     -- but it is not. 
     -- So, we have to arrow down then issue a return 
     -- The above delay is also required to make sure the paste 
     -- has completed before any more keystrokes 

     key code 125 -- DOWN arrow 
     keystroke return 

    end tell 
end tell 


on text_content() 

    --delay 1  ## don't see any need for this 

    tell application "Safari" to set theURL to URL of front document 
    set theDate to do shell script "date +'%d-%m-%Y'' - '%T" 
    set theusertext to " , " 
    set get_text to (theURL & return & theusertext & theDate) as string 
    return get_text 

end text_content 
+0

ありがとう@JMichaelTX。私はあまりにもあなたが言及したカーソルの問題に気付きました、私はキーコード125をコマンドダウンとキーストロークリターンを使用して使用しましたが、evernoteではなくサファリで処理していました。私はappendコマンドを使用していたので、カーソルの問題はありません。 – lawsome

関連する問題