applescript子程序和动作的属性

时间:2016-05-09 19:08:33

标签: 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定义为属性,但仍然会遇到相同的错误。关于如何处理它的任何指导?

1 个答案:

答案 0 :(得分:0)

这适用于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