AutoHotkey Community

It is currently May 27th, 2012, 7:17 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: March 28th, 2006, 6:31 pm 
Hello, everyone help on this forum is top notch! I have a web site that I need to paste text from a CSV file into form fields one line at a time. I can do 10 lines per page then need to submit the form. The CSV file is very simple; it looks like this:

name1
name2
name3
etc

I have code below that I use to read the file line by line and then paste it into the web form and submit. (I'm sure someone could figure out of to accomplish with I wrote in a loop) However, I need to remove the 10 lines I just pasted into the form so I can run the script again. I've seen functions that can manipulate lists but I have not been successful in adapting them to my situation.


Code:
#SingleInstance force

;paste function
^1::
Send, {TAB}
Send, {TAB}
Send, {TAB}

FileReadline, OutputVar, names.csv, 1
Send, %outputvar%
Send, {TAB}
FileReadline, OutputVar, names.csv, 2
Send, %outputvar%
Send, {TAB}
FileReadline, OutputVar, names.csv, 3
Send, %outputvar%
Send, {TAB}
FileReadline, OutputVar, names.csv, 4
Send, %outputvar%
Send, {TAB}
FileReadline, OutputVar, names.csv, 5
Send, %outputvar%
Send, {TAB}
FileReadline, OutputVar, names.csv, 6
Send, %outputvar%
Send, {TAB}
FileReadline, OutputVar, names.csv, 7
Send, %outputvar%
Send, {TAB}
FileReadline, OutputVar, names.csv, 8
Send, %outputvar%
Send, {TAB}
FileReadline, OutputVar, names.csv, 9
Send, %outputvar%
Send, {TAB}
FileReadline, OutputVar, names.csv, 10
Send, %outputvar%

Send, {TAB}
Send, {ENTER}


I would like to have a script that reads a line, pasts the line in, removes the line from the CSV file, then pasts the next line in 10 times. Any help appriciated.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 28th, 2006, 9:43 pm 
Code:
#SingleInstance, Force

^1::
Send, {TAB 3}
Loop, 10
{
   FileReadline, OutputVar, names.csv, %A_Index%
   Send, %outputvar% {TAB}
   }
Send, {ENTER}
Return
Quote:
However, I need to remove the 10 lines I just pasted into the form so I can run the script again
:?:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 28th, 2006, 10:12 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
Code:
#SingleInstance, Force

currentLineNb = 0
; I suppose the file isn't huge (less than computer's memory...)
FileRead csvLines, names.csv

^1::
   linesLength = 0
   Send {TAB 3}
   Loop Parse, csvLines, `r`n
   {
      Send, %A_LoopField%{TAB}
      linesLength += StrLen(A_LoopField + 1) ; Or +2 if CR+LF
      currentLineNb++
      If (Mod(currentLineNb, 10) = 0)
         Break
   }
   Send {ENTER}
   ; Remove the part already read and sent
   StringTrimLeft csvLine, csvLine, linesLength
Return

Untested, you may need to adjust a value here and there.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 28th, 2006, 10:19 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Dear Greg P, :)

Take a look at this Post where I open a file delete all the contents and save it, effectively emptying the file.

Likewise, you may open the your CSV file in an editor,

send +{End} Shift & End to select a line

send {CTRL UP}x{CTRL DOWN} to Cut the line

and activate the window you want to paste

and paste it...

Loop this process for 10 times!.

Regards, :)

_________________
URLGet - Internet Explorer based Downloader
StartEx - Portable Shortcut Link


Report this post
Top
 Profile  
Reply with quote  
PostPosted: March 29th, 2006, 5:41 am 
Offline

Joined: April 5th, 2005, 10:50 pm
Posts: 133
Greg P wrote:
I have a web site that I need to paste text from a CSV file into form fields one line at a time. I can do 10 lines per page then need to submit the form.
Greg P wrote:
However, I need to remove the 10 lines I just pasted into the form so I can run the script again.
I think you'll have to wait after pressing the submit button for the new form to be loaded and then the next 10 names could be send .. if this is the case then i don't think you need to delete the data .. just try the next code and maybe you can edit it to suit your needs
Code:
MaxFields=10

^F1::
 Send {TAB 3}
 Loop, read, names.csv
 {
  Send, %A_LoopReadLine% {TAB}
  If (A_index=MaxFields)
  {
   Send, {TAB}{Enter}
   MaxFields:= MaxFields+10
   Pause
   Send {ctrl}+{F2}
  }      
 }
Return

^F2::
 Pause
Return

^F3::
  ExitApp
Return
Here's how does it work:
- Use Ctrl+F1 to start sending the data to the form (it'll send 10 and then pause) waiting for the next form to be loaded depending on your connection speed and the site
- When a new page is ready Just Use Ctrl+F2 to end the pause and send the next 10 and then pause again ... and so on
- Use Ctrl+F3 to exit the script when all done!

I hope that what you need..!

_________________
MYYM
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Exabot [Bot], oldbrother, sjc1000 and 70 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group