Jump to content
Sign in to follow this  
aanons

Automated web form Do/until loop using increasing integer?

Recommended Posts

aanons

Hello:

I am quite new to autoIT with very rusty web development skills. I was wondering if someone could just point me in the right direction. I know what I want, I just do not know the terms to search for in order to learn how to code the script that I want.

So far I have been able to use autoIT to go to successfully complete the following function:

1. Open IE and go to a specific web page.
2. Automatically type a specified number into the text field
3. And submit the form.

I want to create a do/until loop that will automate entering in a numeric variable, increasing by 1 into the text field until it finds a number that will generate a certain error message.

In case I am not explaining thoroughly enough this is what I want it to look like:

1. Open IE and go to a specific web page.
2. Automatically enter a numeric variable (ie 8675309) into the text field
3. And submit the form.
4. If the form does not generate the certain error message I am looking for, I want autoIT to move on to the next integer (ie 8675310) and so on until the message I am looking for is accomplished.

Thank you for your help!

-AA

Share this post


Link to post
Share on other sites
JLogan3o13

@aanons welcome to the forum. As you mention you have the first three steps already done, you would simply need a For Loop wrapped around steps 2 and 3 to accomplish what you are after. You can look up Loops in the help file, and if you're stuck please post your code so we can see what you're doing. Also, to forestall any issues as you progress, please ensure you are familiar with the forum rules and not trying to A: bypass security measures like a CAPTCHA or B: doing something against the site's EULA or TOS.


√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
aanons

No theres no captcha or anything like that. I will see if I can post my code. It is very short and simple.

Share this post


Link to post
Share on other sites
aanons

#include <IE.au3>

Call ("testem")

Func testem ()
   Global $oIE = _IECreate ("http://websitenamehere.com")


Local  $oForm = _IEFormGetObjByName($oIE, "cForm")
Local $cCoField = _IEGetObjByName($oIE,"cCoField")

_IEFormElementSetValue ($cCoField,"8675309")

Sleep(500)

_IEFormSubmit($oForm)

EndFunc

Spoiler

 

 

Share this post


Link to post
Share on other sites
aanons

I dont know how to make the loop and change the variable to = +1 and I dont know how to extend the loop until I get the specific error code.

Share this post


Link to post
Share on other sites
JLogan3o13

Create an array of all the numbers you want to try

Local $aNumbers[3] = [<first_number>,<second_number>,<third_number>}

Then loop through the array (again, look at the help file for For...In...Next, it has an almost perfect example for your needs). The last three lines of your function should be all you need to loop through, set the value, pause if you need, then submit the form. If, after submitting the form, the page changes, then look at _IENavigate to get you back to the right page.


√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
aanons

How would I insert that into my current code? I know that my input is static right now 

And do I have to insert each number and fill it into the <first_number> <second_number> sections?

And how would  I stop the script once I get to the result I want? Im trying to wrap my head around this.

 

Share this post


Link to post
Share on other sites
aanons

Hey, I'm sorry. For some reason it didn't show me the last part of your post. I will check that out thank you.

Share this post


Link to post
Share on other sites
gruntydatsun

Hey!! You just doxed Jenny :)

Share this post


Link to post
Share on other sites
gruntydatsun

I'm just making fun of the whole liberal doxing thing by saying you doxed the imaginary Jenny by publishing her phone number 8675309... damn now i did it too.  Sigh.... so many micro aggressions.... my privilege is showing ;)

Share this post


Link to post
Share on other sites
aanons

Well I figured everything else out except how to make the variable that will be input into the text box increase by one. Sadly that is the most important part lol.

Share this post


Link to post
Share on other sites
gruntydatsun
#include <IE.au3>
Global $oIE = _IECreate ("http://websitenamehere.com")
Global  $oForm = _IEFormGetObjByName($oIE, "cForm")
Global $cCoField = _IEGetObjByName($oIE,"cCoField")
Global $counter = 8675309

Call ("testem")

Func testem ()
    While 1
        _IEFormElementSetValue ($cCoField,"8675309")
        Sleep(500)
        _IEFormSubmit($oForm)
            ;test for whatever you're testing for here
            ;if you find it then
            ExitLoop
            ;if you don't find it
            $counter+=1
    Wend
EndFunc

 

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
Sign in to follow this  

×