FlashGirl
FlashGirl

Reputation: 21

How do I invoke enter with keystroke in AppleScript so Web Clipper will save a web page to Evernote?

Lately I have discovered Automator (yes, finally she did that) and I wanted to make an event which runs at a regular interval using Calendar. I wanted to save a particular web page to Evernote using the Web Clipper extension in Safari.

I set up my Web Clipper to start on $, F = Full page, enter = Save.

I have come so far as to actually have an event which works by:

  1. Creating a new document in Automator of the type Calendar
  2. Adding "Get Specified URLs" with the URL I want
  3. Adding "Display Webpages"
  4. Adding "Run AppleScript" with the following code - I'm a total noob at AppleScript so you might say I could have done it in a better way ... then do tell ;) ...:
    tell application "Safari" to activate 
    delay 5
    tell application "System Events"
        keystroke "$" -- key code 10 = Activate Web Clipper (custom shortcut)
    end tell
    delay 1
    tell application "System Events"
        keystroke "f" -- key code 3 = Full page saved by Web Clipper
    end tell
    tell application "System Events"
        key code 36 -- works to save page, however, 'keystroke enter' does not
    end tell

5.Saving the document in a Calendar event and set it up to repeat.

I found some help here with a list of key code values, however, I couldn't find "enter" in the list. I used a little free app called Key Codes instead to figure out that enter has the key code 36.

I would rather be able to use keystroke, since it is easier to read than some number. Can anyone help?

Upvotes: 2

Views: 7163

Answers (1)

mcgrailm
mcgrailm

Reputation: 17640

i'm not sure this will do exactly what you want but maybe just keystroke return ?

tell application "Safari" to activate
delay 5
tell application "System Events"
    keystroke "$" -- key code 10 = Activate Web Clipper (custom shortcut)
delay 1
    keystroke "f" -- key code 3 = Full page saved by Web Clipper
    keystroke return
end tell

Upvotes: 2

Related Questions