Jump to content

How do I code this?


Recommended Posts

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!

Link to comment
Share on other sites

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 by DragonFroot
Link to comment
Share on other sites

@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:

 

Link to comment
Share on other sites

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 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...