Jump to content

MSIE Troubles


Recommended Posts

$x = 1
RunWait(@ComSpec & " /c " & 'start explorer ' & '"' & 'http://www.atari.com/exchange/rct3/item?id=' & $x & '"', "", @SW_HIDE)
WinActivate("RollerCoaster Tycoon 3 Ride Exchange")
WinWaitActive("RollerCoaster Tycoon 3 Ride Exchange")
Sleep($sec*2)
$wintext = WinGetText("")
$wintext = StringStripWS($wintext,4)
$wintext = StringSplit($wintext," ")
MsgBox(262144,'debug line ~25' , '$wintext:' & @lf & $wintext[1]);### Debug MSGBOX
If StringInStr($wintext,"/rct3/download?id=") <> "" Then
;~ $wintext = WinGetText("RollerCoaster Tycoon 3 Ride Exchange", "http://www.atari.com/exchange/rct3/download?id=" & $x)
MsgBox(262144,'debug line ~7' , '$wintext:' & @lf & $wintext[1]);### Debug MSGBOX
Else
    MsgBox(0,"failure","")
EndIf

Just trying to loop this so I can download massive ammounts of coaster tracks for RCT3. My problem is, the MSIE window text changes from "http://www.atari.com/exchange/rct3/" to '"http://www.atari.com/exchange/rct3/download?id=" & $x' when the proper control has been tabbed or moused over. I've tried every thing I can think of to get the text that GetWinText returns to match the pattern "/rct3/download." I'm obviously missing something (besides my mind). Can anyone nudge me in the correct direction?

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

Ok, I found a basic solution, it's a count of 10 TABs from the new page to the link I click/hit enter on. The only problem with this is the script will break if the number of links on the page change. I was hoping to use the WinGetText to tell the loop to stop and hit "enter" at that point. I'm posting the entire script for reference.

#include <Default.au3>
Dim $bailout = 0, $x = 0
$savepath = "D:\Program Files\Atari\RollerCoaster Tycoon® 3\Coaster Designs\"
$start = IniRead("D:\Program Files\Atari\RollerCoaster Tycoon® 3\Coaster Designs\downloads.ini", "Download", "start", "5")

For $x = $start to ($start + 500) Step 1
   RunWait(@ComSpec & " /c " & 'start explorer ' & '"' & 'http://www.atari.com/exchange/rct3/item?id=' & $x & '"', "", @SW_HIDE)
   
   WinWait("RollerCoaster Tycoon 3 Ride Exchange")
   WinActivate("RollerCoaster Tycoon 3 Ride Exchange")
   WinWaitActive("RollerCoaster Tycoon 3 Ride Exchange")
   Sleep($sec * 5)
   Send("{tab 10}{enter}")
;~  While 1
;~     WinActivate("RollerCoaster Tycoon 3 Ride Exchange")
;~     $wintext = WinGetText("RollerCoaster Tycoon 3 Ride Exchange", "http://www.atari.com/exchange/rct3/download?id=" & $x)
;~     If $wintext = 1 Then
;~        Send("{enter}")
;~        ExitLoop
;~     Else
;~        Send("{tab}")
;~     EndIf
;~     Sleep(10)
;~  WEnd
   
   If WinWaitActive("File Download", "", 30) = 1 Then
      ControlClick("File Download", "Some files can harm", "Button2", $primary, 1)
      
      WinWaitActive("Save As")
      WinActivate("Save As")
      $filename = ControlGetText("Save As", "File &name:", "Edit1")
      Send("!n" & $savepath & $filename)
      Sleep(50)
      Send("{enter}")
      Sleep(500)
      If WinExists("Save As", "Do you want to replace it?") Then
         ControlClick("Save As", "Do you want to replace it?", "Button1", $primary, 1)
      EndIf
      
      WinWaitClose("KB of download")
   Else
      MsgBox(0, "Error", "Timeout on File download.")
      IniWrite("D:\Program Files\Atari\RollerCoaster Tycoon® 3\Coaster Designs\downloads.ini", "Download", "start", $x - 1)
      $bailout = 1
      ExitLoop
   EndIf
   WinClose("RollerCoaster Tycoon 3 Ride Exchange")
Next
MsgBox(0, "Run Complete", "Finished the run." & @LF & "Started on track: " & $start & @LF & "Ended on track: " & $x - 1)
IniWrite("D:\Program Files\Atari\RollerCoaster Tycoon® 3\Coaster Designs\downloads.ini", "Download", "start", $x - 1)
Exit

The loop I have problems with is commented out with ;~

It works, but like I said, it's not fool proof. I need to make a better fool.

[Edit] Ok I'm musing here, but I'm wondering if:

I know it's possible to InetGet() the page, read it, count the <a href= HTML tags, make a loop, find the case where my loop matches the download link.... hmm. A little detailed...but hmm..........[/edit]

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

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