Applescript help.

Posted:
in macOS edited January 2014
Here is what I am needing, I can't seem to figure it out.



I need a script that runs these keystrokes in Safari. That's it. I tried letting the editor record, but it won't.



tab

tab

tab

tab

tab

tab

tab

tab

tab

space

tab

space

tab

space

tab

space

tab

space

tab

space

tab

space

tab

space

tab

space

tab

space

tab

Comments

  • Reply 1 of 2
    outsideroutsider Posts: 6,008member
    Try this. It'll work in Panther and Tiger, maybe even Jaguar. I like to put things in try/end try to handle errors a bit more gracefully.



    Code:


    tell application "System Events"



    tell application process "Safari"



    activate



    try

    repeat 9 times

    key code 48 -- this gives you a tab

    end repeat



    repeat 10 times

    keystroke " " -- this gives you space

    key code 48

    end repeat



    on error

    display dialog "I made a boo-boo." buttons {"Doh!"} default button 1

    end try



    end tell



    end tell



  • Reply 2 of 2
    outsideroutsider Posts: 6,008member
    Also if you want Safari to open up a site before hand, just put these 2 lines before the other code block:



    Code:


    set theWebSite to "http://www.apple.com";



    tell application "Safari" to open location theWebSite



Sign In or Register to comment.