Creating a script that fills in form values and submits
autohotkey, html, post
Solution
You'll need AutoHotkey_L (the most recently updated version), and then you can use the COM Interface for Internet Explorer. It can even fill in the forms, and not show up on your screen.
#NoEnv
#SingleInstance Force
; Settings
path := "http://domain.tld/path/to/form.html"
; Connect to IE
wb := ComObjCreate("InternetExplorer.Application")
wb.Visible := false
; Load the page specified
Load(wb, path)
; Find the first form on the page (put 1 for the second, 2 for the third, etc.)
Form := wb.Document.forms[0]
; Fill in data and submit it
Form["login"].value := "User"
Form["password"].value := "sUp3rS3cUr3"
Form["local_id"].value := "2"
Form["submit"].click()
return
Load(wb, what) {
wb.Navigate(what)
while wb.Busy
continue
wb.Visible := true
}
You may then instruct your script to `Load` the initial page again, and then fill in more data, and submit again. Just put a `while wb.Busy` loop in there so the `php` page can finish.
Problem
I have to submit a form 1000 times to create objects for a website. They have given us access to do so, but no easy way to POST the data without using their website's form. The form has these 4 inputs: ``` Textbox name = login Textbox name = password select name = region (values from 1 to 2000) button name = submit ``` Is there any way to create a script that will select these elements in my browser and set values accordingly? I thought about using AutoHotKey, but can't find any way to select web elements and fill in their values. ``` <form method="post" autocomplete="off" action="index.php?authorized=1"> <input name="login" maxlength="12" type="text"> <input name="password" value="" maxlength="30" type="password"> <select name="local_id"> <option value="1">Washington D.C.</option> <option value="2">Chicago</option> ...(many more that i removed) </select> <input name="login_id" value="223" type="hidden"> <input name="dss" value="1" type="hidden"> <input name="action" value="createUser" type="hidden"> <input name="submit" value="Submit" type="submit"> </form> ```