Jump to content

Clicking on a JavaScript button in Explorer


 Share

Recommended Posts

Greetings all,

Novice at scripting and trying to write a script to automate a login process for SSL-VPN connection and have gotten to the point of logging in but the final step to make the connection is to click on a "button in the page that appears to be a javascript. when you mouse over the "button" the Window info is as follows:

>>>>>>>>>>>> Window Details <<<<<<<<<<<<<

Title: SonicWALL - Virtual Office - Microsoft Internet Explorer

Class: IEFrame

Size: X: 58 Y: 58 W: 960 H: 663

>>>>>>>>>>> Mouse Details <<<<<<<<<<<

Screen: X: 198 Y: 477

Cursor ID: 0

>>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<<

RGB: Hex: 0x038F3E Dec: 233278

>>>>>>>>>>> Control Under Mouse <<<<<<<<<<<

Size: X: 0 Y: 103 W: 952 H: 503

Control ID:

ClassNameNN: Internet Explorer_Server1

Text:

>>>>>>>>>>> Status Bar Text <<<<<<<<<<<

(1): java script:opennetextenderwin();

(2):

(3):

(4):

(5):

(6):

(7): SSL Secured (128 Bit)

(8): Internet

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<

Google

Links

https://XXX.XXX.XXX.XXX/cgi-bin/portal

https://XXX.XXX.XXX.XXX/cgi-bin/portal

java script:opennetextenderwin();

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<

I have tried MouseClick (with the XY coords) and also sending multiple tabs then enter but cannot get this to activate the button.

Any Ideas

Ed Andre

Link to comment
Share on other sites

Can you right click in the ie window and view source. Copy the source code and paste it here and I should be able to help you.

Here it is, thanks in advance

********************************************************************************

<html><head><title>SonicWALL - Virtual Office</title><meta http-equiv='pragma' content='no-cache'><meta http-equiv='cache-control' content='no-cache'><meta http-equiv='cache-control' content='must-revalidate'><meta http-equiv='Content-Type' content='text/html;charset=UTF-8'><link href='/themes/styleblueblackgrey.css' rel=stylesheet type='text/css'>

<script>

var userName='test';

var userDisplayName='test';

var useCacheCleaner="0";

var home1Flag="0";

var home2Flag="1";

var home3Flag="1";

var netExtenderFlag="1";

var servicesPageFlag="0";

var tscApplicationsPageFlag="0";

var desktopPageFlag="0";

var cifsPageFlag="1";

var onlineHelpFlag="0";

var adminFlag="0";

bannerTitle = "Virtual Office";

window.status="SonicWALL - Virtual Office";

window.defaultStatus="SonicWALL - Virtual Office";

var winpopper=0;

var netwin=0;

function resizeapps(heights) {

document.getElementById("main").style.height=heights;

document.getElementById("main").src='/cgi-bin/services';

}

function resizeme(heights) {

document.getElementById("main").style.height=heights;

}

docObj = (document.all) ? "document.all." : "document."

function launchMenu() {

var framer;

framer = window.main.location.toString();

var newvar=framer.lastIndexOf('cgi-bin');

var startvar=newvar+8;

var endvar=newvar+12;

var temps=framer.substring(startvar,endvar);

winpopper=window.open("/cgi-bin/onlineHelp?key=userPortal","OnlineHelp","width=700,height=500,resizable,scrollbars,toolbar,location,menubar,status");

winpopper.focus(); return false;

}

function NetworkPls() {

var popurl='/cgi-bin/entirenetwork/';

netwin=window.open(popurl,"network","width=770,height=545,scrollbars=yes,resizable");

netwin.focus(); return;

}

function userslogout() {

if (winpopper!=0){if(!winpopper.closed) winpopper.close();}

if (netwin!=0){if(!netwin.closed) netwin.close();}

window.location.href='/cgi-bin/userLogout/';

window.main.closechildren();

}

function no_error() {

return true;

}

window.onerror=no_error;

function closeIt() {

if(useCacheCleaner == "1") {

var clicklocation=window.event.clientX-document.body.clientWidth;

if(clicklocation>1){

MLWebCacheCleaner1.CacheCleanAndHistory(location.hostname);

}

}

}

function onloadFunc() {

if(adminFlag == "1") {

document.getElementById("logoutTable").style.display = 'none';

}

}

// -->

</script>

<script src="/js/portalframe.js" type="text/javascript"></script>

</head>

<body onload="onloadFunc();" onbeforeunload="closeIt();" class="loginbodyback" leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>

<center>

<table cellspacing=0 cellpadding=15 width="780" border=0>

<tr>

<td>

<table cellspacing=0 cellpadding=4 width="100%" bgColor="#FFFFFF" border=0 class="logoHeader">

<tr>

<td>

<table cellpadding=4 cellspacing=0 border=0>

<tr>

<td style="padding-top: 5px;"><img src="/images/mainlogo.gif" border=0></td>

<td valign=bottom nowrap style="padding-bottom: 4px;"><font class="logoTitle">

<script>

document.write(bannerTitle);

</script>

</font></td>

</tr>

</table>

</td>

<td align=right valign=bottom width="100%" nowrap style="padding-top: 6px;" class="portalHeader">

<table cellpadding=2 cellspacing=0 border=0>

<tr>

<td class="portalHeader" valign=bottom nowrap style="padding-bottom: 8px;"><b>Welcome, <script>document.write(userDisplayName);</script>! &nbsp; </td>

<td style="padding-bottom: 4px;"><table cellpadding=0 cellspacing=0 border=0 margin=0 id="logoutTable" style='display: block;'><TR><td width=75 class=bbcenter align=center valign=center height=21

style="padding-bottom:1px;padding-top:1px;"

onclick="java script:userslogout()"

onmouseover="java script:this.className='bbcenteron';window.status='';"

onmouseout="java script:this.className='bbcenter';"><script type="text/Javascript" language="Javascript">bbutton2("Logout",'userslogout');</script></td></tr></table>

</td>

<td><img src="/clear.gif" border=0 width=3 height=1></td>

<td style="padding-right: 8px; padding-bottom: 4px;"><table cellpadding=0 cellspacing=0 border=0 margin=0><TR><td width=75 class=bbcenter align=center valign=center height=21

style="padding-bottom:1px;padding-top:1px;"

onclick="java script:launchMenu()"

onmouseover="java script:this.className='bbcenteron';window.status='';"

onmouseout="java script:this.className='bbcenter';"><script type="text/Javascript" language="Javascript">bbutton2("Help",'launchMenu');</script></td></tr></table>

</td>

</tr>

</table>

</td>

</tr>

</table>

</td>

</tr>

</table>

<table cellspacing=0 cellpadding=0 width="750" border=0>

<tr>

<td width=10><img src="/clear.gif" height=4 width=1></td>

</tr>

</table>

<table cellspacing=0 cellpadding=0 width="750" border=0 class="logoHeader">

<tr>

<td>

<table cellspacing=0 cellpadding=0 width="750" border=0>

<tr>

<td>

<iframe name='main' id='main' src='/cgi-bin/homepage' width=750 height=485 scrolling='no' scroll='no' scrollbars='no' border=0 frameborder=0></iframe>

</td>

</tr>

</table>

</td>

</tr>

</table>

<font class=copyright>Copyright &copy; 2005 SonicWALL, Inc.</font>

</center>

</body>

</html>

<!-- v: 1.0.0.6-15sv -->

********************************************************************************

Link to comment
Share on other sites

I have tried MouseClick (with the XY coords)

While big_daddy is off working on a script for you - do you mind sharing what happened when you tried MouseClick?

Did you have the AutoItSetOption setting for MouseCoordMode set the same way that your AutoIt Active Window Tool is setup? (Coordinates relative to Screen, Window, Client...)

I'm by no means suggesting that you use MouseClick for this script - but it should work most of the time.

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

While big_daddy is off working on a script for you - do you mind sharing what happened when you tried MouseClick?

Did you have the AutoItSetOption setting for MouseCoordMode set the same way that your AutoIt Active Window Tool is setup? (Coordinates relative to Screen, Window, Client...)

I'm by no means suggestion that you use MouseClick for this script - but it should work most of the time.

I did try mouse click and it moves to the button but then nothing happens

here is my Script ( Lame I know but I am a newbie )

***************************************************************

;

; Script Function:

; Auto Logon to SSL-VPN

;

Run("C:\\Program Files\\Internet Explorer\\iexplore.exe XXX.XXX.XXX.XXX")

WinWaitActive("Security Alert", "", 5)

ControlClick ("Security Alert","&Yes",1,"Left")

WinWaitActive("SonicWALL - Virtual Office - Microsoft Internet Explorer", "", 5)

MouseClick ("Left",489,354,1)

WinWaitActive("SonicWALL - Virtual Office - Microsoft Internet Explorer", "", 10)

Send ("Username{TAB}Password{ENTER}")

WinWaitActive("SonicWALL - Virtual Office - Microsoft Internet Explorer", "", 30)

MouseClick ("left",135,415,1)

***************************************************************

Link to comment
Share on other sites

Is the button you are trying to click inside or outside the iframe? The iframe is the part in the middle that gives you a scroll bar. If that is where the button is I need the source from that window, not the outside (or main window).

it is in the middle of the screen, not sure it is a frame. When I use AutoIT Window Info, it shows just the window is there.

Link to comment
Share on other sites

  • Moderators

it is in the middle of the screen, not sure it is a frame. When I use AutoIT Window Info, it shows just the window is there.

If it is in the middle then it is in the iFrame. View the source from the middle of the page and compare that to the source you posted earlier. If they are different post the new one here.

Link to comment
Share on other sites

If it is in the middle then it is in the iFrame. View the source from the middle of the page and compare that to the source you posted earlier. If they are different post the new one here.

Here it is

**************************************************

<html><head><title>SonicWALL - Virtual Office</title><meta http-equiv='pragma' content='no-cache'><meta http-equiv='cache-control' content='no-cache'><meta http-equiv='cache-control' content='must-revalidate'><meta http-equiv='Content-Type' content='text/html;charset=UTF-8'><link href='/themes/styleblueblackgrey.css' rel=stylesheet type='text/css'><script>var showNetExtender=1;

var showBookmarkButton=1

var installCertificate=1

var showFileShares=1</script>

<script src="/js/portalframe.js" type="text/javascript"></script>

<script LANGUAGE=Javascript TYPE="TEXT/Javascript">

<!-- Hide script from older browsers

var winpops1=false;

function launchHTTP(hostname)

{

if(hostname == ' ')

var popurl="/cgi-bin/http"

else

var popurl="/cgi-bin/http?HOST="+hostname;

winpops6=window.open(popurl,"","width=800,height=600,resizable,toolbar=yes,scrollbars=yes,location=1,menubar=1,status=1")

}

function launchHTTPS(hostname)

{

if(hostname == ' ')

var popurl="/cgi-bin/https"

else

var popurl="/cgi-bin/https?HOST="+hostname;

winpops2=window.open(popurl,"","width=800,height=600,resizable,toolbar=yes,scrollbars=yes,location=1,menubar=1,status=1")

}

function launchFTP(hostname)

{

if(hostname != ' ')

var popurl='/cgi-bin/ftp-frame?ftpipaddress='+escape(hostname)

else

var popurl="/cgi-bin/ftp-frame"

winpops3=window.open(popurl,"WelcometoFTP","width=780,height=550,resizable,scrollbars=yes")

}

function launchTelnet(hostname)

{

if(hostname != ' ')

var popurl='/cgi-bin/telnet?HOST='+escape(hostname)

else

var popurl="/cgi-bin/telnet"

winpops4=window.open(popurl,"","width=590,height=480,resizable,")

}

function launchSSH(hostname)

{

if(hostname != ' ')

var popurl='/cgi-bin/ssh?HOST='+escape(hostname)

else

var popurl="/cgi-bin/ssh"

winpops5=window.open(popurl,"","width=590,height=480")

}

function launchVNC(hostname)

{

if(hostname == ' ')

var popurl="/cgi-bin/vnc"

else

var popurl='/cgi-bin/vnc?HOST='+escape(hostname);

winpops=window.open(popurl,"VNC","width=520,height=310,resizable")

}

function launchRDP4(bookmark,usertype)

{

var popurl='/cgi-bin/tscbookmark?proto=RDP4&bookmark='+escape(bookmark)+'&type='+escape(usertype);

winpops4=window.open(popurl,"WindowsTerminalConnection","width=520,height=310,resizable");

}

function launchRDP5(bookmark,usertype)

{

var popurl='/cgi-bin/tscbookmark?proto=RDP5&bookmark='+escape(bookmark)+'&type='+escape(usertype);

winpops4=window.open(popurl,"WindowsTerminalConnection","width=520,height=310,resizable");

}

function launchTSC(flag)

{

var popurl="/cgi-bin/tsc?flag="+escape(flag);

winpops5=window.open(popurl,"","width=520,height=310,resizable")

}

function launchCIFS(bookmark, isFile) {

winpops4=window.open(bookmark,"CIFS","width=770,height=545,scrollbars=yes,resizable");

winpops4.focus();

}

var netExtenderWin = null;

function opennetextenderwin() {

var agent = navigator.userAgent.toLowerCase();

if (agent.indexOf("msie") != -1){

if((netExtenderWin && (!netExtenderWin.closed)) && netExtenderWin.XTunnel) {

netExtenderWin.XTunnel.HideWndow(false);

netExtenderWin.focus();

} else {

netExtenderWin = window.open("/cgi-bin/sslvpnclient?opennetextender=yes","virtual","width=400,height=220,status=no,toolbar=no,menubar=no,location=no");

}

}

else{

alert('NetExtender requires Internet Explorer 5.0 and greater');

}

}

function launchaddbookmark()

{

if (numUserBookmarks == 12)

{

alert('You have reached the maximum number of personal bookmarks.');

return;

}

var popurl3="/cgi-bin/addPortalBookmark"

winpops5=window.open(popurl3,"Bookmark","width=400,height=260,resizable,")

}

function onloadFunc() {

resizer();

}

function editbookmark(bookmarkurl, host, owner, name)

{

var width=400;

var height=253;

var x = (800 - width)/2;

var y = (600 - height)/2;

if (screen)

{

y = (screen.availHeight - height)/2;

x = (screen.availWidth - width)/2;

}

winpops5 = window.open(bookmarkurl + escape(host) + '&owner=' + escape(owner) + '&name=' + escape(name),"Bookmark","scrollbars=no, resizable=no, width=400, height=253, top=" + y + ", left=" + x + ", screenX=" + x + ", screenY=" + y) ;

winpops5.focus();

}

//-->

</script>

</head>

<body class="mainback" margin=0 topmargin=0 leftmargin=0 marginwidth=0 marginheight=0 onload="onloadFunc();" style="overflow-x:hidden;overflow-y:hidden">

<table border=0 cellpadding=0 cellspacing=0 width=542 valign="top" align="left">

<tr>

<td width=20><img src="/images/shim.gif" height=385 width=20></td>

<td width=513 valign="top">

<table cellspacing=0 cellpadding=0 width="750" border=0>

<tr>

<td width=10><img src="/clear.gif" height=12 width=1></td>

</tr>

</table>

<table cellspacing=0 cellpadding=0 border=0 valign=top width=513> <tbody><tr><td width=513 height=11> <span style='line-height:120%'><font class=toolbar2><table cellspacing=0 cellpadding=0 border=0 valign=top>

<tr>

<td width=500 valign=top>

<font class=toolbar style="font-size:18px;"><B>Welcome to the SonicWALL Virtual

Office</b></font>

<BR><img src=/images/shim.gif width=1 height=6 border=0><BR>

<span style="line-height:115%;">

<font class=toolbar2>

SonicWALL Virtual Office provides secure Internet access for remote users to log in and access private network resources via SSL-VPN technology.

<BR><img src=/images/shim.gif width=1 height=6 border=0><BR>

Click a pre-configured bookmark or create your own to gain secure Internet access to internal corporate resources.

<BR><img src=/images/shim.gif width=1 height=6 border=0><BR>

Launch NetExtender to create an SSL-VPN tunnel to your corporate network for full network access.

</font>

</span>

</td>

</tr></table>

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

if(showNetExtender == "1" || showFileShares == "1") {

document.write('<table cellspacing=0 cellpadding=0 width="500" border=0><tr><td width=10><img src="/clear.gif" height=20 width=1></td></tr></table>');

document.write('<table border=0 cellpadding=0 cellspacing=0 width="500"><tr>');

if(showNetExtender == "1") {

document.write('<td width="35%">');

document.write('<table border=0 cellpadding=4 cellspacing=0 width="320" class=logoHeader>');

document.write('<tr><td><a href="java script:opennetextenderwin();"');

document.write('title="Launch NetExender to create an SSL-VPN tunnel to your corporate network. Keep the NetExtender window open to maintain the connection."');

document.write('><img border=0 src="/images/passage2.gif"></a></td>');

document.write('<td nowrap class=toolbar>&nbsp;<a href="java script:opennetextenderwin();"');

document.write('title="Launch NetExender to create an SSL-VPN tunnel to your corporate network. Keep the NetExtender window open to maintain the connection."');

document.write('><font color="#333333"><b>NetExtender</b></font></a></td>');

document.write('<td width="100%">&nbsp;</td></tr></table></td>');

document.write('<td width="30%"><img src="/clear.gif" width=72 height=1></td>');

}

if(showFileShares == "1") {

document.write('<td width="35%">');

document.write('<table border=0 cellpadding=4 cellspacing=0 width="320" class=logoHeader>');

document.write('<tr><td><a href="java script:parent.NetworkPls();"');

document.write('title="Browse the network neighborhood, open and download files, upload files, and rename files and directories."');

document.write('><img border=0 src="/images/netPlaces.gif"></a></td>');

document.write('<td nowrap class=toolbar>&nbsp;<a href="java script:parent.NetworkPls();"');

document.write('title="Browse the network neighborhood, open and download files, upload files, and rename files and directories."');

document.write('><font color="#333333"><b>File Shares</b></font></a></td>');

document.write('<td width="100%">&nbsp;</td></tr></table></td>');

}

document.write('</tr></table>');

}

</script>

<table cellspacing=0 cellpadding=0 width="750" border=0>

<tr>

<td width=10><img src="/clear.gif" height=20 width=1></td>

</tr>

</table>

<table cellspacing=0 cellpadding=0 border=0 valign=top><tbody><tr><td> <table cellspacing=0 cellpadding=0 border=0 valign=top><tbody> <tr> <td colspan=3 class=darkback height=1><img src="/images/shim.gif" width=1 height=1 border=0></td></tr> <tr><td width=1 class=darkback><img src="/images/shim.gif" width=1 height=1 border=0></td> <td align=center> <table width=710 border=0 cellpadding=0 cellspacing=0 valign=top class=HeadingStyle> <tbody><tr height=21><td class=HeadingStyle nowrap>&nbsp;Virtual Office Bookmarks</td>

<td class="HeadingStyle" nowrap>Host/IP Address</td>

<td class="HeadingStyle" nowrap>Service</td>

<td class="HeadingStyle" nowrap>Configure</td>

</tr>

<tr>

<td width="" height=1 colspan=4 class="darkback"><img src="/images/shim.gif" width=1 height=1 border=0></td>

</tr>

<tr>

<td width="" height=4 colspan=4 bgcolor="#FFFFFF"><img src="/images/shim.gif" width=1 height=1 border=0></td>

</tr>

<tr height=25><td colspan=4 class=li><font class=toolbar>&nbsp;&nbsp;No Bookmarks</font></td></tr></tbody></table></td></tr></tbody></table></td> <td height=1 colspan=1 class=darkback><img src="/images/shim.gif" width=1 height=1 border=0></td> </tr><tr><td width=1 class=darkback colspan=4><img src="/images/shim.gif" width=1 height=1 border=0></td></tr></tbody></table>

<table cellspacing=0 cellpadding=0 width="750" border=0>

<tr>

<td width=10><img src="/clear.gif" height=8 width=1></td>

</tr>

</table>

<table cellspacing=0 cellpadding=0 width="280" border=0>

<tr>

<script>

if(showBookmarkButton == "1") {

document.write('<td><table border=0 cellpadding=0 cellspacing=0 valign=top><tr>');

document.write('<td width=82 height=21 valign=center align=center onclick="java script:launchaddbookmark();">');

document.write('<table cellpadding=0 cellspacing=0 border=0 margin=0 class=mybutton><TR>');

document.write('<td width=82 class=bbcenter align=center onmouseover="java script:this.className=\'bbcenteron\';window.status=\'\';" onmouseout="java script:this.className=\'bbcenter\';"><img src="/images/shim.gif" width=80 height=1 border=0><BR>');

bbutton2(baddbookmark,'launchaddbookmark');

document.write('<BR><img src="/images/shim.gif" width=80 height=1 border=0></td>');

document.write('</tr></table></td></tr></table></td><td width=10>&nbsp;</td>');

}

function doInstallCert() {

window.location = "/cgi-bin/installcert?referrer=sslvpnclient";

}

if(installCertificate == "1") {

document.write('<td><table border=0 cellpadding=0 cellspacing=0 valign=top><tr>');

document.write('<td width=142 height=21 valign=center align=center onclick="java script:doInstallCert();">');

document.write('<table cellpadding=0 cellspacing=0 border=0 margin=0 class=mybutton><TR>');

document.write('<td width=142 class=bbcenter align=center onmouseover="java script:this.className=\'bbcenteron\';window.status=\'\';" onmouseout="java script:this.className=\'bbcenter\';"><a href="java script:doInstallCert();" title="If the SSL-VPN Server uses a self-signed SSL certificate, it must be imported into the Root Certificate Store of your browser in order for certain SSL-VPN applications to work."><img src="/images/shim.gif" width=140 height=1 border=0><BR>');

bbutton2('Import Certificate','doInstallCert');

document.write('<BR><img src="/images/shim.gif" width=140 height=1 border=0></a></td>');

document.write('</tr></table></td></tr></table></td>');

}

</script>

<td>&nbsp;</td></tr></table>

<br>

<script>var numUserBookmarks=0;</script>

</td></tr></table></body></html>

**********************************************************************

Link to comment
Share on other sites

In your first post you said that the AutoIt Active Window Tool gives this:

>>>>>>>>>>> Mouse Details <<<<<<<<<<<

Screen: X: 198 Y: 477

...when you mouse over the button of interest

but none of the MouseClick coordinates in your script makes use of these XY coordinates?

You might want to set the MouseCoordMode to be relative to the active window:

Opt("MouseCoordMode", 0)

Place that line of code near the top of your script.

Then change the AutoIt Active Window Tool to give you coordinates relative to the active window:

Options > Coord Mode > Window

Last - change the two lines of code that use xy coords to click the mouse.

Edit: Again with the caveat - I'm not saying that MouseClick is the method to use - but it should work!

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

:lmao: Well I did find a way to make it work. I added the line below before the mouse click:

MouseMove (305,415,100)

this appears to give the page time to finish whatever it is doing and seems to work. If yall have a better sugestion please let me know. Works for now.

Link to comment
Share on other sites

...this appears to give the page time to finish whatever it is doing and seems to work.

It appears that the page was not finished loading.

You might not want a timeout on each of your WinWaitActive lines.

That would let the script continue even if the window is not present or active.

Do you really want to send username and password if the window is not there?

You might try adding this opt setting near the top of your script and adding "Done" as window text.

Opt("WinDetectHiddenText", 1) ;0=don't detect, 1=do detect

WinWaitActive("SonicWALL - Virtual Office - Microsoft Internet Explorer", "Done",)

That code might make the script wait until the webpage has finished loading before clicking.

(You can also use "Sleep" statements if you must.)

Another opt setting that you might want to use:

Opt("TrayIconDebug", 0) ;0=no info, 1=debug line info

If the script hangs, you can mouse over the AutoIt icon in the system tray and see what line number is giving you trouble.

One last thing - use SciTE4AutoIt3 to create/debug your scripts - if you are not already doing so...

http://www.autoitscript.com/autoit3/scite/

later...

Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

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