Faalamva Posted June 11, 2014 Posted June 11, 2014 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 ) 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 !
jdelaney Posted June 11, 2014 Posted June 11, 2014 (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 June 11, 2014 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.
Faalamva Posted June 11, 2014 Author Posted June 11, 2014 Thank you, I will try that. Does it also work with other browsers (Firefox...) ?
jdelaney Posted June 11, 2014 Posted June 11, 2014 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.
Faalamva Posted June 11, 2014 Author Posted June 11, 2014 I tested your example and it works just fine. I may be able to adapt my own programs to use it, thank you . (I will also check ff.au3 for comparison's sake).
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now