DragonFroot Posted April 9, 2019 Posted April 9, 2019 Hi, I'm trying to expand my autoit knowledge & I'm having trouble creating the following program: Say I have a list of 6 items, I want the program to Clipput 2 items at a time into notepad (on a loop) until item 6. So lets say my list is: Red, Blue, Green, Yellow, Orange, Purple I want the program to: Clipput Red, Blue (loops again); clipput Green, Yellow (loops again); Clipput Orange, Purple. I know I can create this with 3 lines of just using clipput, but the code ends up very very long for when I have more items (and then changing the list becomes a mess). All help appreciated!
FrancescoDiMuro Posted April 9, 2019 Posted April 9, 2019 @DragonFroot Post your script so we can help you Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
DragonFroot Posted April 9, 2019 Author Posted April 9, 2019 (edited) 5 minutes ago, FrancescoDiMuro said: @DragonFroot Post your script so we can help you My current code goes like this: Clipput ("Item 1, Item2") Send(^v) Clipput ("Item3, Item4") Send(^v) Clipput ("Item5, Item6") (ignore any mistakes, this is just an example) However, I want to make it like this: List: Item 1 Item 2 Item 3 Item 4 Item 5 Item 6 (etc etc) While 1 Clipput(2 items) WEnd And have it automatically select the next 2 items every time it loops. Edited April 9, 2019 by DragonFroot
FrancescoDiMuro Posted April 9, 2019 Posted April 9, 2019 @DragonFroot You could think to store the list of item in an array, and do something like this (pay attention at the step value in the second for): #include <Array.au3> ; List of items Global $arrItems[0] ; Populate the array For $i = 1 To 100 Step 1 _ArrayAdd($arrItems, "Item " & $i) If @error Then ConsoleWrite("_ArrayAdd() ERR: " & @error & @CRLF) Next ; Show the For...Next behaviour For $i = 0 To UBound($arrItems) - 1 Step 2 ConsoleWrite('ClipPut("' & $arrItems[$i] & ", " & $arrItems[$i+1] & '")' & @CRLF) Next Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
DragonFroot Posted April 9, 2019 Author Posted April 9, 2019 2 minutes ago, FrancescoDiMuro said: @DragonFroot You could think to store the list of item in an array, and do something like this (pay attention at the step value in the second for): #include <Array.au3> ; List of items Global $arrItems[0] ; Populate the array For $i = 1 To 100 Step 1 _ArrayAdd($arrItems, "Item " & $i) If @error Then ConsoleWrite("_ArrayAdd() ERR: " & @error & @CRLF) Next ; Show the For...Next behaviour For $i = 0 To UBound($arrItems) - 1 Step 2 ConsoleWrite('ClipPut("' & $arrItems[$i] & ", " & $arrItems[$i+1] & '")' & @CRLF) Next Thank you!! but lets just say I had a list of colors instead of "Item 1 Item 2", how would that work? Couldn't I just create an array with a list of all the items I have
FrancescoDiMuro Posted April 9, 2019 Posted April 9, 2019 6 minutes ago, DragonFroot said: Couldn't I just create an array with a list of all the items I have Sure Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now