reading CSV cells and pasting it into chrome browser
reading CSV cells and pasting it into chrome browser
Hi guys,
I have a need for a super simple script but not sure how its done. Basically I have a csv file and it needs to copy the cells in column W, then go to chrome and past the url that was in the cell, then close the tab and that's it. But I need it to do it for all the cells in column W, one at a time until I reach blank cells. So basically:
start loop
copy cell W1, go to chrome and paste, then close tab
copy cell W2, go to chrome and paste, then close tab
copy cell W3, go to chrome and paste, then close tab
copy cell W4, go to chrome and paste, then close tab
repeat until the cell in Wxxx is a blank, then stop the loop (if this part is too hard I can just specify the number of loops required as I would know the information before running the code by counting the rows)
end loop
Is there anyone that can guide me in the right direction
So far I only know how to do the run chrome and paste and close tab part.
Thanks for your help
I have a need for a super simple script but not sure how its done. Basically I have a csv file and it needs to copy the cells in column W, then go to chrome and past the url that was in the cell, then close the tab and that's it. But I need it to do it for all the cells in column W, one at a time until I reach blank cells. So basically:
start loop
copy cell W1, go to chrome and paste, then close tab
copy cell W2, go to chrome and paste, then close tab
copy cell W3, go to chrome and paste, then close tab
copy cell W4, go to chrome and paste, then close tab
repeat until the cell in Wxxx is a blank, then stop the loop (if this part is too hard I can just specify the number of loops required as I would know the information before running the code by counting the rows)
end loop
Is there anyone that can guide me in the right direction
So far I only know how to do the run chrome and paste and close tab part.
Thanks for your help
Re: reading CSV cells and pasting it into chrome browser
Code: Select all
file = %A_ScriptDir%\test.csv
If !FileExist(file) {
MsgBox, 48, Error, File not found. Aborting.`n`n%file%
Return
} Else FileRead, ttext, %file%
If !WinExist(wTitle := "ahk_exe chrome.exe") {
Run, chrome.exe
WinWaitActive, %wTitle%,, 10
If ErrorLevel {
MsgBox, 48, Error, An error occurred while waiting for Chrome. Aborting.
Return
}
} Else WinActivate
Loop, Read, %file%
{ Loop, Parse, A_LoopReadLine, CSV
{ If (A_Index < 23)
Continue
If (A_LoopField = "")
Return
Send %A_LoopField%^w
Sleep, 100
Break
}
}
Re: reading CSV cells and pasting it into chrome browser
Hey sorry to bring this up again,
I did come across one issue that is affecting me running this code.
You know how the code is currently designed to stop when it detects a blank cell.
Is it possible for the code to start to run and if it detects a "0" in that column it reads to simply skip over all "0" cells until it hits a populated cell, then run the code and stop again when it hits the blank cell again like it currently does.
The reason being is I have thousands of cells of rows and I need to run the code in batches. So I would delete the first couple hundred cells and replace it with the number 1, leaving a few hundred populated that I need to run, then delete the rest of the cells so it only runs it in that section for that period, if that makes sense.
Just not sure how to do the if = 1 then skip to next row part.
Thank you
I did come across one issue that is affecting me running this code.
You know how the code is currently designed to stop when it detects a blank cell.
Is it possible for the code to start to run and if it detects a "0" in that column it reads to simply skip over all "0" cells until it hits a populated cell, then run the code and stop again when it hits the blank cell again like it currently does.
The reason being is I have thousands of cells of rows and I need to run the code in batches. So I would delete the first couple hundred cells and replace it with the number 1, leaving a few hundred populated that I need to run, then delete the rest of the cells so it only runs it in that section for that period, if that makes sense.
Just not sure how to do the if = 1 then skip to next row part.
Thank you
Re: reading CSV cells and pasting it into chrome browser
Maybe like this:
Code: Select all
started := False
Loop, Read, %file%
{ Loop, Parse, A_LoopReadLine, CSV
{ If (A_Index != 23)
Continue
If A_LoopField {
Send %A_LoopField%^w
Sleep, 100
started := True
} Else If started
Return
}
}
Re: reading CSV cells and pasting it into chrome browser
Hey, thanks for your reply.
I don't understand where it reads the part about it being a "0" and skipping to the next line:
This is the code I have:
Alternatively can we not assign a 1 to skip that row and a 0 to end the loop? I could easily just add 1's and 0's where they belong for example.
I don't understand where it reads the part about it being a "0" and skipping to the next line:
This is the code I have:
Code: Select all
file = C:\test.csv
If !FileExist(file) {
MsgBox, 48, Error, File not found. Aborting.`n`n%file%
Return
} Else FileRead, ttext, %file%
If !WinExist(wTitle := "ahk_exe chrome.exe") {
Run, chrome.exe
WinWaitActive, %wTitle%,, 5
sleep, 1500
} Else WinActivate
WinActivate
Loop, Read, %file%
{ Loop, Parse, A_LoopReadLine, CSV
{ If (A_Index < 23)
Continue
If (A_LoopField = "")
Return
Send ^t
Sleep, 500
Send %A_LoopField%
Sleep, 1000
Send {enter}
Sleep, 4000
Send ^w
Break
}
}
Re: reading CSV cells and pasting it into chrome browser
You tried my script?
Re: reading CSV cells and pasting it into chrome browser
wow that worked, took a while to integrate it into my script but also suprised there was no "0" anywhere in the script yet it knew the interpret only that number. well shows how much i know, thanks a lot for your help with this!