Alan_Hsu Posted October 20, 2017 Share Posted October 20, 2017 Hello, I am new to autoit. I was experimenting with automating COM objects like internet explorer but I had a problem with finding elements on a website. I learned from youtube tutorials that you can find an element by using $var = .document.getElementsByTagName("text element here") but the text that I wanted to find appeared under multiple lines, like this: <p id="line1" class> <span class="oung">TEXT HERE</span> </p> <p id="line2" class> <span class="oung">TEXT HERE</span> </p> <p id="line3" class> <span class="oung">TEXT HERE</span> </p> The text in every one of them is the same, the only thing that's different is the line1 and line2. How would I find the TEXT HERE from line1 without the program finding the other ones? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 20, 2017 Moderators Share Posted October 20, 2017 Look at the _IECreate() / _IEAttach() / _IEGetObjByID / _IEGetObjBy...etc functions. Your example would look something like this pseudo code: #include <IE.au3> Global $goIE = _IECreate("some website url here") If Not IsObj($goIE) Then MsgBox(16, "Error 1", "Not an object") Exit EndIf Global $goLine1 = _IEGetObjById($goIE, "line1") If Not IsObj($goLine1) Then MsgBox(16, "Error 2", "Not an object") Exit EndIf ; get the value of the text MsgBox(64, "Value", _IEPropertyGet($goLine1, "outertext")) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Alan_Hsu Posted October 20, 2017 Author Share Posted October 20, 2017 Thank you! I've been stuck on this for hours. I have another question, since the text in the html changes sometimes, is it possible to wait until something happens, and then get the value of the text? I'd like to wait until a line appears: <span id="textIcon" class="red" style="opacity: 1;"></span> before getting the value of the text, and while it isn't there yet, the program will sleep. Is this possible? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 21, 2017 Moderators Share Posted October 21, 2017 Well, your question is open ended. Yes it's possible. Maybe something like: Global $goIE = _IECreate etc... Global $goObj Do Sleep(100) $goObj = _IEGetObjByID($goIE, "textIcon") Until IsObj($goObj) ... rest of code So just a word to the wise, do your homework, read the help file, try some code, post what doesn't work. I'm not a fan of doing the work myself Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Alan_Hsu Posted October 21, 2017 Author Share Posted October 21, 2017 Ok thanks, I will make sure to read the help file! Link to comment Share on other sites More sharing options...
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