Jump to content

Problem with _IELinkClickbyText()


Recommended Posts

basically the script below will be hosed untill you click yes or no for the Message box in the attachment.

Before you do that add that site (www.hello.com) to your trusted sites.

#include <IE.au3> 
;;Add this website"https://www.hello.com/" to your trusted sites.
$O_IE = _IECreate( "https://www.hello.com/" )
If StringInStr( _IEBodyReadText ($O_IE), "There is a problem with this website's security certificate.") Then
    _IELinkClickByText ($O_IE, "Continue to this website (not recommended).", 0, 0)
EndIf
Sleep(200)
MsgBox( 0 , "" , "" )

Note:

IE7 Beta3 with Autoit 131

If you click "NO" the script will crash.

You can change the link to any website that has a problem with it's certificate and supports https.

Regards

RK

Edit:I removed the attachment to save space

Edited by rbhkamal

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Link to comment
Share on other sites

Thanks for the example site. I had suggested this solution to someone else but was unable to test it.

Here you go, use Adlib:

#include <IE.au3> 
;;Add this website"https://www.hello.com/" to your trusted sites.
AdlibEnable("WhackSecurityAlert")
$O_IE = _IECreate( "https://www.hello.com/")
AdlibDisable()
If StringInStr( _IEBodyReadText ($O_IE), "There is a problem with this website's security certificate.") Then
    _IELinkClickByText ($O_IE, "Continue to this website (not recommended).", 0, 0)
EndIf
Sleep(200)
MsgBox( 0 , "" , "" )

Func WhackSecurityAlert()
    If WinExists("Security Alert") Then
        ControlClick("Security Alert", "", "Button1")
    EndIf
EndFunc

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

I'm sorry but the script is totaly hosed. even adlib.

It's not working for me.

#include <IE.au3>
;;Add this website"https://www.hello.com/" to your trusted sites.
Global $a
AdlibEnable("WhackSecurityAlert")
If @error Then MsgBox( 0 , '' , @error )
$O_IE = _IECreate( "https://www.hello.com/")
If StringInStr( _IEBodyReadText ($O_IE), "There is a problem with this website's security certificate.") Then
    _IELinkClickByText ($O_IE, "Continue to this website (not recommended).", 0, 0)
EndIf
AdlibDisable()
Sleep(200)
MsgBox( 0 , "" , "" )

Func WhackSecurityAlert()
    $a += 1

                                                                    local $DEBUG_SAVE_ERROR = @error ;### Debug Console 
                                                                    ConsoleWrite('@@ Debug('&@ScriptLineNumber&') : $a = ' & $a &' >>Error code: ' & $DEBUG_SAVE_ERROR & @lf) ;### Debug Console
                                                                    SetError($DEBUG_SAVE_ERROR) ;### Debug Console

    If WinExists("Security Warning") Then
        ControlClick("Security Warning", "", "Button1")
    EndIf
EndFunc
Edited by rbhkamal

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Link to comment
Share on other sites

Nice, added to the database.

It's not working! :D

Try it

Edit: IE7 Beta3 and Autoit Beta .....131

Edit: It looks like AuotIt is treating the security alert as if it's a MsgBox.(You can't exit , start adlib ..... etc)

Edited by rbhkamal

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Link to comment
Share on other sites

What am I supposed to do?

It looks like the only way is to create another exe which kills that security alert or warning for IE7.

I wonder if batch files can do that???

Edited by rbhkamal

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Link to comment
Share on other sites

  • Moderators

What am I supposed to do?

It looks like the only way is to create another exe which kills that security alert or warning for IE7.

I wonder if batch files can do that???

It should work, use the AutoIt Info Tool and make sure your "Yes" button is "Button1".
Link to comment
Share on other sites

It should work, use the AutoIt Info Tool and make sure your "Yes" button is "Button1".

Does it work for you? Because the Console messages stop when the Alert shows up.!! Edited by rbhkamal

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Link to comment
Share on other sites

Does it work for you? Because the Console messages stop when the Alert shows up.!!

OK, I ignored what you told me about adding it to my trusted site list.

The dislog I was whacking was a "Security Alert" dialog, not the one you attached. Sorry.

I'll admit to never using a trusted site list before... how do I add a site to it?

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

  • Moderators

OK, I ignored what you told me about adding it to my trusted site list.

The dislog I was whacking was a "Security Alert" dialog, not the one you attached. Sorry.

I'll admit to never using a trusted site list before... how do I add a site to it?

Dale

Tools-> Internet Options-> Security-> Trusted Sites-> Sites-> Add

I added it to my trusted sites and it still works, so it must be something to do with IE7.

Edited by big_daddy
Link to comment
Share on other sites

I see that the behavior in IE7 is musch different than IE6.

I've now tested with IE7 Beta3 and I cannot get that message box. I get the page telling me there is a problem with the security certificate, but no dialog box.

Either with or without https://www.hello.com in my trusted sites list your original script works fine and I do not get that dialog... wassup?

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

I see that the behavior in IE7 is musch different than IE6.

I've now tested with IE7 Beta3 and I cannot get that message box. I get the page telling me there is a problem with the security certificate, but no dialog box.

Either with or without https://www.hello.com in my trusted sites list your original script works fine and I do not get that dialog... wassup?

Dale

make sure that you have only one opened IE window.

It happens every time using defferent web links.

maybe your IE security level is low, mine is set to "medium-high"

I'm sure it happend to alot of people out there.

thanks

RK

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Link to comment
Share on other sites

make sure that you have only one opened IE window.

It happens every time using defferent web links.

maybe your IE security level is low, mine is set to "medium-high"

I'm sure it happend to alot of people out there.

thanks

RK

I checked sevurity -- was medium-high for Internet, but medium for trusted. Set trusted to medium high. I closed all browser windows and tested your code again. still no dialog box. I can't reproduce.

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

Dear Dale,

I just installed IE7 Beta 3 at home and the problem happens here too.

please make sure that the link under your trusted sites is the same as the one you are trying to access.

https://www.hello.com/

Thanks

RK

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Link to comment
Share on other sites

Dear Dale,

I just installed IE7 Beta 3 at home and the problem happens here too.

please make sure that the link under your trusted sites is the same as the one you are trying to access.

https://www.hello.com/

Thanks

RK

Yep, checked again and that is the way I am set up. I use a proxy server... shut thyat off and still no dice.

So, lets stop trying to reproduce and just focus on your probems.

What is the behavior of the following code:

#include <IE.au3>
$oIE = _IECreate("https://www.hello.com", 0, 1, 0)
MsgBox(0, "", "Did I wait for the dialog to be dismissed?")

This does a create with nowait. We need to understand whether the stall is in in the navigation or in the _IELoadWait.

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

The Warning message shows up between MsgBox 6 and 7

Here is what happens:

1- the script start executing the .click action.

2- The warning message shows up

3- The script becomes not responding (even the systray Icon )

4- the script never goes beyond that line until I click "Yes" or "No" in the Warning Message.

a- If clicked "Yes" everything works fine

b- If clicked "No" the script will crash with this error.

C:\Documents and Settings\rbhkamal\Desktop\asdasd.au3 (29) : ==> The requested action with this object has failed.: 
$link.click 
$link.click^ ERROR
+>AutoIT3.exe ended.rc:0
>Exit code: 0   Time: 10.119

In other words I got all message boxes except (7 and last)

If I click "Yes" on the Warning, the script continues.

#include <IE.au3>
$O_IE = _IECreate( "https://www.hello.com/" )
;Good No Problems, Autoit is still responding
_IEloadwait( $O_IE , 100 )
MsgBox( 0 , "1" , "No Problems here" )  ;Message Box 1
;Still no problems
IELinkClickByText ($O_IE, "Continue to this website (not recommended).", 0, 0)

MsgBox( 0 , "Last" , "No Problems here" )  ;Message Box Last

Func IELinkClickByText(ByRef $o_object, $s_linkText, $i_index = 0, $f_wait = 1)
    If Not IsObj($o_object) Then
        __IEErrorNotify("Error", "_IELinkClickByText", "$_IEStatus_InvalidDataType")
        SetError($_IEStatus_InvalidDataType, 1)
        Return 0
    EndIf
    ;
    MsgBox( 0 , "2" , "No Problems here" )  ;Message Box 2
    Local $found = 0, $link, $linktext, $links = $o_object.document.links
    MsgBox( 0 , "3" , "No Problems here" )  ;Message Box 3
    $i_index = Number($i_index)
    For $link In $links
        MsgBox( 0 , "4" , $link.outerText )  ;Message Box 4
        $linktext = $link.outerText & "" ; Append empty string to prevent problem with no outerText (image) links
        MsgBox( 0 , "5" , $link.outerText )  ;Message Box 5
        If $linktext = $s_linkText Then
            if ($found = $i_index) Then
                MsgBox( 0 , "6" , $link.outerText )  ;Message Box 6;The Warning message shows up between MsgBox 6 and 7
                $link.click
                MsgBox( 0 , "7" , $link.outerText )  ;Message Box 7
                If $f_wait Then
                    _IELoadWait($o_object)
                    SetError(@error)
                    Return -1
                EndIf
                SetError($_IEStatus_Success)
                Return -1
            EndIf
            $found = $found + 1
        EndIf
    Next
    __IEErrorNotify("Warning", "_IELinkClickByText", "$_IEStatus_NoMatch")
    SetError($_IEStatus_NoMatch) ; Could be caused by parameter 2, 3 or both
    Return 0
EndFunc   ;==>_IELinkClickByText

AutoIt will be completely hosed when the "$oject.click" is executed (If only there was a Warning message).

let me know if you have any question.

thanks

RK

Note:

1- _IEcreate() and _IEloadwait() have no problems

2- The Warning message shows up between MsgBox 6 and 7

3- I hope I was clear.

Edited by rbhkamal

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Link to comment
Share on other sites

Thanks. This showed me what I needed to see. My debug suggestion was not what I needed, but the one you used (_IELinkClickByText ($O_IE, "Continue to this website (not recommended).", 0, 0) ) with the NoWait was exactly what we needed.

This is unfortunate be cause it shows that the script is stalling because the browser is not returning control back to autoit after the link is clicked until you dismiss the dialog box. We see this behavior at other times like when Javascript alert boxes are created as a result of an action.

You either need to avoid the stall or have another execution thread. Having another execution thread would require executing another script that would dismiss the dialog for you - this is not straightforward in AutoIt. The other way to to activate the link without using the DOM, by sending a keyboard action:

$oLinks = _IELinkGetCollection($oIE)
For $oLink in $oLinks
    If $oLink.outerText = "Continue to this website (not recommended)." Then
        $oLink.focus
        ControlSend(_IEPropertyGet($oIE, "hwnd"), "", "", "{SPACE}") ; you can use SEND is the window has focus
        ExitLoop
    EndIf
Next

At this point the dialogbox will appear (or not), but control will have returned to AutoIt and you can use WinExists(), ControlSend() etc. to deal with it and then return to IE.au3 processing.

Ugly yes, but it is the best I know to offer.

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

Thanks Dale,

Sorry I didn't explain the problem correctly from the first time.

Could you please open a bug about this issue or you think its not worth it?

RK

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Link to comment
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
 Share

  • Recently Browsing   0 members

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