Jump to content

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!

Share this post


Link to post
Share on other sites

@DragonFroot
Post your script so we can help you :)


Click here to see my signature:

Spoiler

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


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

Share this post


Link to post
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

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
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 

Share this post


Link to post
Share on other sites
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

Thoughts:

  • I will always thank you for the time you spent for me.
    I'm here to ask, and from your response, I'd like to learn.
    By my knowledge, I can help someone else, and "that someone" could help in turn another, and so on.

/*--------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/

ALWAYS GOOD TO READ:

 

Share this post


Link to post
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

×
×
  • Create New...