Jump to content

Recommended Posts

Good morning,

Apologies if this thread already exists or I've completely missed the answer in a similar thread. 

I'm new to Autoit since yesterday, albeit that I've had an account for 3 years, I'm only starting to get into it. I am trying to create a script which will read my CSV row by row and create a variable per cell on that row. In my job I'm going to need to fill out a webform 100 times over so I would like to input each variable into my chosen field on this webform and repeat.

I've been playing with AutoIT and this is what I've done so far, am I on the right track? I was thinking of using the StringSplit functions but I am a bit clueless to be honest. Any help would be Great to get me started.

#include <file.au3>
#include <FileConstants.au3>
#include <array.au3>

_BrowseForFile()

Global $aOutput, $FilePath

_FileReadToArray ($FilePath,$aOutput,4,",")
_ArrayDisplay($aOutput)

Func _BrowseForFile() ;Sets $FilePath
    global $FilePath=FileOpenDialog("Browse for CSV",@DesktopDir,"csv files (*.csv)",$FD_MULTISELECT + $FD_FILEMUSTEXIST)
EndFunc

 

Edited by Churchy112

Share this post


Link to post
Share on other sites

Yes, I think you are on the right track.
I suggest to drop function _BrowseForFile as a single line function is a lot of overhead.
As _FileReadToArray can handle CSV files now you've got a 2D array.
You would then need two loops to process each line (outer loop) and each cell in the row (inner loop).

Which browser do you use to fill the web form?

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-07-31 - Version 1.4.12.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thanks for your suggestions.

I'll be using Chrome but I can switch to any if more compatible. I'm hoping to apply this to other uses such as iTunes account creation. I work with schools and for every Apple device in school I need to create an Apple ID for it, so thats on average 60 Apple IDs per school :(.

Would you mind giving me a example of the loops that I could have a play with?

Share this post


Link to post
Share on other sites

I'm not sure you need two loops because I assume you process all fields of a reacord (row) and write them to a single web page.
So it could look like:

For $i = 1 to $aOutput[0][0]
    ; Write the first field to the web page: $aOutput[$i][0]
    ; Write the second field to the web page: $aOutput[$i][1]
    ; ...
Next

How to write the data to the web page depends on the browser you use. Easiest is IE (a UDF comes with AutoIt), more complex gets FF etc.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2019-07-31 - Version 1.4.12.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2019-07-24 - Version 1.3.6.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (NEW 2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites

I'm not sure you need two loops because I assume you process all fields of a reacord (row) and write them to a single web page.
So it could look like:

For $i = 1 to $aOutput[0][0]
    ; Write the first field to the web page: $aOutput[$i][0]
    ; Write the second field to the web page: $aOutput[$i][1]
    ; ...
Next

How to write the data to the web page depends on the browser you use. Easiest is IE (a UDF comes with AutoIt), more complex gets FF etc.

Thanks! I just need to have a play at the emulation functions and I'll give it a go tomorrow with iTunes form at my school. 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Similar Content

    • By ThePoro
      I have this code 
      It gets variable input from GUI to run a loop and write to a text file then copy it to the clipboard
      But the thing is code runs normally with $px and $py <100 or both > 100 or with $px <10 and $py>100 but It's wrong with 10<$px <100 and $py >100
      Can anyone tell me why?
      Func clone() Local $px = GUICtrlRead($input1) Local $py = GUICtrlRead($input2) Local $temp = "C:\temp.csv" FileDelete($temp) While $px <= $py Local $name = "P"&$px FileWrite($temp, " & $name & ""& @CRLF) $px+= 1 WEnd $a=FileRead($temp) ClipPut($a) MsgBox($MB_ICONINFORMATION,"","Copied to Clipboard") EndFunc  
    • By Blueman
      Hey Guys,
      Maybe you can help me with something small.
      It is not terrible but it slows down my script and after a while even crash the script.

      First i explain what i have;
      I have a GUI with a lot of GUICtrlCreateInput controls, lets say 600 pieces.
      All the controls are hidden when the GUI is displayed, i have 3 buttons attached to 200 pieces each.
      When i press button-1 the first 200 controls are showed,
      When i press button-2 the first 200 controls are hidden and the next 200 controls are showed,
      etc, etc.
      This is working perfectly but after a while the GUI is getting slower and slower.
      After a while the controls aren't responding anymore and the script crashes.
      When i compile the script to 64-Bits version the speed is a lot better but you can still see the script slowing down each time i use the buttons.
      I think there has to be a buffer somewhere that is filling each time i show and hide the controls, but how can i clear that buffer without restarting the script?
      Deleting and re-creating the controls didn't help, deleting the entire gui (and controls) and re-creating it didn't help also.
      The only thing that is working is restarting the script.

      Thanks guys!

      PS: If you need a working example i can add it to this topic, just let me know. It is not rocket science, i just create the controls and show/hide them with a while loop and 3 buttons.
       
    • By MadhaN
      Hi all,
      I have a csv file as below, I wand to find srno from csv and send corresponding ip and pass to commend cmd prompt. 
      Please guide me to create script .
      srno,name,ip,pass
      1,name1,ip1,pass1
      2,name2,ip2,pass2
       
       
       
       
    • By XinYoung
      Hello again 
      I need to click this Submit button, but it's in a lightbox and has no ID (i think) and I can't figure out a way to target it. _IEFormSubmit doesn't work.

       
      Thank you
    • By MrCheese
      hi all,
      reviewing the forum, this thread is applicable: 
       
       
      I wanted to know if there is now a better way to do this?
      In essence, I load a tab delimited txt file into an array (works well). I used tab, as some fields in the original csv contains commas.
      However, I needed autoit to manipulate this array, and output it as a csv.
      IF my array contains items with a comma, without double quotes around the field, then how best do I get a csv out of this?
      My current workaround is to filewritefromarray tab delimited, then open it in excel and save as a csv. I will need to check this to see how the address fields behave that contain a comma.
       
      Any thoughts would be appreciated.
       
×
×
  • Create New...