Jump to content

Problem with _IECreateEmbedded opening new tab


Recommended Posts

Although not difficult to create a script with the ability to reproduce the issue (probably), you should still do so...or even post your own code.

The responses will be quicker.

You'll probably need to intercept the click, and create a second embedded browser...maybe use one embedded browser for each GUICtrlCreateTabItem (which are child objects of GUICtrlCreateTab)

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

The script i use to test this problem is here :

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>

$url = "file://c:/loop-it.htm"
;$url = "file://c:/loop-it.html"

Opt("GUIOnEventMode", 1)

Local $oIE = _IECreateEmbedded()
$Form1 = GUICreate("Form1", 641, 481, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "_CLOSEClicked")
GUICtrlCreateObj($oIE, -1, -1, 641, 481)
ObjEvent($oIE, "IEEvent_", "DWebBrowserEvents2")
GUISetState() ;Show GUI

_IENavigate($oIE, $url)

Func IEEvent_NavigateError()
    MsgBox(0, "Error", "Navigation Error")
EndFunc

Func _CLOSEClicked()
    exit
EndFunc
        
While 1
        Sleep(500)
WEnd

Content of "file://c:/loop-it.htm"

<html>
<a name="loopit" href="file:///C:/loop-it.htm" target="_blank">Loop opening this page</a>
</html>

While both it's not event part of my script, the problem i need to solve is described by that.

Sorry for my bad English,, Hope for help soon as i only have to work fully on this in the weekend,, : :'( :

Link to comment
Share on other sites

your trying (hoping) to pop up IE page from inside autoit, dont think it can work with popup
 

<html>
<a name="loopit" href="C:\somepathifneeded\loop-it.htm">Loop opening this page</a>
</html>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
 
$url = "C:\somepathifneeded\loop-it.htm"
Opt("GUIOnEventMode", 1)
 
Local $oIE = _IECreateEmbedded()
$Form1 = GUICreate("Form1", 641, 481, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "_CLOSEClicked")
GUICtrlCreateObj($oIE, -1, -1, 641, 481)
ObjEvent($oIE, "IEEvent_", "DWebBrowserEvents2")
GUISetState() ;Show GUI
 
_IENavigate($oIE, $url)
 
Func IEEvent_NavigateError()
    MsgBox(0, "Error", "Navigation Error")
EndFunc
 
Func _CLOSEClicked()
    exit
EndFunc
 
While 1
        Sleep(500)
WEnd

i wonder if maybe like jdelaney already told changing to no popup (intercepting) and with handelling events to open new tab (new autoit embed) if link is clicked can work

edit: lots of edit :P

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

Let's say the html code above is emulation of the "real" problem i try to solve.

The thing is that the page i working on is not something i can change - it's local public wifi login page, which when the login success, the page redirect automatically to a page that have popup waiting to be opened. As i work on this, i find that the only way to alter the page is after it downloaded or loaded, so basically i can't change the page before it loaded. The problem is solved when : a. the page can be altered before get to displayed or b. There is a way to handle popup window generated from redirected web page in _IECreateEmbedded UDF function,,

Well, just in case anyone can figure out something, here is html code for login page :

<html><head>
<title>Web Authentication</title>
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<style>
<!--
DIV.sidebar {
    RIGHT: 0px;
    POSITION: absolute;
    TOP: -1px;
    HEIGHT: 100%;
    width: 200;
}
DIV.graybar {
    RIGHT: 0px; POSITION: absolute; TOP: 0px; HEIGHT: 100%; BACKGROUND-COLOR: #f8f8f8
}
/* background not be shown for NEC */

DIV.header {
    BACKGROUND-POSITION: right 50%; LEFT: 0px; BACKGROUND-IMAGE:  url(images/background_web41.jpg); WIDTH: 100%; BACKGROUND-REPEAT: repeat; POSITION: absolute; TOP: 0px; HEIGHT: 52px; BACKGROUND-COLOR: #FFFFFF}


DIV.content {
    LEFT: 14px; MARGIN: 15px; POSITION: absolute; TOP: 60px
}
H1 {
    FONT-WEIGHT: bold; FONT-SIZE: 19px; MARGIN: 16px 0px 0px 25px; COLOR: #ffffff; FONT-FAMILY: Tahoma, Arial, Helvetica, sans-serif
}
H2 {
    FONT-WEIGHT: bold; FONT-SIZE: 15px; MARGIN: 10px 0px 0px 10px; COLOR: #336666; FONT-FAMILY: Arial, Helvetica, sans-serif
}
INPUT {
    FONT-SIZE: 12px; FONT-FAMILY: Arial, Helvetica, sans-serif
}
INPUT.button {
    MARGIN-TOP: 10px; FONT-WEIGHT: bold; WIDTH: 80px; COLOR: #ffffff; BACKGROUND-COLOR: #669999
}
P {
    FONT-SIZE: 12px; MARGIN: 0px 0px 10px; COLOR: #001133; FONT-FAMILY: Arial, Helvetica, sans-serif
}
TD {
    FONT-WEIGHT: bold; FONT-SIZE: 12px; COLOR: #336666; FONT-FAMILY: Arial, Helvetica, sans-serif
}
TD.message {
    FONT-WEIGHT: normal; COLOR: #000000
}
-->
</style>

<noscript>
<meta HTTP-EQUIV="REFRESH" content="0; url=http://1.1.1.1/login_noscript.html">
</noscript>

<script language="javascript" src="loginscript.js"></script>
<script>
function getErrorMsgIfAny(){
 if(document.forms[0].err_flag.value == 1){
    document.writeln(' \
     <tr align="center"> <td colspan="2" style="color:#CC0000">Login Error.</td>\
     </tr><tr align="center"> <td width="350" class="message" colspan="2">The User Name and Password combination you have entered is invalid. Please try again.</td></tr>\
    <tr> <td class="caption" colspan="2">&nbsp;</td></tr>');
 }else{
   document.writeln(' ');
 }
}

function unhideform(){
     document.getElementById("formId").style.display = "block";
}
</script>
</head>
<body leftmargin="0" topmargin="0" onload="unhideform();" bgcolor="#ffffff" marginheight="0" marginwidth="0" text="#000000">
<form method="post" action="/login.html">
<input name="buttonClicked" size="16" maxlength="15" value="0" type="hidden">
<input name="err_flag" size="16" maxlength="15" value="0" type="hidden">
<input name="err_msg" size="32" maxlength="31" value="" type="hidden">
<input name="info_flag" size="16" maxlength="15" value="0" type="hidden">
<input name="info_msg" size="32" maxlength="31" value="" type="hidden">
<input name="redirect_url" size="255" maxlength="255" value="" type="hidden">
<div style="display: block;" id="formId">
<table cellpading="0" border="0" cellspacing="0" width="100%">
   <tbody><tr>
     <td style="padding-bottom: 4px;" align="center" background="background_web41.jpg" width="180">

     <h1>Login</h1>
     </td>

     <td style="padding-bottom: 4px; padding-right: 20px;" align="right" background="background_web41.jpg" height="53"><div align="right"><img src="cisco-webauth-logo-2007.gif" height="40" width="67"></div></td>

   </tr>
   <tr>
        <td align="left" width="400">
        <div class="content">
            <table border="0" cellpadding="0" cellspacing="10">
            <tbody><tr>
                <td>
                    <table border="0" cellpadding="0" cellspacing="10">
                        <tbody><tr>
                            <th align="left" width="400">
                                Welcome to the Cisco wireless network
                            </th>
                        </tr>
                        <tr>
                            <td class="message" align="left" width="400">
                                Cisco is pleased to provide the Wireless
 LAN infrastructure for your network. Please login and put your unified
wireless solution to work.  
                            </td>
                        </tr>
                    </tbody></table>
                </td>
            </tr>
                <script>
                    getErrorMsgIfAny();
                </script>

            <tr>
                <td>
                    <table border="0" cellpadding="0" cellspacing="10">
                        <tbody><tr>
                            <td nowrap="nowrap" width="100">User Name</td>
                            <td>
                                <input name="username" size="25" maxlength="80" type="TEXT">
                            </td>
                        </tr>
                        <tr>
                            <td nowrap="nowrap">Password</td>
                            <td>
                                <input name="password" emweb_type="PASSWORD" autocomplete="off" onkeypress="submitOnEnter(event);" size="25" maxlength="127" value="" type="Password">
                            </td>
                        </tr>
                        <tr>
                            <td>&nbsp;</td>
                            <td>
                                <script>getHtmlForButton("Submit","Submit","button","submitAction()"); </script><input name="Submit" value="Submit" class="button" onclick="submitAction()" type="button">

                            </td>
                        </tr>
                    </tbody></table>
                </td>
             </tr>

            </tbody></table>
        </div>
        </td>
        <td align="right">
            <table border="0" cellpadding="0" cellspacing="10">
                <tbody><tr>
                    <td style="padding-top: 25px; padding-right: 20px;" align="right" bgcolor="#ffffff">
                    <div></div></td>
                </tr>
            </tbody></table>   
        </td>
   </tr>
</tbody></table>
</div>
</form>


<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">


</body></html>

And here is the page that loaded AFTER LOGIN SUCCESSFULL :

<html><head>
<style>
<!--
h1 {
    font-family: Tahoma, Arial, Helvetica, sans-serif;
    color: #787a7f;
    font-size: 19px;
    font-weight: bold;
    margin-bottom: 10px;
}
td {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
    font-weight: bold;
    color: #336699;
    padding: 10px 5px 0px 0px;
}
td.caption {
    font-size: 12px;
    font-weight: normal;
    color: #000000;
    padding: 2px;
}
input.button {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-weight: bold;
    background-color: #c9cbd4;
    color: #333333;
    width: 80px;
}
-->
</style>
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Logged In</title>
</head>
<body topmargin="50" bgcolor="#DADCE5" marginheight="50">
<form method="post" action="/login_success.html">
<input name="redirect_url" size="255" maxlength="255" value="" type="hidden">
<input name="logoutPageName" size="255" maxlength="255" value="logout.html" type="hidden">
</form>

<noscript>
    <meta HTTP-EQUIV="REFRESH" content="0; url=">
</noscript>
<!--
<script>
var logoutPage = document.forms[0].logoutPageName.value;
function getLogout()
{
   parent.location.href = logoutPage;
}
</script>
 -->
<script>
var logoutPage = "logout.html";
function getLogout()
{
   parent.location.href = logoutPage;
}
</script>
  <div align="center">
    <h1>Web Authentication</h1>
    <table border="0" cellpadding="0" cellspacing="0">
      <tbody><tr>
        <td align="center">Login Successful</td>
      </tr>
      <tr>
        <td class="caption" align="center" width="340"> You can now use all our regular network services over the wireless network.<br>
          Keep the small logout window around so that you can logout
successfully when done. Else you can always goto following url to
logout:
          
           
            <a href="javascript:getLogout();">http://1.1.1.1/<script> document.write(logoutPage) </script></a></td>
           
          
      </tr>
      <tr>
        <td class="caption">&nbsp;</td>

      </tr>
<script>
/* Note: Value 'ILLEGAL_ACCESS' means this page has been attemted to access directly rather than a
    redirect from login page. So in that case better redirect user to login page again */
    if(document.forms[0].redirect_url.value != "ILLEGAL_ACCESS"){

        var editWindow = window.open(logoutPage,"AirespaceWebAuthLogoutPage","left=0 top=0 menubar=yes,scrollbars=yes,toolbar=yes,width=310,height=250,status=yes,resizable=yes");

        if(document.forms[0].redirect_url.value != ""){
            var redirurl = document.forms[0].redirect_url.value;
            var searchString = "http";
            var equalIndex = redirurl.indexOf(searchString);
            if(equalIndex != 0) {
                redirurl = "http://" + redirurl;
            }
            window.location.href = redirurl;
        }
     }
     else
       window.location.href = "login.html";
</script>
    </tbody></table>
  </div>



<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">




</body></html>

Sorry for my bad English when it's make you confussed even more,, o:)

Link to comment
Share on other sites

Although not difficult to create a script with the ability to reproduce the issue (probably), you should still do so...or even post your own code.

The responses will be quicker.

You'll probably need to intercept the click, and create a second embedded browser...maybe use one embedded browser for each GUICtrlCreateTabItem (which are child objects of GUICtrlCreateTab)

"second embedded browser" can you give me an example script ??. Would be great if i can change window name to "_blank" so any popup window goes there,,

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...