Excel Looping for Form

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
bivanchan
Posts: 29
Joined: 10 Feb 2022, 10:01

Excel Looping for Form

Post by bivanchan » 17 Aug 2022, 16:32

Hey everyone. I am working on this script to grab excel rows, fill out a form, loop back for the next row and then STOP when the cell is empty. I only need A and C columns from the excel doc.

I can get it to work but then get stuck in an endless loop and cant get out of it. Here is the code. I shortened the form down a bit, as that works well already. Just not sure how to keep it from looping

Code: Select all

#SingleInstance, Force
#warn

rows := [] 
loop, Read,  C:\SALES\COUPONS.csv
	rows.Push(StrSplit(A_LoopReadLine, ","))

{
for each, row in rows 
	DATE := row.1
	CODE := row.3

WinActivate, ahk_exe chrome.exe
Sleep, 500
SendInput, {home}

CoordMode, mouse, screen   
MouseClick, left, 595, 363
Sleep, 500

CoordMode, mouse, screen
MouseClick, left, 1171, 408

Sleep, 500
Send, 60

Sleep, 500
CoordMode, mouse, screen
MouseClick, left, 837, 653
SendInput, %DATE%

Sleep, 500
CoordMode, mouse, screen
MouseClick, left, 1191, 657
SendInput, %DATE%

Sleep, 500
CoordMode, mouse, screen
MouseClick, left, 831, 872
SendInput, %CODE%

Sleep, 500
CoordMode, mouse, screen
MouseClick, left, 1457, 992

Sleep, 500
CoordMode, mouse, screen
MouseClick, left, 522, 400

Sleep, 500
CoordMode, mouse, screen
MouseClick, left, 508, 457

Sleep, 500
CoordMode, mouse, screen
MouseClick, left, 522, 400

Sleep, 500
CoordMode, mouse, screen
MouseClick, left, 514, 492

Sleep, 500
CoordMode, mouse, screen
MouseClick, left, 1412, 989

Sleep, 500
CoordMode, mouse, screen
MouseClick, left,1372, 988

Sleep, 500
CoordMode, mouse, screen
MouseClick, left,961, 745

}
[Mod edit: [code][/code] tags added.]
Last edited by gregster on 18 Aug 2022, 00:50, edited 1 time in total.
Reason: Please use code tags. Thank you!

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

Re: Excel Looping for Form

Post by mikeyww » 18 Aug 2022, 07:04

If you need a block, then the brace would go after the command, rather than before it. You can test a shorter script, get your block working, and then expand from there.

bivanchan
Posts: 29
Joined: 10 Feb 2022, 10:01

Re: Excel Looping for Form

Post by bivanchan » 18 Aug 2022, 09:14

Not sure I fully understand, Are you saying it should look like this?

Code: Select all

rows := [] 
loop, Read,  C:\SALES\COUPONS.csv
	rows.Push(StrSplit(A_LoopReadLine, ","))

{
for each, row in rows 
	DATE := row.1
	CODE := row.3
}
WinActivate, ahk_exe chrome.exe
Sleep, 500
SendInput, {home}
[Mod edit: [code][/code] tags added.]

?
Last edited by gregster on 18 Aug 2022, 09:14, edited 1 time in total.
Reason: Please use code tags. Thank you!

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

Re: Excel Looping for Form

Post by mikeyww » 18 Aug 2022, 09:42

The link that I cited provides you with an example. I recommend examining it. Another example is below.

Code: Select all

For each, row in rows
{
 DATE := row.1
 CODE := row.3
 ; Other commands
}

bivanchan
Posts: 29
Joined: 10 Feb 2022, 10:01

Re: Excel Looping for Form

Post by bivanchan » 18 Aug 2022, 10:54

Oh fantastic, that worked perfect. Thank you.

Post Reply

Return to “Ask for Help (v1)”