EmptySpace Posted December 31, 2011 Share Posted December 31, 2011 Hi all, I need some help with adding few stringinctr , I call it string checker Ok, this is my script now (cuted all other junk that u dont need to see) $oIE = _IECreate("http://www.link.com) ; $i = 0 While $i <= 10000 _IELinkClickByText($oIE, "Linktext") $body = _IEBodyReadHTML($oIE) If StringInStr($body, "text 1") Then _IELinkClickByIndex($oIE, 3) ContinueLoop Else ContinueLoop EndIf Exit $i = $i + 1 WEnd This is only one checker. What I need is to place one more checker somewhere which would search for other word when _IELinkClickByText is working. Tried to place everywhere but it just wont work. Any advices? Link to comment Share on other sites More sharing options...
somdcomputerguy Posted December 31, 2011 Share Posted December 31, 2011 If StringInStr($body, "text 1") Then _IELinkClickByIndex($oIE, 3) ; Is this one of those places? ContinueLoop Else ContinueLoop EndIf - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
czardas Posted December 31, 2011 Share Posted December 31, 2011 (edited) Not sure what you want, but there are several mistakes in your code. See the comments below. $oIE = _IECreate("http://www.link.com") ; $i = 0 While $i <= 10000 _IELinkClickByText($oIE, "Linktext") $body = _IEBodyReadHTML($oIE) If StringInStr($body, "text 1") Then _IELinkClickByIndex($oIE, 3) ContinueLoop ; This happens regardless of the conditional If statement Else ContinueLoop ; This happens regardless of the conditional If statement EndIf Exit ; This line will never be reached becuase you use ContinueLoop above $i = $i + 1 ; This line will never be reached becuase you use ContinueLoop and Exit above WEnd Basically what you have written can be simplified as follows (both scripts do exactly the same thing): $oIE = _IECreate("http://www.link.com") For $i = 0 To 10000 _IELinkClickByText($oIE, "Linktext") $body = _IEBodyReadHTML($oIE) If StringInStr($body, "text 1") Then _IELinkClickByIndex($oIE, 3) EndIf Next First try to understand exactly what your code is doing before you add any new arguments. I hope this helps you. Happy New Year. Edited December 31, 2011 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
EmptySpace Posted December 31, 2011 Author Share Posted December 31, 2011 Happy New Year to all! Czardas, thanks I will check it tomowow but it seems be working.Im really newbie so I dont understand much.Talking about ContinueLoop, day ago I had problem that script was stoping after string check so I just used ContinueLoop... It worked perfectly since my scripts are very simple. Thanks for showing mistakes And I see you didnt answered my question .I need to add to two _IELinkClickByText($oIE, "Linktext") $body = _IEBodyReadHTML($oIE) If StringInStr($body, "text 1") Then _IELinkClickByIndex($oIE, 3)Which would search for text 1 and if its found do something, and other which would search for text 2 and do smth, if not found text 1 and text2 then continue loop.(Sorry if I somethink didnt saw, my english is very bad) Link to comment Share on other sites More sharing options...
somdcomputerguy Posted January 1, 2012 Share Posted January 1, 2012 (edited) If StringInStr($body, "text1") And StringInStr($body, "text2") Then _IELinkClickByIndex($oIE, 3) This will only execute the _IELinkClick if search 1 AND search 2 are successful. A question for you. Are something and something else two different things? Or the same? Edited January 1, 2012 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
EmptySpace Posted January 1, 2012 Author Share Posted January 1, 2012 (edited) That thing I know, I need two different things. If 1 search found then _IELinkClickByIndex($oIE, 3 , If 2search found then for example IENavigate to url... I tried to place two checkers but it wont works $body = _IEBodyReadHTML($oIE) If StringInStr($body, "text 1") Then _IELinkClickByIndex($oIE, 3) If StringInStr($body, "text 2") Then _IELinkClickByIndex($oIE, 1) This is for example what I mean. It must be possible but I dont know how to do it correctly, Edit: Maybe something I can make with case? Dont know exactly what it means... Edited January 1, 2012 by sirfearless Link to comment Share on other sites More sharing options...
EmptySpace Posted January 1, 2012 Author Share Posted January 1, 2012 (edited) Oh, I never thought that it will work : $oIE = _IECreate("http://www.link.com") $i = 0 Do For $i = 0 To 1 _IELinkClickByText($oIE, "link") $body = _IEBodyReadHTML($oIE) If StringInStr($body, "test 1") Then _IELinkClickByIndex($oIE, 3) EndIf Next For $i = 0 To 1 _IELinkClickByText($oIE, "same link") $body = _IEBodyReadHTML($oIE) If StringInStr($body, "text 2") Then _IENavigate($oIE, "link") EndIf Next $i = $i + 1 Until $i = 10000 I know there is unnecessary things... Its good for me if its working Edited January 1, 2012 by sirfearless Link to comment Share on other sites More sharing options...
czardas Posted January 1, 2012 Share Posted January 1, 2012 Hmm, if only I knew what you were trying to do. I've added some comments to explain why you have created an infinite loop. $oIE = _IECreate("http://www.link.com") $i = 0 ; $i now equals 0 Do ; Forever For $i = 0 To 1 ; $i now equals 0 _IELinkClickByText($oIE, "link") $body = _IEBodyReadHTML($oIE) If StringInStr($body, "test 1") Then _IELinkClickByIndex($oIE, 3) EndIf Next ; $i now equals 2 For $i = 0 To 1 ; $i now equals 0 _IELinkClickByText($oIE, "same link") $body = _IEBodyReadHTML($oIE) If StringInStr($body, "text 2") Then _IENavigate($oIE, "link") EndIf Next ; $i now equals 2 $i = $i + 1 ; $i now equals 3 Until $i = 10000 ; ; $i NEVER equals 10000 Every time you enter the For loop, $i is reset to zero, so your code is not making much sense. If you wish to run the main loop 10000 times, then instead of using $i to increase the count, use a different variable name (to avoid corrupting the count). If it is an infinite loop you wish to create then just use a While loop. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
EmptySpace Posted January 1, 2012 Author Share Posted January 1, 2012 Yep, I want to make infinite loop. Seems that I found out my solutions to make few string checkers I need to use if....Then... ElseIf....then and so on? All I needed is that I dont undertand much of these variables and other things ... Firstly I want to learn basic, and get it to work. Link to comment Share on other sites More sharing options...
czardas Posted January 1, 2012 Share Posted January 1, 2012 Okay here's how to do it with an infinite While loop. $oIE = _IECreate("http://www.link.com") While 1 For $i = 0 To 1 ; Why are you repeating the following code? _IELinkClickByText($oIE, "link") $body = _IEBodyReadHTML($oIE) If StringInStr($body, "test 1") Then _IELinkClickByIndex($oIE, 3) EndIf Next For $i = 0 To 1 ; Why are you repeating the following code? _IELinkClickByText($oIE, "same link") $body = _IEBodyReadHTML($oIE) If StringInStr($body, "text 2") Then _IENavigate($oIE, "link") EndIf Next WEnd I'm not sure why you are repeating each set of actions twice by using the For loops. See comments in the code. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
EmptySpace Posted January 1, 2012 Author Share Posted January 1, 2012 (edited) That was my old script. I didnt knew about else if. So it wasnt working. now my code looks $oIE = _IECreate("http://www.link.com") While 1 _IELinkClickByText($oIE, "link") $body = _IEBodyReadHTML($oIE) If StringInStr($body, "test 1") Then _IELinkClickByIndex($oIE, 3) $body = _IEBodyReadHTML($oIE) ElseIf StringInStr($body, "text 2") Then _IENavigate($oIE, "link") EndIf Next WEnd Also I cant figure out how to click link. One link just wont work so im trying to use _IEGetObjById ($oIE, "id got from inspect") _IEAction ($oIE, "click") It have to work but I think one line is missing. Edited January 1, 2012 by sirfearless Link to comment Share on other sites More sharing options...
czardas Posted January 1, 2012 Share Posted January 1, 2012 Now the code is looking a bit more sensible. I don't know if it does what you want it to do, but at least I understand it now. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
EmptySpace Posted January 1, 2012 Author Share Posted January 1, 2012 Code was doing what I wanted from the begining But it was hard to add something new into it. Now its lot easer. Thanks for help.Also can you explain what means all these $oIE.It just says that line will work into$oIE = _IECreate("http://www.link.com") ? Link to comment Share on other sites More sharing options...
czardas Posted January 1, 2012 Share Posted January 1, 2012 If you look in the help file it tells you what the return value is for the function _IECreate()Returns an object variable pointing to an InternetExplorer.Application objectSo that is what it is. You should look up the following basic terms and try to understand their meanings:• variable• conditional statement operator64 ArrayWorkshop 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