Jump to content

Web automation


Recommended Posts

Hello

I just recently wrote a script for auto login for myself and improved it thanks to the help I got on this forum. But I have now encountered yet another problem that I've been trying to solve for a while.

I need to click a link : I tried using _IELinkClickByIndex or _IELinkClickByText but it always return as "No match". Then I figured that the link is in a frame (or iframe) which might be the reason why it was not detected.

So how can I do this ? the frame is on left, like a menu. I cannot unfortunately show the page because one need to login :/

Edited by dvlkn
Link to comment
Share on other sites

Should it be :

$oFrame = _IEFrameGetObjByName ($oIE, "menu")

followed by the code for _IELinkClickByText ? Because in that case it did not work for me. I don't really understand the function of _IEFrameGetObjByName as well despite the help file.

Link to comment
Share on other sites

Aah I just looked at the output and it's the _IEFrameGetObjByName that does not find a match now. Although I did put the name "menu" correctly... I don't know whats wrong muttley

Edited by dvlkn
Link to comment
Share on other sites

<html>

<head>

<title>Star Kingdoms -- Menu</title>

</head>

<body bgcolor="#222222" text="#FFFFFF" link="#447CFF" vlink="#447CFF" alink="#4E9F5F" background="/images/menu-bg.gif">

<STYLE type="text/css"><!--

A:link {text-decoration: none; color: #447CFF; }

A:visited {text-decoration: none; color: #447CFF;}

A:hover { text-decoration: underline; color: #4E9F5F;}

body {

font-size: 9; font-family: Verdana;

}

table {

font-size: 9; font-family: Verdana;

}

--></STYLE>

<center>

<img src="/images/title.gif" alt="" vspace=10 hspace=0 width=80 height=35><br>

<a href="rightframe.php?s=7228" target="skmain">Menu</a><br>

<a href="status.php?s=7228" target="skmain">Status</a><br><br>

<a href="viewsector.php?s=7228&mysector=1" target="skmain">Your Sector</a><br>

<a href="viewsector.php?s=7228" target="skmain">View Sector</a><br>

<a href="explore.php?s=7228" target="skmain">Explore</a><br>

<a href="buildings.php?s=7228" target="skmain">Buildings</a><br>

<a href="research.php?s=7228" target="skmain">Research</a><br>

<a href="military.php?s=7228" target="skmain">Military</a><br><br>

<a href="probes.php?s=7228" target="skmain">Probe Room</a><br>

<a href="attack.php?s=7228" target="skmain">Attack Room</a><br>

<a href="missile.php?s=7228" target="skmain">Missile Room</a><br><br>

<a href="alliances.php?s=7228" target="skmain">Alliances</a><br>

<a href="politics.php?s=7228" target="skmain">Sector Politics</a><br>

<a href="forums.php?s=7228" target="skmain">Sector Forums</a><br>

<a href="alliance-forums.php?s=7228" target="skmain">Alliance Forums</a><br><a href="http://forums.starkingdoms.com/viewforum.php?f=11" target="skmain">Public Forums</a><br><a href="sendmessages.php?s=7228" target="skmain">Messages</a><br>

<a href="sendaid.php?s=7228" target="skmain">Send Aid</a><br><br>

<a href="scores.php?s=7228" target="skmain">Scores</a><br>

<a href="news.php?s=7228" target="skmain">Sector News</a><br>

<a href="uninews.php?s=7228" target="skmain">Universal News</a><br>

<a href="alliancenews.php?s=7228" target="skmain">Alliance News</a><br><br>

<a href="shield.php?s=7228" target="skmain">Shields</a><br>

<a href="pref.php?s=7228" target="skmain">Preferences</a><br>

<a href="rewards.php?s=7228" target="skmain">Rewards</a><br><br>

<a href="logout.php?s=7228" target="_top">Logout</a><br><br>

</center>

<! -- Copyright BSG Online Games �2001-2005. All rights reserved -->

</body>

</html>

Edited by dvlkn
Link to comment
Share on other sites

Oh my bad, here it is :

<html>

<head>

<title>Star Kingdoms</title>

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">

<script type="text/javascript">

//<!--

function setframe(rows) {

var fs = document.getElementById('skright');

fs.rows = rows;

}

//-->

</script>

</head>

<frameset style="background-color: #000000;" cols="100,*" border=0 FRAMEBORDER=0>

<frame name="menu" src="/scripts/menu.php?s=8673" scrolling=true marginheight=0 marginwidth=0>

<frameset style="background-color: #000000;" rows="*,20" border=0 FRAMEBORDER=0 id="skright" >

<frame name="skmain" src="/scripts/rightframe.php?login=true&s=1414&lastip=RZN1hQMZ27K9a%2Bsl%2BO%2BXWQ%3D%3D&lastdate=bfUImBEQwgZO4JC3D5nRjV%2BTGCUFN%2Btm" scrolling=true marginheight=0 marginwidth=0>

<frame name="chatbox" src="/scripts/chat.php?s=6280&o=1" scrolling="no">

</frameset>

</frameset>

</html>

The frame name is "menu" isnt it ?

Edited by dvlkn
Link to comment
Share on other sites

Basically, the code looks like this:

#include <IE.au3>

$oIE = _IECreate("http://starkingdoms.com/")
$oForm = _IEFormGetCollection ($oIE, 0)
$oAccount = _IEFormElementGetCollection ($oForm, 0)
$oPass = _IEFormElementGetCollection ($oForm, 1)

_IEFormElementSetValue ($oAccount,"User")
_IEFormElementSetValue ($oPass,"Pass")
_IEFormSubmit ($oForm,0)
_IELoadWait($oIE)


_IELinkClickByText ($oIE, "Terra Nova")
_IELoadWait($oIE)

;that's where autoIT stops

$oFrame = _IEFrameGetObjByName ($oIE, "menu")
_IEFrameGetObjByName ($oFrame, "Military")
Link to comment
Share on other sites

#RequireAdmin
#include <IE.au3>

$oIE = _IECreate("http://www.starkingdoms.com/login/")
WinSetState($oIE, "", @SW_MAXIMIZE)
_IELoadWaitTimeout(5000)

$oForm = _IEFormGetCollection($oIE, 0)
$oAccount = _IEFormElementGetCollection($oForm, 0)
$oPass = _IEFormElementGetCollection($oForm, 1)

_IEFormElementSetValue($oAccount, "Username")
_IEFormElementSetValue($oPass, "Password")
_IEFormSubmit($oForm, 0)
_IELoadWait($oIE)

$oElements = _IELinkGetCollection($oIE)
For $oElement In $oElements
    If StringInStr($oElement.innertext, "Terra Nova") Then
        _IEAction($oElement, "click")
        _IELoadWait($oIE)
    EndIf
Next

$oFrame = _IEFrameGetObjByName ($oIE, "menu")
_IELinkClickByText ($oFrame, "Menu")
_IELoadWait($oIE)

Here it is then

Edited by TerarinKerowyn

Contact via MSN: [email=terarink_msn@hotmail.com]terarink_msn@hotmail.com[/email], yahoo: terarink_yah

Link to comment
Share on other sites

Eww I discovered a horrible mistake in my code :) I got it working now, thanks a bunch

EDIT: I'll post back here if I encounter any further problems muttley

Edited by dvlkn
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...