2016-05-09 14 views
0

Ich bin mit einer Aktion Eigenschaften Fehler mit meinem kleinen AppleScript stecken. Hier ist das Skript:applescript Unterprogramm und Aktion Eigenschaften

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 

hier Unterroutine nach Hauptprogramm

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 

Dies zeigt mir eine Aktion Eigenschaften Fehler. Ich habe versucht, get_text als Eigenschaften an verschiedenen Stellen im Skript zu definieren, aber immer noch den gleichen Fehler. Irgendwelche Hinweise, wie man damit umgehen soll?

+0

Das Ausführen des Skripts, das Sie wortwörtlich ausgegeben haben, stellt für mich keinen Fehler dar und hat das erwartete Verhalten. Führst du es direkt im Skript-Editor? Wenn ja, wie lautet Ihre Betriebssystemversion? – rems4e

+0

ja, du hast Recht, ich habe meinen Post bearbeitet. Es ist ein Problem mit verschiedenen Teilen des Skripts. – lawsome

+0

kann jetzt keine Unterroutine ausgeführt werden. Es ist in Automator, nicht in Apple Script. – lawsome

Antwort

0

Dies funktioniert für mich in Evernote 6.6.1 (453372) auf OSX 10.11.4, entweder aus dem Skript-Menü oder Skript-Editor.

--- 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

danke @JMichaelTX. Ich bemerkte auch das Cursor-Problem, das Sie erwähnten, und ich benutzte den Schlüsselcode 125, indem ich den Befehl runter und die Taste zurückgab, aber es wurde in Safari statt in evernote verarbeitet. Da ich Append-Befehl verwendet, keine Probleme mit dem Cursor. – lawsome

Verwandte Themen