Sign in to follow this  
Followers 0
Blue_Drache

Roller Coaster Tycoon 3 Coaster Leecher

5 posts in this topic

#1 ·  Posted (edited)

Ok, here goes....I'm posting the bones of this project and will update it as I learn and go along. Feel free to post bugs, suggestions and other ideas. :lmao: All flames will be ignored.

This is to be considered a work in progress and I will support as best I can.

Remember, I'm learning too.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Name: Coaster.Au3
;
; Author: Blue Drache
; Contact: Forum only.
;
; Version: 0.5 BETA
;
; Purpose: Automatically download coaster tracks 
;           from RollerCoaster Tycoon 3's website.
;
; Requirements: An active coaster exchange account.
;               You should log in to the exchange at least once to get
;                  the auto-login cookie set.
;               MSIE 6.0 SP 1 or greater
;               An active internet account.
;
; Language written in: AutoIt v3.0.103.xxx BETA version: Jan-22-2005
;                       Download at http://www.autoitscript.com
;
; Status: Functional, but not pretty.  Brute force implementation.
;               or "Simulated Human" if you will.
;
; To Do List: Wrap program in a pretty looking GUI. 
;               Will display updated information as program runs
;                 such as current #, previous 5 track names, etc.
;             Allow simple modification of ban list through GUI
;              Figure out how to loop the darn {tab 10} section to
;              handle a variable number.......
; 
; Any and all images used are copyright respective owners.  I am not 
; responsible if your account, host, or IP range gets banned from RCT3's 
; network.  Use responsibly.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;~ #include <Default.au3>
#include <file.au3>
AutoItSetOption("WinTitleMatchMode",2)

; change this to match your main coaster path if you want the downloads to go in the main program coaster folder
$savepath = "D:Program FilesAtariRollerCoaster Tycoon® 3Coaster Designs" 

; Uncomment the next line if you want to use your My Documents RCT3 folder for saving downloaded coasters.
;~ $savepath = @MyDocumentsDir & "RCT3Coaster Designs"

Dim $bailout = 0, $x = 0, $uray, $skipped, $saved, $page = 1,$songnum = 1
$rtc3re="RollerCoaster Tycoon 3 Ride Exchange"
$inifile = $savepath & "coaster.ini"
$tempfile = @TempDir & "coaster.txt"
$start = IniRead($inifile, "Download", "start", "5")
$totalskipped = IniRead($inifile, "Download", "skipped", "0")
$totalsaved = IniRead($inifile, "Download", "saved", "0")

;~ $start = 1
$banlist = IniRead($inifile, "Download", "ban", "")
$banlist = StringSplit($banlist, ",")
For $q = 1 to $banlist[0]
StringStripWS($banlist[$q],8)
MsgBox(0,"Current Banlist: " & $q,$banlist[$q])
Next

;~ For $x = $start To $start + 3 Step 1
For $x = $start to ($start + 500) Step 1
    If WinExists($rtc3re) then winclose($rtc3re)
   RunWait(@ComSpec & " /c " & 'start explorer ' & '"' & 'http://www.atari.com/exchange/rct3/item?id=' & $x & '"', "", @SW_HIDE)
   WinWait($rtc3re)
   WinActivate($rtc3re)
   WinWaitActive($rtc3re)
   Sleep($sec * 5)
   InetGet("http://www.atari.com/exchange/rct3/item?id=" & $x, $tempfile, 1, 0)
   _FileReadToArray($tempfile, $uray)
; check the page for a name in the banlist
   For $y = 1 To $uray[0] Step 1
      For $z = 1 To $banlist[0] Step 1
         If not StringInStr($uray[$y],$banlist[$z]) = "" then; Function returns a null string if name from banlist not found.
                           WinClose($rtc3re) 
                           $skipped = $skipped + 1
            ContinueLoop 3; this breaks out of 3 levels of loop at once
                                ; this skips all the following commands to the normal "Next" operator for the $x loop.
                                ; ContinueLoop can be used in For/Next Do/Until and While/WEnd.
         EndIf
      Next
   Next
   Send("{tab 10}{enter}")
   
   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")
                  $saved = $saved + 1
   Else
      MsgBox(0, "Error", "Timeout on File download.")
      IniWrite($inifile, "Download", "start", $x - 1)
      $bailout = 1
      ExitLoop
   EndIf
   WinClose($rtc3re)
Next

MsgBox(0, "Run Complete", "Finished the run." & @LF & "Started on track: " & $start & @LF & "Ended on track: " & $x - 1 _
         & @LF & "Skipped: " & $skipped & @LF & "Saved: " & $saved)
IniWrite($inifile, "Download", "start", $x - 1)
IniWrite($inifile, "Download", "saved", $totalsaved + $saved)
IniWrite($inifile, "Download", "skipped", $totalskipped + $skipped)
Exit
Edited by Blue_Drache

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Visual Layout of GUI finished. Tenative design is attached. As of this point, no GUI code has been written yet. This is turning into a fun project and I look forward to learning the GUI aspects of AutoIt.

Grey fields are buttons.

Green fields will contain counter type data that will be updated as the program runs, or when options (such as the save-to folder or ban-list additions & subtractions) are changed.

Ideas? Comments?

Edited by Blue_Drache

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

Share this post


Link to post
Share on other sites

Visual Layout of GUI finished.  Tenative design is attached.  As of this point, no GUI code has been written yet.  This is turning into a fun project and I look forward to learning the GUI aspects of AutoIt.

Grey fields are buttons. 

Green fields will contain counter type data that will be updated as the program runs, or when options (such as the save-to folder or ban-list additions & subtractions) are changed.

Ideas?  Comments?

<{POST_SNAPBACK}>

How about a max filesize for coaster and a total max filesize

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

How about a max filesize for coaster and a total max filesize

<{POST_SNAPBACK}>

That's a good idea, I'd been kicking around a per file min/max file size configuration option....the only problem being is, I'd have to check the file size AFTER the download and spending the user's time. Meh....it's another feature though. I'll add it after I get the new method of downloading the file programmed.

I've also come to the conclusion that my way of using MSIE is a little clunky. Simulated human scripts are nice, but can break easily and hog the computer.

Since the download link is always preceeded by the # of the track on the website (ex. hxxp://www.download.track.com/download=$x), I should be able to pull the name and type of the coaster from the original InetGet() function and then use it to get the filename for an InetGet() on the download link. This would result in saving a number of steps, speeding up the script, and making the failure check easier. Whenever I download something that's greater than what the website contains, it returns an "Invalid ID" error.

God, I get bored at work.

If I keep tweaking the bones, I'll never get to the GUI.

And I hope that the devs don't mind that I'm using this forum for a personal scratch pad on this thing I'm writing. I'll probably be posting in this topic quite a bit as I go along with ideas and code scraps.

Edited by Blue_Drache

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

Share this post


Link to post
Share on other sites

OK, a long time in coming, but I decided to re-visit this program and upload the GUI that I developed for it. Haven't inserted the main code yet though.

#include <GUIConstants.au3>
Dim $hWnd_PrimaryGUI, $hWnd_BanListGUI, $hWnd_ConfigGUI, $aWndo_Location
Dim $version = "0.7 Beta-GUI"
If Not FileExists(@ScriptDir & "\CL_Primary.gif") Then
   FileInstall(@ScriptDir & "\CL_Primary.gif", @ScriptDir & "\", 1)
   FileInstall(@ScriptDir & "\CL_BanList.gif", @ScriptDir & "\", 1)
   FileInstall(@ScriptDir & "\CL_Config.gif", @ScriptDir & "\", 1)
    FileInstall(@ScriptDir & "\CL_HelpFile.txt", @ScriptDir & "\", 1)
EndIf
PrimaryGUI()

While 1 ; primary data loop
    If WinActive("Coaster Leech") = 1 Then
        HotKeySet("{F1}","HelpContents") ; set the hotkey if the window's active
    Else
        HotKeySet("{F1}") ; release the key when it's not active.
    EndIf
   Sleep(10)
   $msg = GUIGetMsg()
   Select
;~**********************************************************************************
      Case $msg = $GUI_EVENT_CLOSE Or $msg = $button_exit
         Exit
;~**********************************************************************************
      Case $msg = $button_banlist
         $aWndo_Location = WinGetPos($hWnd_PrimaryGUI)
         GUISetState(@SW_HIDE, $hWnd_PrimaryGUI)
         If $hWnd_BanListGUI = "" Then
            BanListGUI($aWndo_Location[0], $aWndo_Location[1])
         Else
            WinMove($hWnd_BanListGUI, "", $aWndo_Location[0], $aWndo_Location[1])
            GUISetState(@SW_SHOW, $hWnd_BanListGUI)
         EndIf
         While 1 ; BanList Data Loop
            $msg_ban = GUIGetMsg()
            Select
               Case $msg_ban = $GUI_EVENT_CLOSE Or $msg_ban = $button_exitban
                  Exit
               Case $msg_ban = $button_backban
                  ExitLoop
            EndSelect
         WEnd
         $aWndo_Location = WinGetPos($hWnd_BanListGUI)
         GUISetState(@SW_HIDE, $hWnd_BanListGUI)
         WinMove($hWnd_PrimaryGUI, "", $aWndo_Location[0], $aWndo_Location[1])
         GUISetState(@SW_SHOW, $hWnd_PrimaryGUI)
;~**********************************************************************************
      Case $msg = $button_config
         $aWndo_Location = WinGetPos($hWnd_PrimaryGUI)
         GUISetState(@SW_HIDE, $hWnd_PrimaryGUI)
         If $hWnd_ConfigGUI = "" Then
            ConfigGUI($aWndo_Location[0], $aWndo_Location[1])
         Else
            WinMove($hWnd_ConfigGUI, "", $aWndo_Location[0], $aWndo_Location[1])
            GUISetState(@SW_SHOW, $hWnd_ConfigGUI)
         EndIf
         While 1 ; Config Data Loop
            $msg_config = GUIGetMsg()
            Select
               Case $msg_config = $GUI_EVENT_CLOSE Or $msg_config = $button_exitconfig
                  Exit
               Case $msg_config = $button_backconfig
                  ExitLoop
            EndSelect
         WEnd
         $aWndo_Location = WinGetPos($hWnd_ConfigGUI)
         GUISetState(@SW_HIDE, $hWnd_ConfigGUI)
         WinMove($hWnd_PrimaryGUI, "", $aWndo_Location[0], $aWndo_Location[1])
         GUISetState(@SW_SHOW, $hWnd_PrimaryGUI)
;~**********************************************************************************
        Case $msg = $hMenuItem_HelpPrimaryAbout 
            MsgBox(0,"About","Author: Blue Drache" & @LF & "DracWerks Productions 2k5" & @LF & @LF & @LF & "Version: " & $version)
;~**********************************************************************************
        Case $msg = $hMenuItem_HelpPrimaryContents
            Run("Notepad.exe " & @ScriptDir & "\CL_HelpFile.txt")
;~**********************************************************************************
   EndSelect
WEnd


Func PrimaryGUI()
   Global $hWnd_PrimaryGUI = GUICreate("Coaster Leech", 231, 361)  ; primary GUI window.
    Global $hMenu_HelpPrimary = GUICtrlCreateMenu("&Help")
    Global $hMenuItem_HelpPrimaryContents =  GUICtrlCreateMenuitem("&Contents" & @tab & "          F1",$hMenu_HelpPrimary)
    Global $hMenuItem_HelpPrimaryAbout = GUICtrlCreateMenuitem("&About",$hMenu_HelpPrimary)
   GUISetBkColor(0x484b80)
   GUICtrlCreatePic(@ScriptDir & "\CL_Primary.gif", 10, 10, 211, 60)
;~    GUICtrlCreateLabel("", 10, 10, 211, 60)
;~    GUICtrlSetBkColor(-1, 0xffff00) ; yellow.  Placeholder for the image
   $label_white = GUICtrlCreateLabel("", 10, 80, 211, 251)
   GUICtrlSetBkColor($label_white, 0xffffff) ; white
   GUICtrlSetState($label_white, $GUI_DISABLE)
   Global $button_banlist = GUICtrlCreateButton("View &Bans", 15, 85, 65, 20)
   Global $button_config = GUICtrlCreateButton("&Config", 151, 85, 65, 20)
   Global $button_run = GUICtrlCreateButton("&Run", 15, 306, 65, 20)
   Global $button_exit = GUICtrlCreateButton("E&xit", 151, 306, 65, 20)
   GUISetState()
EndFunc   ;==>PrimaryGUI

Func BanListGUI($x = -1, $y = -1)
   Global $hWnd_BanListGUI = GUICreate("Coaster Leech - Ban List", 231, 361, $x, $y)  ; Ban List GUI window.
    Global $hMenu_HelpBanList = GUICtrlCreateMenu("&Help")
   GUISetBkColor(0x484b80) ; default colour
   GUICtrlCreatePic(@ScriptDir & "\CL_BanList.gif", 10, 10, 211, 60)
;~     GUICtrlCreateLabel("", 10, 10, 211, 60)
;~    GUICtrlSetBkColor(-1, 0xffff00) ; yellow.  Placeholder for the image
   $label_white = GUICtrlCreateLabel("", 10, 80, 211, 251)
   GUICtrlSetBkColor($label_white, 0xffffff) ; white
   GUICtrlSetState($label_white, $GUI_DISABLE)
   Global $button_addban = GUICtrlCreateButton("&Add Ban", 15, 85, 65, 20)
    Global $button_editban = GUICtrlCreateButton("&Remove Ban", 83, 85, 65, 20)
    Global $button_clearlist = GUICtrlCreateButton("&Clear List", 151, 85, 65, 20)
   Global $button_backban = GUICtrlCreateButton("&Back", 15, 306, 65, 20)
   Global $button_exitban = GUICtrlCreateButton("E&xit", 151, 306, 65, 20)
   GUISetState()
;~    MsgBox(0, "Banlist", "Insert Banlist GUI here")
EndFunc   ;==>BanListGUI

Func ConfigGUI($x = -1, $y = -1)
   Global $hWnd_ConfigGUI = GUICreate("Coaster Leech - Configuration", 231, 361, $x, $y)  ; primary GUI window.
    Global $hMenu_HelpConfig = GUICtrlCreateMenu("&Help")
   GUISetBkColor(0x484b80) ; default colour
   GUICtrlCreatePic(@ScriptDir & "\CL_Config.gif", 10, 10, 211, 60)
;~    GUICtrlCreateLabel("", 10, 10, 211, 60)
;~    GUICtrlSetBkColor(-1, 0xffff00) ; yellow.  Placeholder for the image
   $label_white = GUICtrlCreateLabel("", 10, 80, 211, 251)
   GUICtrlSetBkColor($label_white, 0xffffff) ; white
   GUICtrlSetState($label_white, $GUI_DISABLE)
   Global $button_folder = GUICtrlCreateButton("&Folder", 15, 85, 65, 20)
   Global $button_login = GUICtrlCreateButton("&Login/Pass", 151, 85, 65, 20)
   Global $button_backconfig = GUICtrlCreateButton("&Back", 15, 306, 65, 20)
   Global $button_exitconfig = GUICtrlCreateButton("E&xit", 151, 306, 65, 20)
   GUISetState()
;~    MsgBox(0, "Configuration", "Config GUI goes here")
EndFunc   ;==>ConfigGUI

Func HelpContents()
    Run("Notepad.exe " & @ScriptDir & "\CL_HelpFile.txt")
EndFunc

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

Share this post


Link to post
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
Sign in to follow this  
Followers 0