Jump to content

IE.au3, Javascript redirecting, frames, and other madness.


Recommended Posts

Hey all. I'm trying to use IE.au3 to automate a seemingly simple task - Automating the queue in Tribalwars.net

The problem lies in that that page you build things from lies in the second of two frames:

<frameset cols="*, 130", frameborder="0" framespacing="0" border="0"> -->

<frame frameborder="0" marginwidth="5" marginheight="5" border="0" src="game.php?screen=overview&intro&popup" name="main">

<frame frameborder="0" scrolling="no" noresize marginwidth="7" marginheight="0" src="http://www.tribalwars.net/ad_sky.php?zone_id=game&switch_url=http%3A%2F%2Ftw8.tribalwars.net%2Fstaemme.php%3Fscreen%3Doverview%26intro%26no_sky" name="sky">

</frameset>

And that page contains this JS to make sure you only view it from where you're supposed to:

//<![CDATA[

if(!top || top.frames.length < 2) { top.location="staemme.php?village=47309&screen=main";}

//]]>

So then, trying to get the index of (24+) links on the top pages results in nothing, and navigating to that page doesn't do anything. You cannot grab the frame by name, either. I tried to using this:

$oFrame = _IEFrameGetObjByName( $oIE, "sky" )
_IEBodyWriteHTML ($oFrame, "Hello <b>iFrame!</b>")

And lo, it didn't work.

So how can I retrieve (and click) a certain link with a certain index inside the second of two frames in a parent page?

P.S. I hope this isn't too much of a brainbuster.

Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite
Link to comment
Share on other sites

All cleared up, but thanks for the look!

#include <IE.au3>

$World = 8
$Building = "wall"

;~ $oIE = _IEAttach ("Tribal Wars")

$oIE = _IECreate ("http://www.tribalwars.net/", 0, 0)
_IEFormImageClick ($oIE, "button.php?type=world&text=World+"&$World, "src")
_IENavigate($oIE,"http://tw8.tribalwars.net/game.php?village=47309&screen=main")

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

$oLinks = _IELinkGetCollection ($oFrame)

$i = 0
For $oLink In $oLinks
    If StringInStr($oLink.href,"action=build&id=" & $Building) Then ExitLoop
    $i = $i + 1
Next

_IELinkClickByIndex($oFrame, $i)
Ha, I haven't been on these forums since... 2006, almost. Behold, my legacy signature:My AutoIt idol is Valuater. You know you love him, too.My Stuff: D&D AGoT Tools Suite
Link to comment
Share on other sites

Good job...

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 have a similar problem with an other browsergame: Ogame.

when I open a link like:

in the new page appears the following:

<script type="text/javascript"> if (parent.frames.length == 0) { top.location.href = "http://www.ogame.it/"; } </script>

In addition, the line: _IEFrameGetCollection gives 1 as result!

by opening the page with FrontPage, I get that there are two frames but when I use _IEFrameGetObjByName (with the name of each frame) the result is @error 7 = no match.

Why? i dont understand. Beside the problem looks similar to the one of Josh DB, but his script doesnt work with me. what can i give you to let you help me for this?

thank you in advance

Link to comment
Share on other sites

Piling on to existing threads, especially dormant, resolved one is not typically done in this forum. Please start a new thread for a new question.

That said, please try:

#include <IE.au3>
$oIE = _IECreate("your-url")
ConsoleWrite(_IEDocReadHTML($oI$) & @CR)

and look at the output to see if it is what you expect it to be.

Please start a new thread to continue your questions.

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

  • 1 month later...

Hi Dale,

Tried your last bit of code and the output is as expected --> the code from the main frame.

Pulling up the page in FireFox's DOM viewer (or IEDovMon) shows:

the first frameset:

<FRAMESET border=0 frameSpacing=0 rows=*,0,0 frameBorder=no>

<FRAME name=mainframe src="home.php" frameBorder=0 noResize scrolling=yes></FRAMESET>

Anyways - the new thread is started under http://www.autoitscript.com/forum/index.php?showtopic=48117

Grtz,

Rick

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