Jump to content

Quick questions about ielinkclick and reading changing text


Recommended Posts

Just cant find out how to:

Click changing link. For example link is www.google.com/wmd after its clicked that wmd changes like www.google.com/lmk . So how I should click it ignoring these letters?Continen of that link is same. Btw link is on/in javascript or something. But no matter i think. I found this in russian forum (firstly translated in english ofcorse)

$OLinks = _IELinjGetCollection($oIE) ; $oIE before created ie window
For $OLinks in $OLink ; cant understand why needs this line
If (StringInStr($OLink.Innertext, "some text?")) Then ; not sure about these ones
Do something
EndIf
Next

Second, reading text from web page like "points left : 1000" That 1000 number always changes and I need to show it In my created GUI corner (I know how to do) but i dont know how to read whole line and that changing number. This is to show me how many point i have from forum. Its kinda forum when u do some activity and collect points so I just want to know fastly how much I have.

Thanks

Edited by Edgaras
Link to comment
Share on other sites

Try this; change

If (StringInStr($OLink.Innertext, "some text?")) Then

to

If StringInStr($OLink.Innertext, "some text?") Or StringInStr($OLink.Innertext, "some other text?") Then

I removed the extra set of parentheses, I don't think they're needed. But I'm usually wrong more than I'm right..

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

Yeah I spent some time on searching for it but didnt found any solution. What I need to do now is to move on onther things. Like how to read text section but cant find out how to do that. Its possible to read all text in browser window but i need just one sentence... Cant find info about it too.. thats why i started learning c#

Link to comment
Share on other sites

Can't you just get the object of where the text is and then use $oText.Innertext? So the code you posted above was for the link, but isn't that what you need for just a sentence?

Link to comment
Share on other sites

I used two functions _StringBetween and _INetGetSource here, but this can probably be done some other way.

#include <String.au3>
#include <INet.au3>
Local $Array = _StringBetween(_INetGetSource('http://www.w3schools.com/html/tryit.asp?filename=tryhtml_intro'), 'type="submit" value="', '&raquo;" onclick=')
ConsoleWrite(@LF & $Array[0] & @LF & @LF)

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to comment
Share on other sites

I find that taking the body text and using lots of string manipulation is over complicated. Another thing you could do would be to get the tag name of the button, which would be "input". well here is how you could retrieve the text in the button:

#include <IE.au3>

Global $oBrowser = _IECreate("http://www.w3schools.com/html/tryit.asp?filename=tryhtml_intro"); open IE

Global $oButton = _IETagNameGetCollection($oBrowser, "input", 0); get the object of the button

MsgBox(0,'', $oButton.value); display the data in the value tag of our object, which is the text we wanted to see

In your case, you can find what instance your text would be under the tag name 'u', and access its "innertext" tag or whatever.

Its difficult/impossible to find right string in whole window.

Eh? Can't you just inspect the element? If you are using google chrome, right-click the element and select "Inspect Element". Otherwise, find an add-on (such as firebug) and install that. I think IE has a built in DOM inspector thing as well.

Edit: but then i would recommend just getting its tag name and stuff, not finding strings around it to use with _StringBetween or something.

Edited by lark
Link to comment
Share on other sites

No no no I have firebug and always using it and bunch of firefox addons to inspect elements. I want to get text and place it to gui or somewhere else.

_IETagNameGetCollection($oBrowser, "input" it will take all inputs, right? So it works only where is one button...

Link to comment
Share on other sites

No no no I have firebug and always using it and bunch of firefox addons to inspect elements

I must have misinterpreted you, I apologize.

No no no I have firebug and always using it and bunch of firefox addons to inspect elements

Yes, it takes all inputs. But if you look at the third parameter of _IETagNameGetCollection, you specify the index of the element. So if it were the third input on the webpage, then you could specify the index to be 2.

Also, suppose there were like 38 or so inputs before it. But then, maybe there is a form (or some other less common tag) right before your element. Instead of counting how many elements there are before the one you want, you could make use of the anarchy structure of the DOM by taking that form. Then your element might be only the 5th or so input after that form. Here is an example that retrieves the latest post of the AutoIt General Help and Support forum.

#include <IE.au3>

Global $oBrowser = _IECreate("http://www.autoitscript.com/forum/")

Global $oHighTable = _IETagNameGetCollection($oBrowser, "table", 1)

Global $oMidTR = _IETagNameGetCollection($oHighTable, "tr", 1)

Global $oLowTD = _IETagNameGetCollection($oMidTR, "td", 3)

Global $oA = _IETagNameGetCollection($oLowTD, "a", 1)

ConsoleWrite("Latest Post in General Help and Support: " & $oA.title & @CRLF)

So instead of counting how many elements there are with a tag name 'a', I took other elements lower in the DOM and built my way up to the element I wanted to work with.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...