I'm using an online translator for Spanish in which you give the verb and website gives the conjugations. The website I'm using is: http://www.spanishdict.com/conjugate/tener where "tener" means "to have" in English.
In the screenshot, you can see the present tense (5 yellow highlighted items) and the imperfects (5 blue boxes). I don't need to get the translation for "vosotros", so I didn't make any color on that row. I'm trying to get these 10 translations to be written on the output for my code. But my code is so simple (because I couldn't go into the div / tr / td):
#include <IE.au3> #include <Array.au3> Local $sSpanishWord = "tener" ;to have ;Local $sSpanishWord = "abrir" ;to open Local $oIE = _IECreate ("http://www.spanishdict.com/conjugate/" & $sSpanishWord) ;http://www.spanishdict.com/conjugate/tener ;http://www.spanishdict.com/conjugate/abrir ;== Try using _IETagNameAllGetCollection Local $oElements = _IETagNameAllGetCollection($oIE) For $oElement In $oElements If $oElement.id Then ConsoleWrite("Tagname: " & $oElement.tagname & @CRLF & "id: " & $oElement.id & @CRLF & "innerText: " & $oElement.innerText & @CRLF & @CRLF) EndIf Next ;== Try using _IETagNameGetCollection Local $sTable Local $oTableCells Local $oTableRows = _IETagNameGetCollection($oIE, "tr") For $oTableRow In $oTableRows $sTable = "" $oTableCells = _IETagNameGetCollection($oTableRow, "td") ;I don't know how to continue from here on Next I used the IE to find out the tr / td stuff, but I think I'm lost.
P.S: The verb "tener" can be difficult, because it has red letters because of irregular. The verb "abrir" can be much easier, because it's a regular verb.
I'm using the IE.au3 library to parse elements in a webpage and get their (x,y) coordinates.
Main commands I'm using are :
$oIE = _IECreate($myWebPage) $oElements = _IETagNameGetCollection($oIE, "label") $windowleft = $oIE.document.parentwindow.screenLeft $windowtop = $oIE.document.parentwindow.screenTop $oElementPosX = $windowleft + _IEfindPosX($oElement) $oElementPosY = $windowtop + _IEfindPosY($oElement) Now things become a bit tricky when i simulate a scroll in my webpage :
$oIE.document.parentwindow.scroll(0, $myScrollY) Because once this is done, the coordinates of the elements are still what they were before the scroll.
I can manage this problem by keeping track of the number of pixels I have scrolled, and compute the new "real" ($oElementPosX, $oElementPosY).
But I'm pretty sure there's a more efficient / more elegant way to do it.
What's more in some situations, when I click some controls in the webpage, the webpage adds new elements and shifts the controls below by a random number of pixel, so my workaround can't be used...
So here's my question : Is there a way to "refresh" the calculation of label coordinates ($oElementPosX, $oElementPosY) after a scroll ?
Thank you !
EDIT : I forgot to post the _IEfindPosX and _IEfindPosY functions (found somewhere on this forum) :
Func _IEfindPosX($o_object) Local $curleft = 0 Local $parent = $o_object If IsObj($parent) Then While IsObj($parent) $curleft += $parent.offsetLeft $parent = $parent.offsetParent WEnd Else Local $objx = $o_object.x If IsObj($objx) Then $curleft += $objx EndIf Return $curleft EndFunc Func _IEfindPosY($o_object) Local $curtop = 0 Local $parent = $o_object If IsObj($parent) Then While IsObj($parent) $curtop += $parent.offsetTop $parent = $parent.offsetParent WEnd Else Local $objy = $o_object.y If IsObj($objy) Then $curtop += $objy EndIf Return $curtop EndFunc
I'm trying to create an autoPop tool for AliExpress. When I get to their address page, there are a number of input fields. There are also two drop downs. One is for the country and, depending on what you select, the other dropdown appears with city names or, a standard input box is visible to add a city (See the images). So if I select "United States" the other dropdown is visible with all the states. If I select "France", the input box is visible to enter a French city. Seems cool enough but I'm really struggling trying to get this to work.
This is my test code to work all this out:
#include <MsgBoxConstants.au3> #include <IE.au3> Local $StartPos Local $oIE = _IECreate("https://shoppingcart.aliexpress.com/order/confirm_order.htm?objectId=1792065272&from=aliexpress&countryCode=US&shippingCompany=EMS&provinceCode=&cityCode=&promiseId=&itemCondition=&=556&aeOrderFrom=main_detail&skuAttr=&quantity=1") If @error Then Exit MsgBox(16, "openURL Error", @CRLF & "@error = " & @error & ", @extended = " & @extended) ;If $bVerbose == true Then MsgBox(0, "openURL", "IECreate Object Created") ;Get the Collections $oInputs = _IETagNameGetCollection($oIE, "input"); Input Fields $oSelects = _IETagNameGetCollection($oIE, "select"); Select Fields ;Loop through the Selects For $oSelect In $oSelects If $oSelect.name = "country" Then _IEFormElementOptionSelect($oSelect, "France", 1, "byText",1) Next ;Loop through the inputs For $oInput In $oInputs If $oInput.name = "email" Then $oInput.Value = "email@example.com" If $oInput.name = "contactPerson" Then $oInput.Value = "My Full Name" If $oInput.name = "address" Then $oInput.Value = "123 Anystreet" If $oInput.name = "address2" Then $oInput.Value = "NA" If $oInput.name = "province" Then MsgBox(0, "","$oInput.name = " & $oInput.name &@CRLF &"$oInput.style = " & $oInput.style &@CRLF &"$oInput.type = " & $oInput.type&@CRLF &"$oInput.maxLength = " & $oInput.maxlength) $oInput.Value = "FrenchyLand" EndIf If $oInput.name = "city" Then $oInput.Value = "AnyTown" If $oInput.name = "zip" Then $oInput.Value = "12345" If $oInput.name = "mobileNo" Then $oInput.Value = "1-415-555-1212" Next So I open the page on AliExpress and get an "input" collection and a "select" Collection
I first loop through the Selects until I find "country" and then select "France"
I then loop through all the inputs and put the information in the correct inputs.
When the country is one that AliExpress knows the states or provinces for, they swap Styles between the input box and the dropdown to either "display: inline-block;" or "display: none;" which hides one, or the other (See the AliExpDOM Image).
Problem #1: When I use the "_IEFormElementOptionSelect($oSelect, "France", 1, "byText",1)" To make the dropdown selection, It selects it but does not invoke the widget to change the second dropdown to an input box.
Problem #2: I thought a possible solution would be to read the Style of the input box and based on the value, either place text in the input box or go to the dropdown and make a selection. I can't seem to read the Style attribute from the collection ie: $oInput.style returns nothing.
Any help here would be greatly appreciated. If I figure out a solution before and answer here, I will publish it here for anyone else who might be struggling with these kinds of things
I got the need of crawling all the label tag contained within a div element, and then inspecting one by one looking for a specified content
Local $reportForm=_IEFormGetObjByName($oIE,"ui_form") If @error Then ConsoleWrite('_IEFormGetObjByName @error = ' & @error & ' @extended = ' & @extended & @CRLF) EndIf Local $divTagSites = _IEGetObjById($reportForm, "divElementId") If @error Then ConsoleWrite('_IEGetObjById for @error = ' & @error & ' @extended = ' & @extended & @CRLF) EndIf Local $divLabels = _IETagNameGetCollection($divTagSites, "label") If @error Then ConsoleWrite('_IETagNameGetCollection for label @error = ' & @error & ' @extended = ' & @extended & @CRLF) EndIf ConsoleWrite('_IETagNameGetCollection @extended = ' & @extended & @CRLF) For $divLabel In $divLabels ConsoleWrite($divLabel.for & @CRLF) Next the html looks like the following
What I miss is the step: accessing the text inside the label tag.
PS: searching through the forum I found out only method based on analyzing the whole html page.
Guys need help, why second _IELinkClickByText not working ? First click is ok, but second click is problem.
Warning from function _IELinkClickByText, $_IESTATUS_NoMatch but text is correct.
First click, changed browser adress is this a problem ?
Thanks for answer.
Func zmazanie() $oIE = _IECreate("http://www.bazos.sk/moje-inzeraty.php/") $cozmazat = GUICtrlRead($nadpis) Sleep (2000) _IELinkClickByText($oIE, $cozmazat) Sleep (2000) _IELinkClickByText($oIE, "Zmazať/ Editovať/ Topovať") EndFunc