Neo Posted May 3, 2008 Share Posted May 3, 2008 (edited) Hello everyone,I have been working on a script that with the help of Master DaleHohm was able to progress quite well.However, I am stuck at trying to click the Properties link (javascript , i.e. java script:UL(62,17277)) corresponding to the Account Name (javascript , i.e. java script:UL(21,17277)).The links are similar as they just have a different beginning (62 for properties, 21 for account name).Would there be a way to find the user by text (Something maybe similar to _IELinkClickByText($oFrameBody, "USERNAME", 0) and then changing the link to access the corresponding Properties text ?As of now, I can only manage to click it by using mouse movements which my goal is to eliminate completely. See the picture for details and if further information is needed, let me know.Any and all help will be greatly appreciated. Thanks in advance. Edited May 17, 2008 by Neo Link to comment Share on other sites More sharing options...
aGorilla Posted May 3, 2008 Share Posted May 3, 2008 I recently had to do something similar. You can use _IELinkGetCollection($oIE) to get an array of all of the links. Then loop through them, and display them. Find out which one you want, then you can change your code to click it by index with something like: IEClick($oIE, _IELinkGetCollection($oIE, 2)) Search AutoItScript.com via Google Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted May 3, 2008 Share Posted May 3, 2008 Use _IELinkGetCollection, do a For In loop, and use .href on the end. Check for what you need if it is then add a .click on the end , simple. Try it out if you need an actual example I can help you out. Link to comment Share on other sites More sharing options...
Neo Posted May 3, 2008 Author Share Posted May 3, 2008 (edited) Sweet!! Thanks a lot. I will try this right now. I am wondering also would there be a way to just find a text in an IE page without using the CTRL+F to display the search function ? I am not very good in autoit..yet. @Thatsgreat2345: Is it close to something like this ? #include <IE.au3> $oIE =_IECreate ("http://sports.espn.go.com/espnradio/podcast/archive?id=2445552") $oLinks = _IELinkGetCollection($oIE) For $oLink In $oLinks If StringInStr($oLink.href, ".mp3") Then ConsoleWrite($oLink.href & @LF) _IENavigate($oIE, $oLink.href) ExitLoop EndIf Next If not, an example would be awesome. Meanwhile, I will try things with your and aGorilla's recommendations. Thanks a lot for the hyper fast answers Edited May 10, 2008 by Neo Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted May 4, 2008 Share Posted May 4, 2008 If you are trying to download it then something like this. #include <IE.au3> $oIE =_IECreate ("http://sports.espn.go.com/espnradio/podcast/archive?id=2445552") $oLinks = _IELinkGetCollection($oIE) For $oLink In $oLinks $sLink = $oLink.href If StringInStr($sLink, ".mp3") Then $sText = StringSplit($sLink,'/') InetGet($sLink,$sText[UBound($sText) - 1]) ExitLoop EndIf Next Link to comment Share on other sites More sharing options...
Neo Posted May 6, 2008 Author Share Posted May 6, 2008 (edited) What I actually need is to access the "Properties" text for the correct person (one that is taken from an excel spreadsheet). I managed to extract all the links from the page. I have the below code now:$oIE = _IEAttach("InForm") $oFrameC = _IEFrameGetObjByName($oIE, "C") $oFrameBody = _IEFrameGetObjByName($oFrameC, "Body") $oTable = _IETableGetCollection($oFrameBody, 0) $oLinks = _IELinkGetCollection($oFrameBody) For $oLink In $oLinks ConsoleWrite($oLink.href & @LF) NextBut what I need to do is actually to find the name of the user that I take from Excel in the list of users. Then I will need to access the Properties link (i.e. java script:UL(62,34784)) that corresponds to the username (java script:UL(21,34784)). The links and some examples of the usernames can be found in the screenshot.Thank you very much Edited May 10, 2008 by Neo Link to comment Share on other sites More sharing options...
aGorilla Posted May 6, 2008 Share Posted May 6, 2008 You can use $oLink.innerHTML to read the usernames. So check for that in your loop, then do some string parsing on $oLink.href to get the user 'id'. Hope that helps. Search AutoItScript.com via Google Link to comment Share on other sites More sharing options...
Neo Posted May 7, 2008 Author Share Posted May 7, 2008 (edited) You guys are great ! Word by word I am getting closer to the goal . Thanks a lot aGorilla and Thatsgreat2345 . I have finally managed to click on the link I would like. I just want to know if what I did to make it work makes sense ? $oIE = _IEAttach("InForm") $oFrameC = _IEFrameGetObjByName($oIE, "C") $oFrameBody = _IEFrameGetObjByName($oFrameC, "Body") $oTable = _IETableGetCollection($oFrameBody, 0) $oLinks = _IELinkGetCollection($oFrameBody) For $oLink In $oLinks If($oLink.innerHTML = ClipGet()) Then $linkSplit = StringSplit($oLink.href, ",") ConsoleWrite($linkSplit[2] & @LF) $lprop = "java script:UL(62," & $linkSplit[2] For $oLink In $oLinks If($oLink.href = $lprop) Then _IEAction ($oLink, "click") ExitLoop EndIf Next ExitLoop EndIf Next I am wondering if there is a way to do it without 2 loops because I couldn't get _IEAction($lprop, "click") to work as it is not seen as a link. In either case, it's now time to look at the Excel part . Thank you again and again Edited May 10, 2008 by Neo Link to comment Share on other sites More sharing options...
aGorilla Posted May 7, 2008 Share Posted May 7, 2008 Happy to help. It makes sense to me, but I'm still a noob myself (less than a month). I didn't know how to read the text (innerHTML), until I tried to answer your question, I just guessed, and got lucky That looks very much like what I had in mind, I just didn't have the time to try it. If there's a better way, hopefully somebody more experienced will point it out. I was also wondering how you could 'shortcut' the process, since you knew what the href would be, once you parsed the text. You should probably change the variable for the inner loop, if for no other reason, it causes confusion. It's risky to use the same name for nested loops. Good luck with your app, I'm working on something similar myself. Search AutoItScript.com via Google Link to comment Share on other sites More sharing options...
Neo Posted May 7, 2008 Author Share Posted May 7, 2008 Wow fast answer ! Even though I've been registered for a long time, I didn't use much of IE functions until THE DaleHohm himself helped me write the most important part. Thank you very much again and I might bother you all soon enough with my Excel issues Take care Link to comment Share on other sites More sharing options...
Neo Posted May 10, 2008 Author Share Posted May 10, 2008 (edited) It's me again! Now I have an excel sheet with X amounts of rows in column A filled with usernames. I have an Array that obtains the usernames from the rows. Now I managed to get the first username in the Array processed. But I want the procedure to be repeated until all items in the Array are done. I have the below code, could anyone give me ideas as to why it doesn't work ? Also It would be nice if there was an easy way to write to the Array all the rows until it's empty as the size is variable (100-500 rows no empty lines in between starts from A1 to AXXX) expandcollapse popup#include <GUIConstants.au3> #include <IE.au3> #include <ExcelCOM_UDF.au3> #include <Array.au3> #include <File.au3> Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",4) Opt("WinDetectHiddenText",1) $protocol = InputBox("Automate!", "Enter Protocol","","",400,200) Global $XLFilePath = @DesktopDir & "\" & $protocol &".xls" Global $oExcel, $XLArray $oIE = _IEAttach($protocol) $oFrameC = _IEFrameGetObjByName($oIE, "C") $oFrameBody = _IEFrameGetObjByName($oFrameC, "Body") $oTable = _IETableGetCollection($oFrameBody, 0) $oLinks = _IELinkGetCollection($oFrameBody) $oExcel = _ExcelBookOpen($XLFilePath) $XLArray = _ExcelReadArray($oExcel, 1, 1, 2, 1) ;ACCESS THE PROPERTIES LINK OF THE CURRENT USER For $xlUser in $XLArray; For Array ConsoleWrite($xlUser & @LF);TEST LINE For $oLink In $oLinks; For Links for current Profile If($oLink.innerHTML = $xlUser) Then $linkSplit = StringSplit($oLink.href, ",") $lprop = "java script:UL(62," & $linkSplit[2] For $pLink In $oLinks If($pLink.href = $lprop) Then ConsoleWrite($lprop & @LF);TEST LINE _IEAction ($pLink, "click") ;~ SELECTION STARTS HERE _IELoadWait($oFrameBody) $oSelect = _IETagNameGetCollection($oFrameBody, "select", 1) $oOptions = $oSelect.Options For $oOption in $oOptions $sText = String($oOption.text) If Not StringInStr($sText, "NOT PARTICIPATING") Then $oOption.selected = True Else $oOption.selected = False EndIf Next $oFrameContextPanel = _IEFrameGetObjByName($oFrameC, "ContextPanel") $oA = _IELinkGetCollection($oFrameContextPanel, 0) ConsoleWrite($oA.innertext & @CR) $hwnd = _IEPropertyGet($oIE, "hwnd") _IEAction($oA, "focus") ControlSend($hwnd, "Submit", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}") ; Wait for Alert window, then click on OK $popupTitle = "Microsoft Internet Explorer" WinWait($popupTitle) ControlClick($popupTitle, " ", "[CLASS:Button; TEXT:OK; Instance:1;]") _IELoadWait ($oFrameContextPanel) $oR = _IELinkGetCollection($oFrameContextPanel, 1) ConsoleWrite($oR.innertext & @CR) _IEAction($oR, "focus") ControlSend($hwnd, "Return", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}") ;~ SELECTION ENDS HERE ExitLoop EndIf Next ExitLoop EndIf Next; End For Links for current Profile ;PROCESSED USERNAME Next; End For Array / GOTO NEXT PROFILE _ExcelBookClose($oExcel);I BELIEVE THIS CAN BE DONE RIGHT AFTER THE ARRAY IS POPULATED Exit 0 Thank you very much again Edited May 10, 2008 by Neo Link to comment Share on other sites More sharing options...
aGorilla Posted May 10, 2008 Share Posted May 10, 2008 Couple of thoughts... I would add Opt('MustDeclareVars', 1) just to make sure I don't have any typos. You should also try seperating some of the complexity out to functions. Here's a quick attempt at getting some of the confusion out of the way... expandcollapse popup$oIE = _IEAttach($protocol) $oFrameC = _IEFrameGetObjByName($oIE, "C") $oFrameBody = _IEFrameGetObjByName($oFrameC, "Body") $oTable = _IETableGetCollection($oFrameBody, 0) $oLinks = _IELinkGetCollection($oFrameBody) $XLArray = ReadExcel($XLFilePath) ;ACCESS THE PROPERTIES LINK OF THE CURRENT USER For $xlUser in $XLArray; For Array ConsoleWrite($xlUser & @LF);TEST LINE $lprop = FindLinkText($xlUser) If $lprop Then $pLink = FindLinkHref($lprop) If $pLink Then _IEAction ($pLink, "click") ;~ SELECTION STARTS HERE _IELoadWait($oFrameBody) $oSelect = _IETagNameGetCollection($oFrameBody, "select", 1) $oOptions = $oSelect.Options For $oOption in $oOptions $sText = String($oOption.text) If Not StringInStr($sText, "NOT PARTICIPATING") Then $oOption.selected = True Else $oOption.selected = False EndIf Next $oFrameContextPanel = _IEFrameGetObjByName($oFrameC, "ContextPanel") $oA = _IELinkGetCollection($oFrameContextPanel, 0) ConsoleWrite($oA.innertext & @CR) $hwnd = _IEPropertyGet($oIE, "hwnd") _IEAction($oA, "focus") ControlSend($hwnd, "Submit", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}") ; Wait for Alert window, then click on OK $popupTitle = "Microsoft Internet Explorer" WinWait($popupTitle) ControlClick($popupTitle, " ", "[CLASS:Button; TEXT:OK; Instance:1;]") _IELoadWait ($oFrameContextPanel) $oR = _IELinkGetCollection($oFrameContextPanel, 1) ConsoleWrite($oR.innertext & @CR) _IEAction($oR, "focus") ControlSend($hwnd, "Return", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{Enter}") ;~ SELECTION ENDS HERE EndIf EndIf ;PROCESSED USERNAME Next; End For Array / GOTO NEXT PROFILE Func ReadExcel($path) Local $oExcel = _ExcelBookOpen($path) Local $XLArray = _ExcelReadArray($oExcel, 1, 1, 2, 1) _ExcelBookClose($oExcel);I BELIEVE THIS CAN BE DONE RIGHT AFTER THE ARRAY IS POPULATED ; I agree, and you should try it;) Return($XLArray) EndFunc Func FindLinkText($text) Local $oLink, $linkSplit, $lprop For $oLink In $oLinks; For Links for current Profile If($oLink.innerHTML = $text) Then $linkSplit = StringSplit($oLink.href, ",") $lprop = "java script:UL(62," & $linkSplit[2] Return $lprop EndIf Next; End For Links for current Profile EndFunc Func FindLinkHref($href) Local $oLink For $oLink In $oLinks If($oLink.href = $href) Then ConsoleWrite($href & @LF);TEST LINE Return $oLink EndIf Next EndFunc Exit 0 Search AutoItScript.com via Google Link to comment Share on other sites More sharing options...
Neo Posted May 10, 2008 Author Share Posted May 10, 2008 Thanks a lot I will try this to see if it works and report back very soon. I am really glad that you're always there to help aGorilla Link to comment Share on other sites More sharing options...
Neo Posted May 16, 2008 Author Share Posted May 16, 2008 With all your help, I have finally managed to complete my project . Thank you Master DaleHohm, Thatsgreat2345 and aGorilla!! You all have helped me with this and I am indebted to all of you. Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you,Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you,Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you,Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you,Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you,Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you,Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you,Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you,Thank you, Thank you, Thank you, Thank you, Thank you, Thank you, Thank you!!!!! :D Link to comment Share on other sites More sharing options...
Neo Posted May 16, 2008 Author Share Posted May 16, 2008 (edited) As per the above post, the script works perfectly.However, I do have the following question: Is there a faster way to access a java script:.... link such as java script:UL(62,28022) inside a frame instead of looping through all links such as the following ?;This function finds the link belonging to a username IN A VERY LONG LIST CONTAINING ABOUT 1000 to 2000 names (each having 3 links (1 for last name / 1 for first name / 1 for username) this allows access to edit their names Func FindLinkText($text) _IELoadWait($oFrameBody) Local $oLink, $oLinks, $linkSplit, $lprop $text = StringStripWS($text, 3) $oLinks = _IELinkGetCollection($oFrameBody) For $oLink In $oLinks If($oLink.innerHTML = $text) Then $linkSplit = StringSplit($oLink.href, ",") $lprop = "java script:UL(62," & $linkSplit[2] Return $lprop EndIf Next EndFunc ;This loops through all those 1000-2000 links x 3 (3000 to 6000 links) and then finds the corresponding link named "Properties". (CAN BE SEEN IN THE FIRST POST) This link allows access to a separate profile properties that I need to access. Func FindLinkHref($href) _IELoadWait($oFrameBody) Local $pLink, $pLinks $pLinks = _IELinkGetCollection($oFrameBody) _IELoadWait($oFrameBody) For $pLink In $pLinks If($pLink.href = $href) Then Return $pLink EndIf Next EndFuncThe only difference between the links for the "first / last / username" and "Properties" is that the first one's link is something like "java script:UL(21,28022)" whereas for Properties it is "java script:UL(62,28022)". Only 1 difference...Like Master DaleHohm would ask, I have tried: _IENavigate($oIE, "java script:UL(62,28022)") but it didn't work. I don't know what else I can try and would appreciate all help .EDIT: P.S. Anything that starts by "java script:" are automatically separated in half not to interfere with the site's function, they are indeed together.I have also seen this post which is starting give me some ideas to get the index but still too foggy(must be the sleep):http://www.autoitscript.com/forum/index.ph...mp;#entry509212Thank you. Edited May 16, 2008 by Neo Link to comment Share on other sites More sharing options...
DaleHohm Posted May 16, 2008 Share Posted May 16, 2008 I'm not sure I'm understanding exactly what your goal is. Do you know in advance what the link looks like before you click on it? Perhaps you should just insert your own on the fly... $oBody = _IETagNameGetCollection($oIE, "body", 0) _IEDocInsertHTML($oBody, "<a href='java script:UL(62,17277)'>Mash Me</a>", "afterbegin") _IELinkClickByText($oIE, "Mash Me") Dale 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...
Neo Posted May 16, 2008 Author Share Posted May 16, 2008 (edited) My goal is to speed up the process of accessing the javascript link "Properties" I will have a huge list of links but I only know which link to access after knowing which username is next to be processed. Let me know if you need more info. I am standing by here I really appreciate you helping me with this Thank you Edited May 16, 2008 by Neo Link to comment Share on other sites More sharing options...
DaleHohm Posted May 16, 2008 Share Posted May 16, 2008 So do you understand what my example above accomplishes? Does it help? Dale 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...
Neo Posted May 16, 2008 Author Share Posted May 16, 2008 (edited) I had not the first time but now I do.I have tried it with several ways and links but it doesn't do anything, it just stops. >>> CORRECTION:It worked!! Thanks a lot again. You always save the day!You're like the superman of autoit coders, Autoitman!THANKS A MILLION again Master Dale Hohm Edited May 16, 2008 by Neo Link to comment Share on other sites More sharing options...
Neo Posted May 16, 2008 Author Share Posted May 16, 2008 (edited) Like the above code insertion on the fly, Can I find a text in that page, then copy it's link, then play around with it ? This would further save time. Every second counts... I have already saved 4-6 seconds thanks to you It's like having _IELinkClickByText but more like _IELinkCopyByText but how ? Edited May 16, 2008 by Neo 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