StevieD
StevieD

Reputation: 7433

Is it possible to send keystrokes to a web page in Safari?

I'd like to tab to the first link in a google search with an applescript. Tried this:

tell application "Safari" to activate
tell application "System Events"
       repeat 17 times
       keystroke tab using control down
       end repeat
end tell

But this just cycles through the open tabs quickly. I've googled around and can't find anything that explains how to send the keystroke to the current open tab in Safari.

Upvotes: 1

Views: 472

Answers (1)

user3439894
user3439894

Reputation: 7555

Is it possible to send keystrokes to a web page in Safari?

Yes its possible.

The AppleScript code in your question is cycling thru tabs because that's what the keyboard shortcut ⌃Tab does.

To just have it tab, remove using control down from the keystroke tab using control down command.

Upvotes: 1

Related Questions