Sign in to follow this  
Followers 0
Welberg

Javascript confirm window | adlib loop stops

5 posts in this topic

On a webpage clicking a specific action results in a confirm window with an OK and CANCEL button.

I would like to click OK on that confirm window but can't get that done.

To determine this point I started using AdlibRegister.

But the 11 ms looping stops when the confirm window gets around.

The specific action that is triggered is called "GoForIt":

<A href="javascript:fnGoForIt()"><B>GoForIt</B></A>

The GoForIt function:

function fnGoForIt(){

var opt;

opt=window.confirm('Do you want to continue?');

if (opt == true) {

window.document.frmReq.txtSubmit.value="POST";

window.document.frmReq.submit();

}

}

Within my script I use AdlibRegister:

$strTemp = "1000"

AdlibRegister("MyAdlib", 11)

Sleep( 110 )

_IELinkClickByText ($oIE, "GoForIt")

$strTemp = "5000"

Send("{ENTER}")

$strTemp = "6000"

Sleep( 110 )

ConsoleWrite("ENDING|" & @LF)

_IEQuit ($oIE)

ConsoleWrite("ENDED|" & @LF)

Exit

The MyAdlib function is like:

Func myadlib()

ConsoleWrite("BGN|")

if (WinActive("[ACTIVE]", "")) Then

$strTemp = $strTemp + 1

$handle = WinGetHandle("[ACTIVE]", "")

$strTitle = WinGetTitle("[active]")

ConsoleWrite("Title=" & $handle & "|" & $strTitle & "|" & $strTemp & @LF)

EndIf

ConsoleWrite("END" & @LF)

EndFunc

The console log looks like upto the moment the conform window gets opened:

BGN|Title=0x000513C0|Title - Windows Internet Explorer|1001

END

BGN|Title=0x000513C0|Title - Windows Internet Explorer|1002

END

BGN|Title=0x000513C0|Title - Windows Internet Explorer|1003

END

BGN|Title=0x000513C0|Title - Windows Internet Explorer|1004

END

BGN|Title=0x000513C0|Title - Windows Internet Explorer|1005

END

BGN|Title=0x000513C0|Title - Windows Internet Explorer|1006

END

BGN|Title=0x000513C0|Title - Windows Internet Explorer|1007

END

BGN|Title=0x000513C0|Title - Windows Internet Explorer|1008

END

BGN|Title=0x000513C0|Title - Windows Internet Explorer|1009

END

After clicking "CANCEL" the log continues like:

BGN|Title=0x000513C0|Title - Windows Internet Explorer|5001

END

BGN|Title=0x000513C0|Title - Windows Internet Explorer|6001

END

.............upto

BGN|Title=0x000513C0|Title - Windows Internet Explorer|6086

END

ENDING|

ENDED|

Share this post


Link to post
Share on other sites



Welcolme to the forum ! Posted Image

Please use AutoIt Tags for your script

I presume you work with Active window because you can't get javascript window title ?


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

This is the script (I left out that which does not affect the problem):

#include <IE.au3>

_IENavigate ($oIE, "http://...", 0)
_IELoadWait($oIE)
#Activate Delete link

$strTemp = "1000"
AdlibRegister("MyAdlib", 11)
Sleep( 110 ) 

_IELinkClickByText ($oIE, "Delete")
$strTemp = "5000"
Send("{ENTER}")
$strTemp = "6000"
Sleep( 110 )
ConsoleWrite("ENDING|" & @LF)
_IEQuit ($oIE)
ConsoleWrite("ENDED|" & @LF)
Exit

Func MyAdlib()
    ConsoleWrite("BGN|")
    if (WinActive("[ACTIVE]", "")) Then
        $strTemp = $strTemp + 1
        $handle = WinGetHandle("[ACTIVE]", "")
        $strTitle = WinGetTitle("[active]") 
        ConsoleWrite("Title=" & $handle & "|" & $strTitle & "|" & $strTemp & @LF)
        EndIf
    If ControlFocus("Message from webpage","OK",1) Then
        ControlClick("Message from webpage", "OK", 1)
        EndIf
    ConsoleWrite("END" & @LF)
EndFunc

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Can you get the javascript window title by AutoItWindowInfo ?

and try by replace WinActive("[ACTIVE]", "") by WinActive( $_JavascriptWindowTitle, "")

because i don't think that WinActive("[ACTIVE]", "") is a good way

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

Makes no difference as the myadlib loop freezes the moment the javascript pop-up gets shown/active.

I started using the myadlib loop to see what is happening and so faced the freezing.

As this is an external site I am trying to replicate with a local setup.

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