Search code examples
javascriptioslistapplescriptkeystroke

is there a way to auto type a list using script writing?


i need a code which will type each item one after another

for eg: myList {"Apple Watch", "iMac", "iPhone", "MacBook Pro"}

i wanted result typed as:

Apple Watch

iMac

iPhone

MacBook Pro

i have tried to make a code but cannot do it due to lack of my knowledge

my code:

set theList to {"Apple Watch", "iMac", "iPhone", "MacBook Pro"}
length of theList
tell application "System Events"
    set condition to 0
    set varName to item 1 of theList
    repeat until condition = length of theList
        keystroke of varName
        keystroke return
        set condition to condition + 1
        set varName to (item 1) + condition
    end repeat
end tell

Solution

  •     tell application "System Events"
            set varX to 1
            set condition to 0
            repeat until condition = length of theList
                set varName to item varX of theList
                keystroke of varName
                delay 0.2
                keystroke return
                set varX to varX + 1
                set condition to condition + 1
            end repeat
        end tell
    end tell