Sign in to follow this  
Followers 0
Faalamva

Get control position and/or automatically fill in a web form

5 posts in this topic

Hi,

Let's take a simple example to make things simpler about my concern :

From this webpage : http://www.oxford.gov.uk/PageRender/decDi/Telluswhatyouthinkform.htm

My goal is to automatically fill in the web form.

I've managed to do it successfully by checking the controls coordinates on a graphic editor, then moving the mouse over these controls (MouseClick), and then sending the desired values (Send).

However, the webpage may be updated, and the controls position may change, making my program useless until I update the new controls coordinates.

Some pages are updated frequently so my solution isn't really viable.

So, I'm looking for a way to get dynamically the controls coordinates on this webpage, assuming only the controls positions or their style would change, but not the label names.

Maybe there's a simple way, rather than moving the mouse to the coordinates, to directly "send" the value to a control using its name ?

My code so far (that doesn't work :sweating: ) is :

ShellExecute("http://www.oxford.gov.uk/PageRender/decDi/Telluswhatyouthinkform.htm")
Local $hWnd = WinWait("Oxford City Council - Tell us what you think", "", 10)
MsgBox($MB_SYSTEMMODAL, "", $hWnd)
Local $aPos = ControlGetPos($hWnd, "Your name:", "<I don't know what to put here !!>")
MsgBox($MB_SYSTEMMODAL, "", "Position: " & $aPos[0] & ", " & $aPos[1] & @CRLF & "Size: " & $aPos[2] & ", " & $aPos[3])

Thank you for your help !

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Use _ie* functions.  Checkout the helpfile.

_IECreate

There are ways to search, and manipulate data, based on the HTML dom object (so x,y coords won't matter).

These objects are rendered by the browser, so the Control* functions won't do you much good.

Very light example:

#include <ie.au3>
$oIE = _IECreate("google.com")
$oObj = _IEGetObjByName($oIE,"q")
$oObj.focus()
_IEFormElementSetValue($oObj, "search string")

$oObj = _IEGetObjByName($oIE,"btnK")
$oObj.focus()
$oObj.click()
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Thank you, I will try that.

Does it also work with other browsers (Firefox...) ?

Share this post


Link to post
Share on other sites

Nope, you'll need to find the ff.au3 file in the Examples Forum.

Then use those.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

I tested your example and it works just fine. I may be able to adapt my own programs to use it, thank you :bye: .

(I will also check ff.au3 for comparison's sake).

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  
Followers 0