Jump to content

Recommended Posts

Posted

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?

  • Moderators
Posted

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!

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
  • Moderators
Posted

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!

Posted

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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...