New to AHK, CSV Suggestions Welcome

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
nawarkk
Posts: 3
Joined: 05 Apr 2021, 13:33

New to AHK, CSV Suggestions Welcome

05 Apr 2021, 14:52

Hi all, forgive my lack of knowledge. I'm looking to use AHK to automate typing in numerical values from a .CSV (I know, original). My CSV is to have five columns, two of which, will be where I need to grab numerical digits. The other three are there just for information and don't need to be used.

(A1, B1, C1, D1, E1) x N - where B1 and C1 are needed.

B1 will be sent, then a tab used and then C1. A sleep will then commence for 1500, to which we then tab and repeat the process by however many rows/lines there are.

This CSV will be updated frequently, so I'd like the code to read the CSV on each run so that it has the most up to date values.

I've used this to get the total amount of rows:

Code: Select all

Loop, Read, C:\Users\x\Desktop\test.csv
TotalRows++
And then got this to work too:

Code: Select all

Send, 1234 {tab} 1
Sleep, 1500
Send, {tab} 
Send, 3456 {tab} 2
[Mod edit: [code][/code] tags added.]

I would just like to have the 1234 be replaced with B1 and 1 replaced with C1. Then, 3456 replaced with B2 and 2 replaced with C2 and so on and so forth.

Considering my CSV may be rather long, I'd love to have a way to stop and start it at a certain line within the CSV, though this would just be a ease of use. My idea would be that after each sent pair of codes, it'd wait for an ESC input to stop.

Hoping I'm at least onto the right path. Thank you all for the help.
nawarkk
Posts: 3
Joined: 05 Apr 2021, 13:33

Re: New to AHK, CSV Suggestions Welcome

06 Apr 2021, 23:00

mikeyww wrote:
05 Apr 2021, 16:07
See example #4 on the following page.

https://www.autohotkey.com/docs/commands/LoopParse.htm
Thank you! I've checked out example 4 and it seems to report the lines, one by one (%LineNumber%) and then the column number, one by one (%A_Index%) which then reports the actual value stored in the CSV %A_LoopField%.

I'm trying to understand how to get it to report just the value based on a specific column. I would use the %LineNumber% to move row to row, but I'd need only B1 and C1 instead of each of the %A_Index%. Is there a way to get it to report only a specified column?

I'm imagining that after these two specific columns are reported, I'd use a send command to input the B1, C1 values, pause, tab and then move to B2, C2, etc.
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: New to AHK, CSV Suggestions Welcome

07 Apr 2021, 03:08

Code: Select all

FileRead, content, C:\Users\x\Desktop\test.csv
i := StrSplit(content,"`n")
Loop % i.Count()
	{	MsgBox % StrSplit(i[A_Index],",").2 . "`t" . StrSplit(i[A_Index],",").3	; replace 'MsgBox' with 'Send' after testing/reviewing.
		Sleep 1500
	}
Untested concept, without pause/resume option.
nawarkk
Posts: 3
Joined: 05 Apr 2021, 13:33

Re: New to AHK, CSV Suggestions Welcome

19 Apr 2021, 20:03

Short of hard coding this, I'm still running into issues this past week.
BoBo wrote:
07 Apr 2021, 03:08

Code: Select all

FileRead, content, C:\Users\x\Desktop\test.csv
i := StrSplit(content,"`n")
Loop % i.Count()
	{	MsgBox % StrSplit(i[A_Index],",").2 . "`t" . StrSplit(i[A_Index],",").3	; replace 'MsgBox' with 'Send' after testing/reviewing.
		Sleep 1500
	}
Untested concept, without pause/resume option.
The above seems to make sense, "i" being the entirety of the string of the CSV split by a new line "`n". The MsgBox then should be the actual value of another string split, this time being from A_Index? and then .2 being column B and .3 being column C? I'll have to debug this some but currently, it's not doing anything. Thank you for helping find the path!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, OrangeCat and 175 guests