2022-08-14

is there a way to input a list from clipboard and as a list? or any other solution to do the same?

I have a code in AppleScript, which is supposed to have an input from last copied text separated by commas. i have made so that script recognise the copied as list.

have a look to my example

i have a list of names

Apple Watch

iPhone

iPad

macBook

in order to recognise as a list i have made in to readable list like "Apple Watch","iPhone","iPad","macBook" and have copied to my clipboard expecting the to have automatically pasted to my code as input. But unfortunately the code doesn't recognise each string separately and gives the same output like this: "Apple Watch","iPhone","iPad","macBook" instead of this:

Apple Watch

iPhone

iPad

macBook

tell application "Safari"
    activate
    set Storage to get clipboard
    set theList to {Storage}
    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
            delay 0.2
            set varX to varX + 1
            set condition to condition + 1
        end repeat
    end tell
end tell

the same thing will work according to my need if i paste that list in the place Storage but i need to happen it automatically without me pasting the list everytime by opening the script.

i apologise for becoming very wordy Can anybody please give me solution?



No comments:

Post a Comment