Sign in to follow this  
Followers 0
EmptySpace

Problem with runing statemens

9 posts in this topic

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?

Share this post


Link to post
Share on other sites



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

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks! It works fine. ^_^

Edit, I cant see correctly but i think it click few links at once. Its possible?

Edited by Edgaras

Share this post


Link to post
Share on other sites

Glad to help


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by Edgaras

Share this post


Link to post
Share on other sites

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

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

You should be able to use ExitLoop in your Else statement. That way, whichever link it finds it will then exit the For loop.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0