Jump to content

Which would be a better way to approach this?


tgnd
 Share

Recommended Posts

I'm very much a newb when it comes to writing scripts but I've created a few over the years to make some repetitive tasks that I do easier. I'm planning on one now and ma not sure what the most efficient way to go about it would be and wanted to ask for some advice before I got in too deep.

The task I have is to populate a form with a randomly requested subset out of a list of about 30 values. Right now I've been doing this manually by ctrl+tab over to excel, arrowing up or down to the value I need, copy the item, switching back to my form and pasting in the value, then tab over to the next form field and lather, rinse, repeat. I do this many many times a day and it's getting very tedious.

There are 2 ways I can think of to approch this task. The first is to have my script read a text file that contains all the values into an array, then have a simple reference open beside my form, numbering each line item. Then I could enter a number into an input prompt and the script would paste the value for that line item into the form, tab over to the next field and pop up a prompt box again, waiting for the next number.

The other way would be similar, but instead of having the file loaded into an array beforehand, I'd enter a number, have the script access the file, read that line item, copy it and paste into the form, accessing the file for each item and only reading that line.

The list of values will be mostly static but may eventually have items added to it or removed as need dictates.

I'm assuming that the first one would be the better way to approach this task, but I'm not sure if there are any advantages to the other approach that would make it better. Also, while I know how to paste and what not, this will be my first attempt at reading a file and getting data from there, so any nudges in the right direction for that would be fantastic.

Link to comment
Share on other sites

"populate a form" What type of form, a web form, a standard windows gui ?

If your data is already stores in exel then there is a great excel UDF you could try to use for collect the data (Transparently I think)

If the target form is web based then the IE UDF would be Ideal to deliver the data, if not then there are numerous other ways to populate it, not least a multitude of native AutoIt functions.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Right now the data set I have looks something like this (obviously fake data): http://prntscr.com/3iooo

I'm working with a web form that then asks for a random set of the 30 or so items in my data set. So the form might look like this:

Dog: ______

Lion: ______

Sheep: ______

[submit]

My thinking given my very limited programming experience was that I could easily create a txt file that contained just column C, then have the script read it into an array. Then I'd set up my screen so at least columns A and B of the spreadsheet are visible and the browser takes up the rest of the space and run the script. It would pop up a box asking me to enter a number, and I put in the corresponding number for the animal listed on the form. The script then pastes the appropriate array element ($input-1 in this case) and tabs over to the next space (3 tabs, there are a couple of links between each text box) before prompting me again. This lets me keep my hand on the keypad the entire time and finish what is otherwise a time consuming task of switching between windows repeatedly and copying the correct line of data in just a couple of minutes.

Like I said, my programming skills are very limited - most of my experience comes from a class on BASIC back in the early 90s. If there's a better way to do this that is simple enough for me to understand I'd love to hear it. I've actually got another data set that is about 300 lines long that is used much less frequently, and I can't even start to think of a way to deal with that to make it easier. Right now I just scroll up and down through it looking for the line I need and copy the corresponding data over. Thankfully right now atleast I don't have to use that set too often.

Edited by tgnd
Link to comment
Share on other sites

It looks like all that could easily be done transparently in lea that a second, never mind clicking away at prompts.

First thing you want to do is look at the excel UDFs and find a function to read your data sets into an array multidimensional 2d would be best (I've never used excel but I'm sure will be a func in the udf) where colum A respesents the array index, colum B ($Array[$index][0] would = Cat $Array[$index][1] would = Meow) etc.

The IE udf can read the form elements given, and set the corresponding elements to its value after you loop to the array to find it.

example, you read the webform element and it turns out to be Cow, you loop through the array until you find Cow, it turns out to be $Array[[6][0], so you set its other value to $Array[6][1].

You are going to have to look at the UDFs and try any example that accompany them.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Hmm.. so I could have the script read the form itself? There's all kinds of other text on the form in addition to the prompt for the data I'm being asked for (cat/dog/etc) ..

Here's a dumb question. I've figured out what UDFs stands for, now the question is where do I find them?

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...