Possible to loop through Clipboard?


I was just wondering if it was possible to LOOP through the contents of the Clipboard line by line and to then process each line in some way.

For example lets say my Clipboard contains the following.

Option 1
Option 2
Option 3
Option 10

I have a form where I want to loop through these lines.

For each line I want to paste that line into a FIELD on a Form, and then simulate a TAB press and then Paste the next line into the next FIELD on the Form.

Hey Andy,

I appreciate all these good questions about interesting use-cases. This is the approach I thought up for this one:

  1. take your clipboard and turn it into a list of items, separated by your line-breaks. I do this by defining the variable clipboardlist, and saying that it's the split contents of my clipboard: {clipboardlist=split({clipboard},"\n")}

  2. use repeat with list comprehension to do a set of actions for each item within the list.

That looks like this:

{repeat: for x in clipboardlist}{=x} {key: tab}{endrepeat}

Whatever is between the {repeat: for x in clipboardlist} and {endrepeat} tags will be performed for each item ("x") in the list ("clipboardlist"). You can also use this to transform every item in your list with something like this:

{repeat: for x in otherlist}{=x} is an item that is on my list
{otherlist=["Option 1", "Option 2", "Option 3", "Option 4", "Option 5", "Option 6", "Option 7", "Option 8", "Option 9", "Option 10"]}

Lists are super useful as your Text Blaze usage gets more complex. I recently wrote this guide for them: Text Blaze | Interacting with lists


Wow, thank you again Andrew, this is awesome. I think I can now finally migrate the last few of my Autohotkey scripts.

Very grateful for everyone here who has helped me.

Thank you.