BreCalmor Posted October 27, 2008 Share Posted October 27, 2008 (edited) <DIV class=NavSelect onclick="OnOpt('newfile.asp');"> <DIV class=NavText>Text Link</DIV> </DIV>$oFrame = _IEFrameGetObjByName ($oIE, "options") _IELinkClickByText ($oFrame, "Text Link") I am trying to click on the "Text Link" in the upper html that is enclosed in a frame of the page I am trying to manipulate. The text isn't an actual HTML link as you can see, but I thought the click by text would work. I have tried the lower code, but it doesn't move the mouse to the link or click it, or anything actually. _IEDocReadHTML shows that I have the right frame and the right HTML in the frame, so the text for the text link does exist. Is there some other function I can use to do this? Maybe one that give me the coords of the text and I can move the mouse and click using the MouseClick function? Thanks, Bre Edited November 1, 2008 by BreCalmor Link to comment Share on other sites More sharing options...
Richard Robertson Posted October 27, 2008 Share Posted October 27, 2008 You'll have to find the div and fire its click event. Since it's not an anchor tag, it can't be located by _IELinkClickByText. Link to comment Share on other sites More sharing options...
BreCalmor Posted October 27, 2008 Author Share Posted October 27, 2008 You'll have to find the div and fire its click event.How do I do that if there are several div tags named "NavSelect" with the onclick event, but the div text is different?Sorry for the stupid questions.Thanks,Bre Link to comment Share on other sites More sharing options...
Richard Robertson Posted October 27, 2008 Share Posted October 27, 2008 No, it's not stupid. I'm not sure how to search by div text. At least, I don't know how to do that using the IE functions. I can whip up an XPath statement no problem but I don't know if XPath works in IE. Link to comment Share on other sites More sharing options...
BreCalmor Posted October 28, 2008 Author Share Posted October 28, 2008 (edited) No, it's not stupid.I'm not sure how to search by div text. At least, I don't know how to do that using the IE functions. I can whip up an XPath statement no problem but I don't know if XPath works in IE.What is XPath?Can I specify anything on the 'class=NavSelect' ??? Edited October 28, 2008 by BreCalmor Link to comment Share on other sites More sharing options...
Richard Robertson Posted October 28, 2008 Share Posted October 28, 2008 XPath is a system designed for navigating XML or XML similar data. It works well for HTML. I'm not quite sure what you are asking there. Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted October 28, 2008 Moderators Share Posted October 28, 2008 No, it's not stupid. I'm not sure how to search by div text. At least, I don't know how to do that using the IE functions. I can whip up an XPath statement no problem but I don't know if XPath works in IE.You can achieve it like this... #include <IE.au3> $sURL = "somewhere.com" $sSearch = "Text Link" $oIE = _IECreate($sURL) $oFrame = _IEFrameGetObjByName($oIE, "options") $oDivs = _IETagNameGetCollection($oFrame, "DIV") For $oDiv In $oDivs If _IEPropertyGet($oDiv, "InnerText") = $sSearch Then _IEAction($oDiv, "click") _IELoadWait($oIE) ExitLoop EndIf Next Link to comment Share on other sites More sharing options...
BreCalmor Posted October 29, 2008 Author Share Posted October 29, 2008 (edited) You can achieve it like this... #include <IE.au3> $sURL = "somewhere.com" $sSearch = "Text Link" $oIE = _IECreate($sURL) $oFrame = _IEFrameGetObjByName($oIE, "options") $oDivs = _IETagNameGetCollection($oFrame, "DIV") For $oDiv In $oDivs If _IEPropertyGet($oDiv, "InnerText") = $sSearch Then _IEAction($oDiv, "click") _IELoadWait($oIE) ExitLoop EndIf NextThat didn't work, the collection only had 1 record and it contained all the text in the entire frame, which has a tons of divs. I tried to narrow it down to the form, but it came up with nothing. The main DIV has an ID, should I try that and see what I get. [edit: didn't work at all...] What else can I do? Thanks, Bre Edited October 29, 2008 by BreCalmor Link to comment Share on other sites More sharing options...
BreCalmor Posted October 30, 2008 Author Share Posted October 30, 2008 Bump. I am stuck until someone can figure this out. Here is the bulk of the HTML: <DIV class=NavDiv id=NavDiv><DIV class=NavSpacer></DIV> <DIV class=NavMessage><FONT color=#ffcc00>Good Afternoon</FONT><BR><FONT color=#ffffff>Bre</FONT></DIV> <DIV class=NavSpacer style="HEIGHT: 100px"></DIV> <DIV class=NavSelect onclick="OnSentClick(this,'../link1.ASP');"> <DIV class=NavText>Text of Link1</DIV></DIV> <DIV class=NavSpacer></DIV> <DIV class=NavOption onclick="OnSentClick(this,'../link2.ASP');"> <DIV class=NavText>Text of Link2</DIV></DIV> <DIV class=NavSpacer></DIV> <DIV class=NavOption onclick="OnSentClick(this,'../link3.ASP');"> <DIV class=NavText>Text of Link3</DIV></DIV> <DIV class=NavSpacer></DIV> <DIV class=NavOption onclick="OnSentClick(this,'../link4.ASP');"> <DIV class=NavText>Text of Link4</DIV></DIV> <DIV class=NavSpacer></DIV> <DIV class=NavOption onclick=OnSentClick();> <DIV class=NavText>Text of Link5</DIV></DIV> <DIV class=NavSpacer></DIV></DIV> I want to be able to click on the links using code no matter where they are on the screen instead of using coordinates... mainly because I will use this on more than one computer and the changing screen resolutions and IE toolbars are killing me. Thanks, Bre Link to comment Share on other sites More sharing options...
Richard Robertson Posted October 30, 2008 Share Posted October 30, 2008 (edited) Well, if you really wanted to, you could run a regular expression on the whole block of text. I'm feeling a little depressed right now but if you know anything about regular expressions you can start on it yourself.Actually, I have a question. Is that a copy and paste of the source? If so, that's a little questionable because of the missing "" around things like the class names. Edited October 30, 2008 by Richard Robertson Link to comment Share on other sites More sharing options...
BreCalmor Posted October 30, 2008 Author Share Posted October 30, 2008 Well, if you really wanted to, you could run a regular expression on the whole block of text. I'm feeling a little depressed right now but if you know anything about regular expressions you can start on it yourself.Ok, so I have a rough idea on regular expressions, but once I do that, what does it matter... I can't use click on text, it doesn't work... Link to comment Share on other sites More sharing options...
Richard Robertson Posted October 30, 2008 Share Posted October 30, 2008 I wasn't going to say to click anything. I was suggesting you just analyze that block of text and pull out the links you want. That way you can just navigate to them instead. Link to comment Share on other sites More sharing options...
BreCalmor Posted October 31, 2008 Author Share Posted October 31, 2008 (edited) I wasn't going to say to click anything. I was suggesting you just analyze that block of text and pull out the links you want. That way you can just navigate to them instead.Unfortunately, the links are not hard links, they are onclick events within DIV tags. I really am at a loss. All I am doing now is clicking at certain points on the screen [i.e. MouseClick ("left", 100/1280*@DesktopWidth, 305/1024*@DesktopHeight)]. Sorry if this seems simple, but I am having no luck. Edited October 31, 2008 by BreCalmor Link to comment Share on other sites More sharing options...
Richard Robertson Posted October 31, 2008 Share Posted October 31, 2008 That's why I was saying you would parse the physical text in the source using a regular expression. You could read for the onclick="whatever" and use the whatever. Link to comment Share on other sites More sharing options...
BreCalmor Posted October 31, 2008 Author Share Posted October 31, 2008 (edited) That's why I was saying you would parse the physical text in the source using a regular expression. You could read for the onclick="whatever" and use the whatever.I understand what your saying, but the _IEAction uses an element object, what function would I use to 'click' in your example? I know what the code is, it doesn't change. Edited October 31, 2008 by BreCalmor Link to comment Share on other sites More sharing options...
Richard Robertson Posted October 31, 2008 Share Posted October 31, 2008 ~sigh~ No. You use the Navagate function to go to the url that you copy out of the text. Link to comment Share on other sites More sharing options...
BreCalmor Posted October 31, 2008 Author Share Posted October 31, 2008 ~sigh~No. You use the Navagate function to go to the url that you copy out of the text.Nope, won't work. I already tried that with hard coded links. The website restricts being able to do that. You can't even use F5 to refresh. You have to log back in and start all over.That is why I need to use the mouse to click on the link, its just been hard to find a way to do that without just clicking on a location. I may just have to figure out the screen and calculate the location of the link on the screen based on the screen dimensions and the height of the visible toolbars, etc...Thanks,Bre Link to comment Share on other sites More sharing options...
Richard Robertson Posted November 1, 2008 Share Posted November 1, 2008 What is the website? Link to comment Share on other sites More sharing options...
DaleHohm Posted November 1, 2008 Share Posted November 1, 2008 I've made a small change to big_daddy's code (adding a String function). Give it a try and see if it doesn't work for you... Dale #include <IE.au3> $sURL = "somewhere.com" $sSearch = "Text Link" $oIE = _IECreate($sURL) $oFrame = _IEFrameGetObjByName($oIE, "options") $oDivs = _IETagNameGetCollection($oFrame, "DIV") For $oDiv In $oDivs If String(_IEPropertyGet($oDiv, "InnerText")) = $sSearch Then _IEAction($oDiv, "click") _IELoadWait($oIE) ExitLoop EndIf Next Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
BreCalmor Posted November 1, 2008 Author Share Posted November 1, 2008 (edited) What is the website?It's a site you have to log in to, so you won't be able to get to it. I've made a small change to big_daddy's code (adding a String function). Give it a try and see if it doesn't work for you... Dale #include <IE.au3> $sURL = "somewhere.com" $sSearch = "Text Link" $oIE = _IECreate($sURL) $oFrame = _IEFrameGetObjByName($oIE, "options") $oDivs = _IETagNameGetCollection($oFrame, "DIV") For $oDiv In $oDivs If String(_IEPropertyGet($oDiv, "InnerText")) = $sSearch Then _IEAction($oDiv, "click") _IELoadWait($oIE) ExitLoop EndIf Nextok, so I tried your string thing... it did work... THANK YOU !! Bre Edited November 1, 2008 by BreCalmor 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