EmptySpace Posted July 6, 2012 Share Posted July 6, 2012 I can solve it in other way but i want to look it clearly and run smooth. Func clicklink() Sleep(4000) _IELinkClickByText($oIE,$text) If @error = 7 Then ;if no link found _IELinkClickByText($oIE,$text2) If @error = 7 Then ; link text2 wasnt found then _IELinkClickByText($oIE,$text3) If all errors then ;if no links found then _ieaction($oIE,"refresh") Endif Endfunc So how i can write this? Maybe its possible with case or smthg? Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 6, 2012 Moderators Share Posted July 6, 2012 If I am understanding you correctly, maybe a For loop and an error level check would make it easier. Something like this (untested)? Func clicklink() Sleep(4000) Local $ErrLevel = 0 Local $aText[3] $aText[0] = "" $aText[1] = "" $aText[2] = "" For $link in $aText _IELinkClickByText($oIE,$link) If @error = 7 Then ;if no link found $ErrLevel += 1 EndIf Next If $ErrLevel = 3 Then ;if no links found then _ieaction($oIE,"refresh") Endif Endfunc "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
EmptySpace Posted July 6, 2012 Author Share Posted July 6, 2012 (edited) Thanks! It works fine. Edit, I cant see correctly but i think it click few links at once. Its possible? Edited July 6, 2012 by Edgaras Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 6, 2012 Moderators Share Posted July 6, 2012 Glad to help "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
EmptySpace Posted July 6, 2012 Author Share Posted July 6, 2012 (edited) It works fine but I think if first link exists it clicks all three. It loops through all links I need somehow to make that if first link exists then dont even check other. Edited July 6, 2012 by Edgaras Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 6, 2012 Moderators Share Posted July 6, 2012 Depending on what you want to do, you need to add an Else into your If Statement: Func clicklink() Sleep(4000) Local $ErrLevel = 0 Local $aText[3] $aText[0] = "" $aText[1] = "" $aText[2] = "" For $link in $aText _IELinkClickByText($oIE,$link) If @error = 7 Then ;if no link found $ErrLevel += 1 Else ;click $link EndIf Next If $ErrLevel = 3 Then ;if no links found then _ieaction($oIE,"refresh") Endif Endfunc "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
EmptySpace Posted July 6, 2012 Author Share Posted July 6, 2012 In first code when I start function in once it tries to click all links. If all three links is in window then i clicks firs and other two. I need if link is clicked then dont search for other links. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted July 6, 2012 Moderators Share Posted July 6, 2012 You should be able to use ExitLoop in your Else statement. That way, whichever link it finds it will then exit the For loop. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
EmptySpace Posted July 6, 2012 Author Share Posted July 6, 2012 Yeah, now it works fine. Thanks again for help Func clicklink() Sleep(4000) Local $ErrLevel = 0 Local $aText[3] $aText[0] = "" $aText[1] = "" $aText[2] = "" For $link in $aText _IELinkClickByText($oIE,$link) If @error = 7 Then ;if no link found $ErrLevel += 1 else exitloop EndIf Next If $ErrLevel = 3 Then ;if no links found then _ieaction($oIE,"refresh") Endif Endfunc 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