Looping arrays and storing them to continue later. Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Jazz
Posts: 3
Joined: 29 May 2023, 20:54

Looping arrays and storing them to continue later.

Post by Jazz » 29 May 2023, 21:56

Hello,

I'm looking to have my code send the first four sub-arrays of the "textarr"
Then i'd like to store this somehow and continue at the 5th sub-array the next time it is called.
I've added 4 notepads with what it's supposed to do and the infinite loop it's creating at the moment.
Tried a whole bunch of stuff but can't seem to figure it out.
First time posting. Any insight would be appreciated :D

Thanks in advance!


Code: Select all

;example

$o::Pause
Esc::ExitApp
$p::
textarr := [["test1", "test2"], ["test3", "test4"], ["test5", "test6"], ["test7", "test8"], ["test9", "test10"], ["test11", "test12"], ["test13", "test14"], ["test15", "test16"]]
coordarr := [[663, 17], [266, 415], [-149, 22], [259, -376]] ;to make the next window i have open active (probably a better way to do it then this :p)

PixelGetColor, expectcolor, 245, 217, 2 ;looking for a specific color with a tolerance of 2
if (expectcolor == "0x272727"){
    Loop, 1 
        {
            Loop, % textarr.Length()
            {
                Loop, % coordarr.Length()
                    {
                    arrsplit1 := textarr[A_Index]
                    t1 := arrsplit1[1]
                    t2 := arrsplit1[2]

                    Sleep, 50
                    Send, %t1%
                    Send, {Space}
                    Send, {Tab}
                    Send, %t2%
                    Sleep, 100
                    Send, {Enter}

                
                            
                    arrsplit2 := coordarr[A_Index]
                    x31 := arrsplit2[1]
                    y31 := arrsplit2[2]
                    

                    Sleep, 300
                    MouseMove, x31, y31
                    Sleep, 30
                    Click
                    Sleep, 100
                }
            }
        }
}    

Else {
    MsgBox, % "error"
}
MsgBox, % "The code will continue now and do a bigger loop later"




image.png
image.png (42.49 KiB) Viewed 264 times
image.png
image.png (50.65 KiB) Viewed 264 times


Also special thanks to the user: mikeyww
You've helped this lurker more then u know ;)


[Mod action: Moved topic to v1 section. The main section is for v2.]

User avatar
mikeyww
Posts: 26602
Joined: 09 Sep 2014, 18:38

Re: Looping arrays and storing them to continue later.  Topic is solved

Post by mikeyww » 30 May 2023, 04:51

Welcome to this AutoHotkey forum!

Code: Select all

#Requires AutoHotkey v1.1.33
txt := [["a", "b"], ["c", "d"], ["e", "f"]]
Gosub F4

F4::txt2 := txt.Clone() ; F4 = Reset array

F3::                    ; F3 = Send the next pair
For each, item in txt2.RemoveAt(1)
 Send % item " ... "
Send `n
Return

F5::
Loop 2
 Gosub F3
Return

Code: Select all

#Requires AutoHotkey v1.1.33
txt := [["a", "b"], ["c", "d"], ["e", "f"]]
Gosub F5

F3::go(txt2)
F4::go(txt2, 2)

F5:: ; F5 = Reset array
txt2 := txt.Clone()
SoundBeep 1500
Return

go(txt, n := 1) {
 Loop % n {
  For each, item in txt.RemoveAt(1)
   Send % item " ... "
  Send `n
 }
}

Jazz
Posts: 3
Joined: 29 May 2023, 20:54

Re: Looping arrays and storing them to continue later.

Post by Jazz » 30 May 2023, 12:22

Thank you for the welcome and help :dance:

Post Reply

Return to “Ask for Help (v1)”