Jex Posted December 10, 2007 Share Posted December 10, 2007 (edited) I'm started Travian 3 days ago and now i'm not playing anymore. ( That mean i can't continue edit that script. My objective creating listbox for add buildings queue but now i can't. )Near ".... per hour" showing how much time remained for that material reach maximum. ( Example in this ss for Woodcutter need 7:21 hour for lumbers reach full. )If you press building buttons upgrading that building. ( If have enough material and workers not already working. )If you press "Copy to clipboard" giving like that report about your village :Lumber : 1922/3100 (3:34)Clay : 1831/3100 (3:51)Iron : 1715/3100 (4:59)Crop : 1573/3100 (6:11)Crop Consumption : 86/333Lumber : 330 per hourClay : 330 per hourIron : 278 per hourCrop : 247 per hourWoodcutter level 4, 4, 4, 4Clay Pit level 4, 4, 4, 4Iron Mine level 3, 3, 4, 4Cropland level 4, 4, 4, 3, 3, 3I think that script will be good IE.au3 example By the way im only tested that script in "http://speed.travian.com" and i think that script can't work with other languages. ( I'm tested with 3 diffrent account and working without problem in this server. )Don't forget change that variables : $Link = "http://speed.travian.com", $User = "Test", $Pass = "123"expandcollapse popup#include <IE.au3> #include <INet.au3> #include <GUIConstants.au3> #include <String.au3> Global $Link = "http://speed.travian.com", $User = "Test", $Pass = "123" Global $Button[5][7], $Label[6], $Label2[5], $5Minute = 0, $TimerDiff = 0 $Form = GUICreate("Travian", 440, 214, 354, 445) GUISetBkColor(0xFFFFFF) $Pic1 = GUICtrlCreatePic("1.gif", 8, 15, 20, 15, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS)) $Pic2 = GUICtrlCreatePic("3.gif", 228, 15, 20, 15, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS)) $Pic3 = GUICtrlCreatePic("2.gif", 118, 15, 20, 15, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS)) $Pic4 = GUICtrlCreatePic("4.gif", 338, 15, 20, 15, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS)) $Pic5 = GUICtrlCreatePic("5.gif", 8, 167, 20, 15, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS)) $Label[1] = GUICtrlCreateLabel("", 38, 16, 80, 17) $Label[2] = GUICtrlCreateLabel("", 148, 16, 80, 17) $Label[3] = GUICtrlCreateLabel("", 258, 16, 80, 17) $Label[4] = GUICtrlCreateLabel("", 368, 16, 80, 17) $Label[5] = GUICtrlCreateLabel("", 38, 168, 80, 17) $Label2[1] = GUICtrlCreateLabel("", 6, 32, 105, 17) $Label2[2] = GUICtrlCreateLabel("", 116, 32, 105, 17) $Label2[3] = GUICtrlCreateLabel("", 226, 32, 105, 17) $Label2[4] = GUICtrlCreateLabel("", 336, 32, 105, 17) $Button[1][1] = GUICtrlCreateButton("", 24, 56, 75, 25, 0) $Button[1][2] = GUICtrlCreateButton("", 24, 80, 75, 25, 0) $Button[1][3] = GUICtrlCreateButton("", 24, 104, 75, 25, 0) $Button[1][4] = GUICtrlCreateButton("", 24, 128, 75, 25, 0) $Label10 = GUICtrlCreateLabel("1.", 8, 64, 13, 17) $Label11 = GUICtrlCreateLabel("2.", 8, 88, 13, 17) $Label12 = GUICtrlCreateLabel("3.", 8, 112, 13, 17) $Label13 = GUICtrlCreateLabel("4.", 8, 136, 13, 17) $Button[2][1] = GUICtrlCreateButton("", 134, 56, 75, 25, 0) $Button[2][2] = GUICtrlCreateButton("", 134, 80, 75, 25, 0) $Button[2][3] = GUICtrlCreateButton("", 134, 104, 75, 25, 0) $Button[2][4] = GUICtrlCreateButton("", 134, 128, 75, 25, 0) $Label14 = GUICtrlCreateLabel("1.", 118, 64, 13, 17) $Label15 = GUICtrlCreateLabel("2.", 118, 88, 13, 17) $Label16 = GUICtrlCreateLabel("3.", 118, 112, 13, 17) $Label17 = GUICtrlCreateLabel("4.", 118, 136, 13, 17) $Button[3][1] = GUICtrlCreateButton("", 244, 56, 75, 25, 0) $Button[3][2] = GUICtrlCreateButton("", 244, 80, 75, 25, 0) $Button[3][3] = GUICtrlCreateButton("", 244, 104, 75, 25, 0) $Button[3][4] = GUICtrlCreateButton("", 244, 128, 75, 25, 0) $Label18 = GUICtrlCreateLabel("1.", 228, 64, 13, 17) $Label19 = GUICtrlCreateLabel("2.", 228, 88, 13, 17) $Label20 = GUICtrlCreateLabel("3.", 228, 112, 13, 17) $Label21 = GUICtrlCreateLabel("4.", 228, 136, 13, 17) $Button[4][1] = GUICtrlCreateButton("", 354, 56, 75, 25, 0) $Button[4][2] = GUICtrlCreateButton("", 354, 80, 75, 25, 0) $Button[4][3] = GUICtrlCreateButton("", 354, 104, 75, 25, 0) $Button[4][4] = GUICtrlCreateButton("", 354, 128, 75, 25, 0) $Button[4][5] = GUICtrlCreateButton("", 354, 152, 75, 25, 0) $Button[4][6] = GUICtrlCreateButton("", 354, 176, 75, 25, 0) $Label22 = GUICtrlCreateLabel("1.", 338, 64, 13, 17) $Label23 = GUICtrlCreateLabel("2.", 338, 88, 13, 17) $Label24 = GUICtrlCreateLabel("3.", 338, 112, 13, 17) $Label25 = GUICtrlCreateLabel("4.", 338, 136, 13, 17) $Label26 = GUICtrlCreateLabel("5.", 338, 160, 13, 17) $Label27 = GUICtrlCreateLabel("6.", 338, 184, 13, 17) $Checkbox1 = GUICtrlCreateCheckbox("Auto Recheck", 96, 184, 97, 17) GUICtrlSetState(-1, $GUI_CHECKED) $Checkbox2 = GUICtrlCreateCheckbox("Auto Relogin", 96, 168, 97, 17) $Copy = GUICtrlCreateButton("Copy to clipboard", 200, 168, 123, 33, 0) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Display Inline Images", "REG_SZ", "no") TrayTip("", "Loading...", 1) $oIE = _IECreate($Link, 0, 0) Login($User, $Pass) Check() TrayTip("", "", 0) GUISetState(@SW_SHOW) While 1 $Timer = TimerInit() $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit For $x = 1 To 4 For $y = 1 To 4 If $msg = $Button[$x][$y] Then Build($x, $y) Next Next If $msg = $Button[4][5] Then Build(4, 5) If $msg = $Button[4][6] Then Build(4, 6) If $msg = $Copy Then Copy() $TimerDiff += TimerDiff($Timer) If $TimerDiff >= 5000 Then Checkbox() $TimerDiff = 0 EndIf WEnd Func Check() $GetMaterials = GetMaterials() $GetProductions = GetProductions() $GetTimes = CalculateResourceTime() $GetResourceFields = GetResourceFields() For $i = 1 To 5 GUICtrlSetData($Label[$i], $GetMaterials[$i][1] & " / " & $GetMaterials[$i][2]) If $i <> 5 Then GUICtrlSetData($Label2[$i], $GetProductions[$i] & " per hour (" & $GetTimes[$i][3] & ")") Next For $x = 1 To 4 For $y = 1 To 4 GUICtrlSetData($Button[$x][$y], "Level " & $GetResourceFields[$x][$y]) If $x = 4 And $y = 4 Then GUICtrlSetData($Button[$x][$y + 1], "Level " & $GetResourceFields[$x][$y + 1]) GUICtrlSetData($Button[$x][$y + 2], "Level " & $GetResourceFields[$x][$y + 2]) EndIf Next Next EndFunc ;==>Check Func Checkbox() If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then $5Minute += 1 If $5Minute = 60 Then _IENavigate($oIE, $Link) Login($User, $Pass) $5Minute = 0 EndIf EndIf If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then Check() EndFunc Func Login($Username, $Password) $oForm = _IEFormGetCollection($oIE, 0) $oQuery = _IEFormElementGetCollection($oForm, 2) _IEFormElementSetValue($oQuery, $Username) $oQuery = _IEFormElementGetCollection($oForm, 3) _IEFormElementSetValue($oQuery, $Password) _IEFormSubmit($oForm) $Source = _IEDocReadHTML($oIE) If Not StringInStr($Source, '<DIV id=ltime>Calculated in <B>') Then MsgBox("", "Error!", "Username or password wrong.") Exit EndIf EndFunc ;==>Login Func Build($xx, $yy) $Number = GetResourceNumbers() $GetSource = _INetGetSource($Link & "/build.php?id=" & $Number[$xx][$yy]) If StringInStr($GetSource, "Too few resources") Then TrayTip("", "Too few resources!", 1) ElseIf StringInStr($GetSource, "The workers are already at work") Then TrayTip("", "The workers are already at work!", 1) Else $Between = _StringBetween($GetSource, '"dorf1.php?', '">') _IENavigate($oIE, $Link & "/dorf1.php?" & $Between[0]) TrayTip("", "Building...", 1) EndIf EndFunc ;==>Build Func Copy() _IENavigate($oIE, $Link & "/dorf1.php?") $Materials2 = ShowCalculatedTime() $Productions = ShowProductions() $ResourceFields = ShowResourceFields() ClipPut($Materials2 & @CRLF & @CRLF & $Productions[2] & @CRLF & @CRLF & $ResourceFields[2]) SoundPlay(@WindowsDir & "\media\tada.wav") EndFunc ;==>Copy Func GetMaterials() $Count = 0 Do $oTable = _IETableGetCollection($oIE, $Count) $aTableData = _IETableWriteToArray($oTable) $Count += 1 Until UBound($aTableData) = 9 Local $Materials[6][3] $Split = StringSplit($aTableData[1][0], "/", 1) $Materials[1][1] = $Split[1] $Materials[1][2] = $Split[2] $Split = StringSplit($aTableData[3][0], "/", 1) $Materials[2][1] = $Split[1] $Materials[2][2] = $Split[2] $Split = StringSplit($aTableData[5][0], "/", 1) $Materials[3][1] = $Split[1] $Materials[3][2] = $Split[2] $Split = StringSplit($aTableData[7][0], "/", 1) $Materials[4][1] = $Split[1] $Materials[4][2] = $Split[2] $Split = StringSplit(StringReplace($aTableData[8][0], " ", ""), "/", 1) $Materials[5][1] = $Split[1] $Materials[5][2] = $Split[2] Return $Materials EndFunc ;==>GetMaterials Func ShowMaterials() $Get = GetMaterials() Local $Materials[3], $Materials2[6] For $x = 1 To 5 If $x = 1 Then $Materials[1] = $Get[$x][1] & "/" & $Get[$x][2] Else $Materials[1] &= ", " & $Get[$x][1] & "/" & $Get[$x][2] EndIf $Materials2[$x] = $Get[$x][1] & "/" & $Get[$x][2] Next $Materials[2] = "Lumber : " & $Materials2[1] & @CRLF & "Clay : " & $Materials2[2] & @CRLF & "Iron : " & $Materials2[3] & @CRLF & "Crop : " & $Materials2[4] & @CRLF & _ "Crop Consumption : " & $Materials2[5] Return $Materials EndFunc ;==>ShowMaterials Func GetProductions() $Count = 0 Do $oTable = _IETableGetCollection($oIE, $Count) $aTableData = _IETableWriteToArray($oTable) $Count += 1 Until UBound($aTableData) = 4 Local $Productions[5] $Productions[1] = StringReplace($aTableData[2][0], " ", "") $Productions[2] = StringReplace($aTableData[2][1], " ", "") $Productions[3] = StringReplace($aTableData[2][2], " ", "") $Productions[4] = StringReplace($aTableData[2][3], " ", "") Return $Productions EndFunc ;==>GetProductions Func ShowProductions() $Get = GetProductions() Local $Productions[3] $Productions[1] = $Get[1] & ", " & $Get[2] & ", " & $Get[3] & ", " & $Get[4] $Productions[2] = "Lumber : " & $Get[1] & " per hour" & @CRLF & "Clay : " & $Get[2] & " per hour" & @CRLF & "Iron : " & $Get[3] & " per hour" & @CRLF & "Crop : " & $Get[4] & " per hour" Return $Productions EndFunc ;==>ShowProductions Func GetResourceFields() $Source = _IEDocReadHTML($oIE) $Areas = _StringBetween($Source, '<AREA title="', '" shape=CIRCLE') For $i = 0 To UBound($Areas) - 1 $Areas[$i] = StringReplace($Areas[$i], "Woodcutter level ", "") $Areas[$i] = StringReplace($Areas[$i], "Clay Pit level ", "") $Areas[$i] = StringReplace($Areas[$i], "Iron Mine level ", "") $Areas[$i] = StringReplace($Areas[$i], "Cropland level ", "") Next Local $ResourceFields[5][7] $ResourceFields[1][1] = $Areas[0] $ResourceFields[1][2] = $Areas[2] $ResourceFields[1][3] = $Areas[13] $ResourceFields[1][4] = $Areas[16] $ResourceFields[2][1] = $Areas[4] $ResourceFields[2][2] = $Areas[5] $ResourceFields[2][3] = $Areas[15] $ResourceFields[2][4] = $Areas[17] $ResourceFields[3][1] = $Areas[3] $ResourceFields[3][2] = $Areas[6] $ResourceFields[3][3] = $Areas[9] $ResourceFields[3][4] = $Areas[10] $ResourceFields[4][1] = $Areas[1] $ResourceFields[4][2] = $Areas[7] $ResourceFields[4][3] = $Areas[8] $ResourceFields[4][4] = $Areas[11] $ResourceFields[4][5] = $Areas[12] $ResourceFields[4][6] = $Areas[14] Return $ResourceFields EndFunc ;==>GetResourceFields Func GetResourceNumbers() Local $FieldNumbers[5][7] $FieldNumbers[1][1] = 1 $FieldNumbers[1][2] = 3 $FieldNumbers[1][3] = 14 $FieldNumbers[1][4] = 17 $FieldNumbers[2][1] = 5 $FieldNumbers[2][2] = 6 $FieldNumbers[2][3] = 16 $FieldNumbers[2][4] = 18 $FieldNumbers[3][1] = 4 $FieldNumbers[3][2] = 7 $FieldNumbers[3][3] = 10 $FieldNumbers[3][4] = 11 $FieldNumbers[4][1] = 2 $FieldNumbers[4][2] = 8 $FieldNumbers[4][3] = 9 $FieldNumbers[4][4] = 12 $FieldNumbers[4][5] = 13 $FieldNumbers[4][6] = 15 Return $FieldNumbers EndFunc ;==>GetResourceNumbers Func ShowResourceFields() $ResourceFields = GetResourceFields() Local $Fields[3] For $i = 1 To 4 For $y = 1 To 4 If $i = 1 And $y = 1 Then $Fields[2] = "Woodcutter level " & $ResourceFields[$i][$y] ElseIf $i = 2 And $y = 1 Then $Fields[2] &= @CRLF & "Clay Pit level " & $ResourceFields[$i][$y] ElseIf $i = 3 And $y = 1 Then $Fields[2] &= @CRLF & "Iron Mine level " & $ResourceFields[$i][$y] ElseIf $i = 4 And $y = 1 Then $Fields[2] &= @CRLF & "Cropland level " & $ResourceFields[$i][$y] Else If $i = 4 And $y = 4 Then $Fields[2] &= ", " & $ResourceFields[$i][$y + 1] $Fields[2] &= ", " & $ResourceFields[$i][$y + 2] EndIf $Fields[2] &= ", " & $ResourceFields[$i][$y] EndIf If $i = 1 And $y = 1 Then $Fields[1] = $ResourceFields[$i][$y] Else $Fields[1] &= ", " & $ResourceFields[$i][$y] EndIf Next Next Return $Fields EndFunc ;==>ShowResourceFields Func CalculateResourceTime() $Materials = GetMaterials() $Productions = GetProductions() Local $Time[5][4] For $i = 1 To 4 $Minute = Round(($Materials[$i][2] - $Materials[$i][1]) / ($Productions[$i] / 60), 0) $Hour = 0 Do $Minute -= 60 $Hour += 1 Until $Minute < 60 If $Minute < 10 Then $Minute = "0" & $Minute $Time[$i][1] = $Hour $Time[$i][2] = $Minute $Time[$i][3] = $Time[$i][1] & ":" & $Time[$i][2] Next Return $Time EndFunc ;==>CalculateResourceTime Func ShowCalculatedTime() $Materials = ShowMaterials() $Time = CalculateResourceTime() $Split = StringSplit($Materials[1], ", ", 1) $Text = "Lumber : " & $Split[1] & " (" & $Time[1][3] & ")" & @CRLF & "Clay : " & $Split[2] & " (" & $Time[2][3] & ")" & @CRLF & _ "Iron : " & $Split[3] & " (" & $Time[3][3] & ")" & @CRLF & "Crop : " & $Split[4] & " (" & $Time[4][3] & ")" & @CRLF & _ "Crop Consumption : " & $Split[5] Return $Text EndFunc ;==>ShowCalculatedTime Func OnAutoItExit() _IEQuit($oIE) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Display Inline Images", "REG_SZ", "yes") EndFunc ;==>OnAutoItExitImages.rar Edited December 10, 2007 by Jex My scripts : Immediate Window , My Web Browser , Travian , Text Effect , Characters & Words per minute or second , Image Editor (ImageMagick) , Matrix style background effect ( Screensaver ) , Mail Sender , Protectlinks decoder and Rapidshare links checker , Fonts Fetcher , Region determine , Compare pictures , Gradient color box , Mouse Coordinates, Colors, Pixel Search things , Encrypt/Decrypt and embeding file in jpeg thing , Hard disk space monitor , Reflex game , Multiplayer Tic Tac Toe , WLM ( MSN ) personal message changer Link to comment Share on other sites More sharing options...
Zepx Posted December 10, 2007 Share Posted December 10, 2007 (edited) omg.. this is so cool... nice work mate. There is another one which does more features e.g Send troops, building time and etc. Search in google and you should find it. However, that doesn't calculate if sufficient resources is there, when task finishes. its coded in C++. Edited December 10, 2007 by Zepx Link to comment Share on other sites More sharing options...
Jex Posted December 10, 2007 Author Share Posted December 10, 2007 (edited) However, that doesn't calculate if sufficient resources is there, when task finishes.Now i'm adding Auto Recheck for that problem. ( and Auto Relogin )Edit : Now every 5 second recheck resources and buildings. And every 5 minute relogin. ( If checkboxs checked. ) Edited December 10, 2007 by Jex My scripts : Immediate Window , My Web Browser , Travian , Text Effect , Characters & Words per minute or second , Image Editor (ImageMagick) , Matrix style background effect ( Screensaver ) , Mail Sender , Protectlinks decoder and Rapidshare links checker , Fonts Fetcher , Region determine , Compare pictures , Gradient color box , Mouse Coordinates, Colors, Pixel Search things , Encrypt/Decrypt and embeding file in jpeg thing , Hard disk space monitor , Reflex game , Multiplayer Tic Tac Toe , WLM ( MSN ) personal message changer Link to comment Share on other sites More sharing options...
Zepx Posted December 10, 2007 Share Posted December 10, 2007 Nicely done Could be improved from time to time with other buildings as well. Link to comment Share on other sites More sharing options...
Linux Posted December 17, 2007 Share Posted December 17, 2007 (edited) Nicely done Could be improved from time to time with other buildings as well. Hi all! i'm planning to improve this script. i minor improvements, but i plan to make an A.I. so i can leave the bot playing for me! yet, i need some help. i cant open the HELP FILE that comes with auto it. can someone tell me where can i find the online help file? i'm looking for documentation about the ie.au3 and inet.au3 this is the code i'm working on: [autoit]#include <IE.au3> #include <INet.au3> #include <GUIConstants.au3> #include <String.au3> #cs Travian v. 1.2 PT TODO Building ends in XX:xx Queue More realistic moves (Sleep in build) #ce Global $Link = "http://s8.travian.pt", $User = "zephir", $Pass = "1212", $AutoPilot = "off" Global $Button[5][7], $Label[6], $Label2[5] , $5Minute = 0, $TimerDiff = 0, $Checkin = 0 Global $barro[10][4], $ferro[10][4] , $crop[10][4], $madeira[10][4] TrayTip("", "Loading...", 1) $Form = GUICreate("Travian v.1.2 PT", 540, 314, 354, 445) GUISetBkColor(0xFFFFFF) $Pic1 = GUICtrlCreatePic("1.gif", 8, 15, 20, 15, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS)) $Pic2 = GUICtrlCreatePic("3.gif", 228, 15, 20, 15, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS)) $Pic3 = GUICtrlCreatePic("2.gif", 118, 15, 20, 15, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS)) $Pic4 = GUICtrlCreatePic("4.gif", 338, 15, 20, 15, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS)) $Pic5 = GUICtrlCreatePic("5.gif", 443, 15, 20, 15, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS)) $LabelU = GUICtrlCreateLabel("User: " & $User, 440, 50, 80, 17) $LabelL = GUICtrlCreateLabel( $Link, 430, 70, 140, 18) $LabelDeb = GUICtrlCreateLabel( $Link, 430, 99, 140, 18) $Labeldeb2 = GUICtrlCreateLabel("", 38, 460, 190, 70) $Label[1] = GUICtrlCreateLabel("", 38, 16, 80, 17) $Label[2] = GUICtrlCreateLabel("", 148, 16, 80, 17) $Label[3] = GUICtrlCreateLabel("", 258, 16, 80, 17) $Label[4] = GUICtrlCreateLabel("", 368, 16, 80, 17) $Label[5] = GUICtrlCreateLabel("", 478, 16, 80, 17) $Label2[1] = GUICtrlCreateLabel("", 6, 32, 105, 17) $Label2[2] = GUICtrlCreateLabel("", 116, 32, 105, 17) $Label2[3] = GUICtrlCreateLabel("", 226, 32, 105, 17) $Label2[4] = GUICtrlCreateLabel("", 336, 32, 105, 17) $Button[1][1] = GUICtrlCreateButton("", 22, 56, 80, 25, 0) $Button[1][2] = GUICtrlCreateButton("", 22, 80, 80, 25, 0) $Button[1][3] = GUICtrlCreateButton("", 22, 104, 80, 25, 0) $Button[1][4] = GUICtrlCreateButton("", 22, 128, 80, 25, 0) $Label10 = GUICtrlCreateLabel("1.", 8, 64, 13, 17) $Label11 = GUICtrlCreateLabel("2.", 8, 88, 13, 17) $Label12 = GUICtrlCreateLabel("3.", 8, 112, 13, 17) $Label13 = GUICtrlCreateLabel("4.", 8, 136, 13, 17) $Button[2][1] = GUICtrlCreateButton("", 134, 56, 75, 25, 0) $Button[2][2] = GUICtrlCreateButton("", 134, 80, 75, 25, 0) $Button[2][3] = GUICtrlCreateButton("", 134, 104, 75, 25, 0) $Button[2][4] = GUICtrlCreateButton("", 134, 128, 75, 25, 0) $Label14 = GUICtrlCreateLabel("1.", 118, 64, 13, 17) $Label15 = GUICtrlCreateLabel("2.", 118, 88, 13, 17) $Label16 = GUICtrlCreateLabel("3.", 118, 112, 13, 17) $Label17 = GUICtrlCreateLabel("4.", 118, 136, 13, 17) $Button[3][1] = GUICtrlCreateButton("", 244, 56, 75, 25, 0) $Button[3][2] = GUICtrlCreateButton("", 244, 80, 75, 25, 0) $Button[3][3] = GUICtrlCreateButton("", 244, 104, 75, 25, 0) $Button[3][4] = GUICtrlCreateButton("", 244, 128, 75, 25, 0) $Label18 = GUICtrlCreateLabel("1.", 228, 64, 13, 17) $Label19 = GUICtrlCreateLabel("2.", 228, 88, 13, 17) $Label20 = GUICtrlCreateLabel("3.", 228, 112, 13, 17) $Label21 = GUICtrlCreateLabel("4.", 228, 136, 13, 17) $Button[4][1] = GUICtrlCreateButton("", 354, 56, 75, 25, 0) $Button[4][2] = GUICtrlCreateButton("", 354, 80, 75, 25, 0) $Button[4][3] = GUICtrlCreateButton("", 354, 104, 75, 25, 0) $Button[4][4] = GUICtrlCreateButton("", 354, 128, 75, 25, 0) $Button[4][5] = GUICtrlCreateButton("", 354, 152, 75, 25, 0) $Button[4][6] = GUICtrlCreateButton("", 354, 176, 75, 25, 0) $Label22 = GUICtrlCreateLabel("1.", 338, 64, 13, 17) $Label23 = GUICtrlCreateLabel("2.", 338, 88, 13, 17) $Label24 = GUICtrlCreateLabel("3.", 338, 112, 13, 17) $Label25 = GUICtrlCreateLabel("4.", 338, 136, 13, 17) $Label26 = GUICtrlCreateLabel("5.", 338, 160, 13, 17) $Label27 = GUICtrlCreateLabel("6.", 338, 184, 13, 17) $Copy = GUICtrlCreateButton("Copy to clipboard", 172, 176, 123, 25, 0) $Auto = GUICtrlCreateButton("Auto", 110 , 176 , 50 , 25 , 0) $Checkbox1 = GUICtrlCreateCheckbox("Auto Recheck", 10, 176, 97, 17) GUICtrlSetState(-1, $GUI_CHECKED) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Display Inline Images", "REG_SZ", "no") $oIE=ObjCreate("InternetExplorer.Application.1") With $oIE .Visible=1 .Top = (@DesktopHeight-400)/2 .Height=400 ; Make it a bit smaller than our GUI. .Width=600 .Silent=1 ; Don't show IE's dialog boxes $IEWnd=HWnd(.hWnd) ; Remember the Window, in case user decides to close it EndWith ;$oIE = _IECreate($Link, 0, 0) $oIE.Navigate( $Link ) TrayTip("","Login " & $User, 0) sleep(15000+random(2000,7000,1)) Login($User, $Pass) TrayTip("","Login OK!", 0) Check() TrayTip("", "", 0) GUISetState(@SW_SHOW) While 1 $Timer = TimerInit() $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit For $x = 1 To 4 For $y = 1 To 4 If $msg = $Button[$x][$y] Then Build($x, $y) Next Next If $msg = $Button[4][5] Then Build(4, 5) If $msg = $Button[4][6] Then Build(4, 6) If $msg = $Copy Then Copy() If $msg = $Auto Then Auto() $TimerDiff += TimerDiff($Timer) If ($TimerDiff >= 10000) Then Checkbox() $TimerDiff = 0 EndIf If ( $Checkin <> (10 - int($TimerDiff/1000)) ) Then $Checkin = (10 - int($TimerDiff/1000)) GUICtrlSetData($LabelDeb, "Check in: " & 10 - int($TimerDiff/1000)) EndIf WEnd Func Check() $GetMaterials = GetMaterials() $GetProductions = GetProductions() $GetTimes = CalculateResourceTime() $GetResourceFields = GetResourceFields() For $i = 1 To 5 GUICtrlSetData($Label[$i], $GetMaterials[$i][1] & " / " & $GetMaterials[$i][2]) If $i <> 5 Then GUICtrlSetData($Label2[$i], $GetProductions[$i] & " per hour (" & $GetTimes[$i][3] & ")") Next For $x = 1 To 4 For $y = 1 To 4 GUICtrlSetData($Button[$x][$y], "Level " & $GetResourceFields[$x][$y]) If $x = 4 And $y = 4 Then GUICtrlSetData($Button[$x][$y + 1], "Level " & $GetResourceFields[$x][$y + 1]) GUICtrlSetData($Button[$x][$y + 2], "Level " & $GetResourceFields[$x][$y + 2]) EndIf Next Next EndFunc ;==>Check Func Checkbox() If $AutoPilot = "on" Then $5Minute += 1 If $5Minute = 10 Then TrayTip("","5 minutes Check...",0) $5Minute = 0 EndIf EndIf If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then Check() EndFunc Func Login($Username, $Password) $oForm = _IEFormGetCollection($oIE, 0) $oQuery = _IEFormElementGetCollection($oForm, 2) _IEFormElementSetValue($oQuery, $Username) $oQuery = _IEFormElementGetCollection($oForm, 3) _IEFormElementSetValue($oQuery, $Password) _IEFormSubmit($oForm) $Source = _IEDocReadHTML($oIE) If Not StringInStr($Source, 'efectuado em <b>') Then MsgBox("", "Error!", "Username or password wrong.") EndIf EndFunc ;==>Login Func Build($xx, $yy) $Number = GetResourceNumbers() _IENavigate($oIE,($Link & "/build.php?id=" & $Number[$xx][$yy]),1) ;$GetSource = _IEDocReadHTML($oIE) $GetSource = _INetGetSource($Link & "/build.php?id=" & $Number[$xx][$yy]) If StringInStr($GetSource, "Poucos recursos") Then TrayTip("", "Poucos recursos!", 1) ElseIf StringInStr($GetSource, "se encontram ocupados") Then TrayTip("", "Os trabalhadores j Edited January 19, 2008 by Linux You can help! Donate to AutoIt! or, visit ClimatePREDICTION.netMy posts:Travian Bot Example (100+ servers) BETAHow to Host you code/app for free! (unlimited team number) (Public or Private)"Sir, we're surrounded!" "Excellent. We can attack in any direction!" Link to comment Share on other sites More sharing options...
Jex Posted December 17, 2007 Author Share Posted December 17, 2007 (edited) I'm added listview for task queue but ie function giving strange errors sometimes, i mean script working true but after +10 minutes some ie functions giving error and script closing But maybe that script will be useful for you.expandcollapse popup#include <IE.au3> #include <INet.au3> #include <GUIConstants.au3> #include <String.au3> #include <GuiListView.au3> Global $Link = "http://speed.travian.com", $User = "..", $Pass = "..", $oIE Global $Button[5][7], $Label[6], $Label2[5], $5Minute = 0, $TimerDiff = 0 $Form = GUICreate("Travian", 628, 211, 354, 445) GUISetBkColor(0xFFFFFF) $Pic1 = GUICtrlCreatePic("1.gif", 8, 15, 20, 15, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS)) $Pic2 = GUICtrlCreatePic("3.gif", 228, 15, 20, 15, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS)) $Pic3 = GUICtrlCreatePic("2.gif", 118, 15, 20, 15, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS)) $Pic4 = GUICtrlCreatePic("4.gif", 338, 15, 20, 15, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS)) $Pic5 = GUICtrlCreatePic("5.gif", 8, 167, 20, 15, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS)) $Label[1] = GUICtrlCreateLabel("", 38, 16, 80, 17) $Label[2] = GUICtrlCreateLabel("", 148, 16, 80, 17) $Label[3] = GUICtrlCreateLabel("", 258, 16, 80, 17) $Label[4] = GUICtrlCreateLabel("", 368, 16, 80, 17) $Label[5] = GUICtrlCreateLabel("", 38, 168, 80, 17) $Label2[1] = GUICtrlCreateLabel("", 6, 32, 110, 17) $Label2[2] = GUICtrlCreateLabel("", 116, 32, 110, 17) $Label2[3] = GUICtrlCreateLabel("", 226, 32, 110, 17) $Label2[4] = GUICtrlCreateLabel("", 336, 32, 110, 17) $Button[1][1] = GUICtrlCreateButton("", 24, 56, 75, 25, 0) $Button[1][2] = GUICtrlCreateButton("", 24, 80, 75, 25, 0) $Button[1][3] = GUICtrlCreateButton("", 24, 104, 75, 25, 0) $Button[1][4] = GUICtrlCreateButton("", 24, 128, 75, 25, 0) $Label10 = GUICtrlCreateLabel("1.", 8, 64, 13, 17) $Label11 = GUICtrlCreateLabel("2.", 8, 88, 13, 17) $Label12 = GUICtrlCreateLabel("3.", 8, 112, 13, 17) $Label13 = GUICtrlCreateLabel("4.", 8, 136, 13, 17) $Button[2][1] = GUICtrlCreateButton("", 134, 56, 75, 25, 0) $Button[2][2] = GUICtrlCreateButton("", 134, 80, 75, 25, 0) $Button[2][3] = GUICtrlCreateButton("", 134, 104, 75, 25, 0) $Button[2][4] = GUICtrlCreateButton("", 134, 128, 75, 25, 0) $Label14 = GUICtrlCreateLabel("1.", 118, 64, 13, 17) $Label15 = GUICtrlCreateLabel("2.", 118, 88, 13, 17) $Label16 = GUICtrlCreateLabel("3.", 118, 112, 13, 17) $Label17 = GUICtrlCreateLabel("4.", 118, 136, 13, 17) $Button[3][1] = GUICtrlCreateButton("", 244, 56, 75, 25, 0) $Button[3][2] = GUICtrlCreateButton("", 244, 80, 75, 25, 0) $Button[3][3] = GUICtrlCreateButton("", 244, 104, 75, 25, 0) $Button[3][4] = GUICtrlCreateButton("", 244, 128, 75, 25, 0) $Label18 = GUICtrlCreateLabel("1.", 228, 64, 13, 17) $Label19 = GUICtrlCreateLabel("2.", 228, 88, 13, 17) $Label20 = GUICtrlCreateLabel("3.", 228, 112, 13, 17) $Label21 = GUICtrlCreateLabel("4.", 228, 136, 13, 17) $Button[4][1] = GUICtrlCreateButton("", 354, 56, 75, 25, 0) $Button[4][2] = GUICtrlCreateButton("", 354, 80, 75, 25, 0) $Button[4][3] = GUICtrlCreateButton("", 354, 104, 75, 25, 0) $Button[4][4] = GUICtrlCreateButton("", 354, 128, 75, 25, 0) $Button[4][5] = GUICtrlCreateButton("", 354, 152, 75, 25, 0) $Button[4][6] = GUICtrlCreateButton("", 354, 176, 75, 25, 0) $Label22 = GUICtrlCreateLabel("1.", 338, 64, 13, 17) $Label23 = GUICtrlCreateLabel("2.", 338, 88, 13, 17) $Label24 = GUICtrlCreateLabel("3.", 338, 112, 13, 17) $Label25 = GUICtrlCreateLabel("4.", 338, 136, 13, 17) $Label26 = GUICtrlCreateLabel("5.", 338, 160, 13, 17) $Label27 = GUICtrlCreateLabel("6.", 338, 184, 13, 17) $Checkbox1 = GUICtrlCreateCheckbox("Auto Recheck", 96, 184, 97, 17) GUICtrlSetState(-1, $GUI_CHECKED) $Checkbox2 = GUICtrlCreateCheckbox("Auto Relogin", 96, 168, 97, 17) $Copy = GUICtrlCreateButton("Copy to clipboard", 200, 168, 123, 33, 0) $List = GUICtrlCreateListView("", 440, 40, 178, 158, BitOR($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_NOCOLUMNHEADER)) $hwndList = ControlGetHandle ($Form, "", $List) _GUICtrlListView_AddColumn ($List, "Column 1", 160) $Delete = GUICtrlCreateButton("Delete", 544, 8, 75, 25, 0) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Display Inline Images", "REG_SZ", "no") TrayTip("", "Loading...", 1) $oIE = _IECreate($Link, 1, 0) Login($User, $Pass) Check() TrayTip("", "", 0) GUISetState() While 1 $Timer = TimerInit() $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit For $x = 1 To 4 For $y = 1 To 4 If $msg = $Button[$x][$y] Then Add($x, $y) Next Next If $msg = $Button[4][5] Then Add(4, 5) If $msg = $Button[4][6] Then Add(4, 6) If $msg = $Copy Then Copy() If $msg = $Delete Then $Count = _GUICtrlListView_GetSelectedIndices ($List, 1) _GUICtrlListView_DeleteItem ($hwndList, $Count[1]) EndIf $TimerDiff += TimerDiff($Timer) If $TimerDiff >= 10000 Then Login($User, $Pass) Checkbox() Checklist() $TimerDiff = 0 EndIf WEnd Func Checklist() $Listcount = _GUICtrlListView_GetItemCount ($List) If $Listcount <> 0 Then $Text = _GUICtrlListView_GetItemText($List, 0) If StringInStr($Text, "Woodcutter") Then $Type = 1 ElseIf StringInStr($Text, "Clay Pit") Then $Type = 2 ElseIf StringInStr($Text, "Iron Mine") Then $Type = 3 ElseIf StringInStr($Text, "Cropland") Then $Type = 4 EndIf $Split = StringSplit($Text, ". ", 1) $Build = Build($Type, $Split[1]) If $Build = 1 Then _GUICtrlListView_DeleteItem($hwndList, 0) EndIf EndFunc Func Add($x1, $y1) If $x1 = 1 Then $Type = "Woodcutter" ElseIf $x1 = 2 Then $Type = "Clay Pit" ElseIf $x1 = 3 Then $Type = "Iron Mine" ElseIf $x1 = 4 Then $Type = "Cropland" EndIf _GUICtrlListView_AddItem($List, $y1 & ". " & $Type) EndFunc Func Check() $GetMaterials = GetMaterials() $GetProductions = GetProductions() $GetTimes = CalculateResourceTime() $GetResourceFields = GetResourceFields() For $i = 1 To 5 GUICtrlSetData($Label[$i], $GetMaterials[$i][1] & " / " & $GetMaterials[$i][2]) If $i <> 5 Then GUICtrlSetData($Label2[$i], $GetProductions[$i] & " per hour (" & $GetTimes[$i][3] & ")") Next For $x = 1 To 4 For $y = 1 To 4 GUICtrlSetData($Button[$x][$y], "Level " & $GetResourceFields[$x][$y]) If $x = 4 And $y = 4 Then GUICtrlSetData($Button[$x][$y + 1], "Level " & $GetResourceFields[$x][$y + 1]) GUICtrlSetData($Button[$x][$y + 2], "Level " & $GetResourceFields[$x][$y + 2]) EndIf Next Next EndFunc ;==>Check Func Checkbox() If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then $5Minute += 1 If $5Minute = 50 Then Login($User, $Pass) $5Minute = 0 EndIf EndIf If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then Check() EndFunc Func Login($Username, $Password) _IENavigate($oIE, $Link) $oForm = _IEFormGetCollection($oIE, 0) $oQuery = _IEFormElementGetCollection($oForm, 2) _IEFormElementSetValue($oQuery, $Username) $oQuery = _IEFormElementGetCollection($oForm, 3) _IEFormElementSetValue($oQuery, $Password) _IEFormSubmit($oForm) $Source = _IEDocReadHTML($oIE) If Not StringInStr($Source, '<DIV id=ltime>Calculated in <B>') Then MsgBox("", "Error!", "Username or password wrong.") Exit EndIf EndFunc ;==>Login Func Build($xx, $yy) $Number = GetResourceNumbers() _IENavigate($oIE, $Link & "/build.php?id=" & $Number[$xx][$yy]) $GetSource = _IEBodyReadHTML($oIE) If StringInStr($GetSource, "Too few resources") Then ;TrayTip("", "Too few resources!", 1) Return 0 ElseIf StringInStr($GetSource, "The workers are already at work") Then ;TrayTip("", "The workers are already at work!", 1) Return 0 ElseIf StringInStr($GetSource, "Lack of food: extend cropland first") Then Return 0 Else $oLinks = _IELinkGetCollection ($oIE, 15) _IEAction($oLinks, "click") ;TrayTip("", "Building...", 1) Return 1 EndIf EndFunc ;==>Build Func Copy() _IENavigate($oIE, $Link & "/dorf1.php?") $Materials2 = ShowCalculatedTime() $Productions = ShowProductions() $ResourceFields = ShowResourceFields() ClipPut($Materials2 & @CRLF & @CRLF & $Productions[2] & @CRLF & @CRLF & $ResourceFields[2]) EndFunc ;==>Copy Func GetMaterials() $Count = 0 Do $oTable = _IETableGetCollection($oIE, $Count) $aTableData = _IETableWriteToArray($oTable) $Count += 1 Until UBound($aTableData) = 9 Local $Materials[6][3] $Split = StringSplit($aTableData[1][0], "/", 1) $Materials[1][1] = $Split[1] $Materials[1][2] = $Split[2] $Split = StringSplit($aTableData[3][0], "/", 1) $Materials[2][1] = $Split[1] $Materials[2][2] = $Split[2] $Split = StringSplit($aTableData[5][0], "/", 1) $Materials[3][1] = $Split[1] $Materials[3][2] = $Split[2] $Split = StringSplit($aTableData[7][0], "/", 1) $Materials[4][1] = $Split[1] $Materials[4][2] = $Split[2] $Split = StringSplit(StringReplace($aTableData[8][0], " ", ""), "/", 1) $Materials[5][1] = $Split[1] $Materials[5][2] = $Split[2] Return $Materials EndFunc ;==>GetMaterials Func ShowMaterials() $Get = GetMaterials() Local $Materials[3], $Materials2[6] For $x = 1 To 5 If $x = 1 Then $Materials[1] = $Get[$x][1] & "/" & $Get[$x][2] Else $Materials[1] &= ", " & $Get[$x][1] & "/" & $Get[$x][2] EndIf $Materials2[$x] = $Get[$x][1] & "/" & $Get[$x][2] Next $Materials[2] = "Lumber : " & $Materials2[1] & @CRLF & "Clay : " & $Materials2[2] & @CRLF & "Iron : " & $Materials2[3] & @CRLF & "Crop : " & $Materials2[4] & @CRLF & _ "Crop Consumption : " & $Materials2[5] Return $Materials EndFunc ;==>ShowMaterials Func GetProductions() $Count = 0 Do $oTable = _IETableGetCollection($oIE, $Count) $aTableData = _IETableWriteToArray($oTable) $Count += 1 Until UBound($aTableData) = 4 Local $Productions[5] $Productions[1] = StringReplace($aTableData[2][0], " ", "") $Productions[2] = StringReplace($aTableData[2][1], " ", "") $Productions[3] = StringReplace($aTableData[2][2], " ", "") $Productions[4] = StringReplace($aTableData[2][3], " ", "") Return $Productions EndFunc ;==>GetProductions Func ShowProductions() $Get = GetProductions() Local $Productions[3] $Productions[1] = $Get[1] & ", " & $Get[2] & ", " & $Get[3] & ", " & $Get[4] $Productions[2] = "Lumber : " & $Get[1] & " per hour" & @CRLF & "Clay : " & $Get[2] & " per hour" & @CRLF & "Iron : " & $Get[3] & " per hour" & @CRLF & "Crop : " & $Get[4] & " per hour" Return $Productions EndFunc ;==>ShowProductions Func GetResourceFields() $Source = _INetGetSource($Link & "/dorf1.php") $Areas = _StringBetween($Source, 'shape="circle" title="', '"><area href') For $i = 0 To UBound($Areas) - 1 $Areas[$i] = StringReplace($Areas[$i], "Woodcutter level ", "") $Areas[$i] = StringReplace($Areas[$i], "Clay Pit level ", "") $Areas[$i] = StringReplace($Areas[$i], "Iron Mine level ", "") $Areas[$i] = StringReplace($Areas[$i], "Cropland level ", "") Next Local $ResourceFields[5][7] $ResourceFields[1][1] = $Areas[0] $ResourceFields[1][2] = $Areas[2] $ResourceFields[1][3] = $Areas[13] $ResourceFields[1][4] = $Areas[16] $ResourceFields[2][1] = $Areas[4] $ResourceFields[2][2] = $Areas[5] $ResourceFields[2][3] = $Areas[15] $ResourceFields[2][4] = $Areas[17] $ResourceFields[3][1] = $Areas[3] $ResourceFields[3][2] = $Areas[6] $ResourceFields[3][3] = $Areas[9] $ResourceFields[3][4] = $Areas[10] $ResourceFields[4][1] = $Areas[1] $ResourceFields[4][2] = $Areas[7] $ResourceFields[4][3] = $Areas[8] $ResourceFields[4][4] = $Areas[11] $ResourceFields[4][5] = $Areas[12] $ResourceFields[4][6] = $Areas[14] Return $ResourceFields EndFunc ;==>GetResourceFields Func GetResourceNumbers() Local $FieldNumbers[5][7] $FieldNumbers[1][1] = 1 $FieldNumbers[1][2] = 3 $FieldNumbers[1][3] = 14 $FieldNumbers[1][4] = 17 $FieldNumbers[2][1] = 5 $FieldNumbers[2][2] = 6 $FieldNumbers[2][3] = 16 $FieldNumbers[2][4] = 18 $FieldNumbers[3][1] = 4 $FieldNumbers[3][2] = 7 $FieldNumbers[3][3] = 10 $FieldNumbers[3][4] = 11 $FieldNumbers[4][1] = 2 $FieldNumbers[4][2] = 8 $FieldNumbers[4][3] = 9 $FieldNumbers[4][4] = 12 $FieldNumbers[4][5] = 13 $FieldNumbers[4][6] = 15 Return $FieldNumbers EndFunc ;==>GetResourceNumbers Func ShowResourceFields() $ResourceFields = GetResourceFields() Local $Fields[3] For $i = 1 To 4 For $y = 1 To 4 If $i = 1 And $y = 1 Then $Fields[2] = "Woodcutter level " & $ResourceFields[$i][$y] ElseIf $i = 2 And $y = 1 Then $Fields[2] &= @CRLF & "Clay Pit level " & $ResourceFields[$i][$y] ElseIf $i = 3 And $y = 1 Then $Fields[2] &= @CRLF & "Iron Mine level " & $ResourceFields[$i][$y] ElseIf $i = 4 And $y = 1 Then $Fields[2] &= @CRLF & "Cropland level " & $ResourceFields[$i][$y] Else If $i = 4 And $y = 4 Then $Fields[2] &= ", " & $ResourceFields[$i][$y + 1] $Fields[2] &= ", " & $ResourceFields[$i][$y + 2] EndIf $Fields[2] &= ", " & $ResourceFields[$i][$y] EndIf If $i = 1 And $y = 1 Then $Fields[1] = $ResourceFields[$i][$y] Else $Fields[1] &= ", " & $ResourceFields[$i][$y] EndIf Next Next Return $Fields EndFunc ;==>ShowResourceFields Func CalculateResourceTime() $Materials = GetMaterials() $Productions = GetProductions() Local $Time[5][4] For $i = 1 To 4 $Minute = Round(($Materials[$i][2] - $Materials[$i][1]) / ($Productions[$i] / 60), 0) $Hour = 0 Do $Minute -= 60 $Hour += 1 Until $Minute < 60 If $Minute < 10 Then $Minute = "0" & $Minute $Time[$i][1] = $Hour $Time[$i][2] = $Minute $Time[$i][3] = $Time[$i][1] & ":" & $Time[$i][2] Next Return $Time EndFunc ;==>CalculateResourceTime Func ShowCalculatedTime() $Materials = ShowMaterials() $Time = CalculateResourceTime() $Split = StringSplit($Materials[1], ", ", 1) $Text = "Lumber : " & $Split[1] & " (" & $Time[1][3] & ")" & @CRLF & "Clay : " & $Split[2] & " (" & $Time[2][3] & ")" & @CRLF & _ "Iron : " & $Split[3] & " (" & $Time[3][3] & ")" & @CRLF & "Crop : " & $Split[4] & " (" & $Time[4][3] & ")" & @CRLF & _ "Crop Consumption : " & $Split[5] Return $Text EndFunc ;==>ShowCalculatedTime Func OnAutoItExit() _IEQuit($oIE) RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Display Inline Images", "REG_SZ", "yes") EndFunc ;==>OnAutoItExit Edited December 17, 2007 by Jex My scripts : Immediate Window , My Web Browser , Travian , Text Effect , Characters & Words per minute or second , Image Editor (ImageMagick) , Matrix style background effect ( Screensaver ) , Mail Sender , Protectlinks decoder and Rapidshare links checker , Fonts Fetcher , Region determine , Compare pictures , Gradient color box , Mouse Coordinates, Colors, Pixel Search things , Encrypt/Decrypt and embeding file in jpeg thing , Hard disk space monitor , Reflex game , Multiplayer Tic Tac Toe , WLM ( MSN ) personal message changer Link to comment Share on other sites More sharing options...
Linux Posted December 17, 2007 Share Posted December 17, 2007 (edited) Thank you for your interest. i will try it later, but my goal is to make an algorithm so the program can choose ehat to build! more info the user is a test user, in a portuguese server. you need local ip to play, and i dont mind if you use it since is for test only. this is the lines of the $GetSource i'm trying to get, refering to the current building: <TD>Campo de cereais (nÃvel 2)</TD> <TD><SPAN id=timer1>0:07:20</SPAN> h</TD> <TD>acabado à s 13:55</SPAN><SPAN> hora</SPAN></TD></TR></TBODY></TABLE></DIV></DIV></DIV></DIV></DIV></DIV> Edit: i have the same problem. it happens when the first building finish, and it forces an AUTO-REFRESH of the website, usualy it comes with a dialog box with something like: "The page you are trying to refresh requires that you re-send extra data..." [OK] [Cancel] Edited December 17, 2007 by Linux You can help! Donate to AutoIt! or, visit ClimatePREDICTION.netMy posts:Travian Bot Example (100+ servers) BETAHow to Host you code/app for free! (unlimited team number) (Public or Private)"Sir, we're surrounded!" "Excellent. We can attack in any direction!" Link to comment Share on other sites More sharing options...
nobbe Posted December 17, 2007 Share Posted December 17, 2007 (edited) ok travian bot is a cool thing to do... the only reason why i started with autoit about a year ago was to build a travian bot my bot now has some nice features ( but bots are not allowed so i will not post source but if you have questions maybe i can help....) i put all events in a different config file : means : build wood, clay etc for town1, research #1, party, build stables , attack on pos x,y etc.. this way you may tune all different towns to do different things without using separate algorithms.. in my case eg: build_town=Versteck Stall Marktplatz Handelskontor Residenz Sägewerk Sägewerk Eisengießerei Lehmbrennerei attack_not=1=Keulenschwinger attack1=mekan|161|-60 attack2=really|161|-62 markt=3|0|0|1275,1275,1275,0|107,-50 now the information about building the new buildings i calculated like. Global $res_target_wood = "40|100|50|60|1.67" Global $res_target_clay = "80|40|80|50|1.67" Global $res_target_iron = "100|80|30|60|1.67"; Global $res_target_crop = "70|90|70|20|1.67"; Switch $bs_name Case "Holzfäller" $my_res_info = $res_target_wood Case "Lehmgrube" $my_res_info = $res_target_clay Case "Eisenmine" $my_res_info = $res_target_iron Case "Getreidefarm" $my_res_info = $res_target_crop EndSwitch $res_info = StringSplit($my_res_info, "|") ;$res_target_wood = "40|100|50|60|1.67" ;$res_target_clay = "80|40|80|50|1.67" ;$res_target_iron = "100|80|30|60|1.67"; ;$res_target_crop = "70|90|70|20|1.67"; ;BS info (Holzfäller) LEV (5) ID (3) ;BS info (Getreidefarm) LEV (7) ID (9) ;BS info (Eisenmine) LEV (6) ID (11) ;BS info (Lehmgrube) LEV (6) ID (18) $wood_needed_for_levup = Ceiling((($res_info[5] ^ $bs_lev) / 5) * $res_info[1] * 5) $clay_needed_for_levup = Ceiling((($res_info[5] ^ $bs_lev) / 5) * $res_info[2] * 5) $iron_needed_for_levup = Ceiling((($res_info[5] ^ $bs_lev) / 5) * $res_info[3] * 5) $crop_needed_for_levup = Ceiling((($res_info[5] ^ $bs_lev) / 5) * $res_info[4] * 5) ; DebugPrint ("Need for Next level : Wood (" & $wood_needed_for_levup & ") Clay (" & $clay_needed_for_levup & ") Iron (" & $iron_needed_for_levup & ") Crop (" & $crop_needed_for_levup & ")") ; now we calculate what we have - we need == rest $resource = StringSplit($glob_account_current_resource, "|") $wood_needed = $wood_needed_for_levup - $resource[1]; $clay_needed = $clay_needed_for_levup - $resource[2]; $iron_needed = $iron_needed_for_levup - $resource[3]; $crop_needed = $crop_needed_for_levup - $resource[4]; ; if MISSING ="-" then we have Enough ! ; DebugPrint ("Missing here : Wood (" & $wood_needed & ") Clay (" & $clay_needed & ") Iron (" & $iron_needed & ") Crop (" & $crop_needed & ")") ; $maximum_minutes = 0; $resource_per_hours = StringSplit($glob_account_current_prod_per_hour, "|") $wood_needs_another_min = Ceiling($wood_needed / ($resource_per_hours[1] / 60)); for min $clay_needs_another_min = Ceiling($clay_needed / ($resource_per_hours[2] / 60)); for min $iron_needs_another_min = Ceiling($iron_needed / ($resource_per_hours[3] / 60)); for min $crop_needs_another_min = Ceiling($crop_needed / ($resource_per_hours[4] / 60)); for min the bot now calculates all building times for each resource and other building when time has come and nothing is currently building , my bot will automatically build a new resource or level up a building.. maybe it helps-- greets.. Edited January 25, 2008 by nobbe Link to comment Share on other sites More sharing options...
nobbe Posted December 18, 2007 Share Posted December 18, 2007 Edit: i have the same problem. it happens when the first building finish, and it forces an AUTO-REFRESH of the website, usualy it comes with a dialog box with something like: "The page you are trying to refresh requires that you re-send extra data..." [OK] [Cancel] you will need an external program to "click" the message box .. (edit title match to your language).. ; Opt("wintitlematchmode",4); While True If WinExists("Microsoft Internet Explorer","Die Seite kann ohne ein erneut") Then ControlClick("Microsoft Internet Explorer","Die Seite kann ohne ein erneut","Button1") ConsoleWrite ("found ie wiederholen .. " &@CRLF); EndIf Sleep(2000) WEnd Link to comment Share on other sites More sharing options...
WolfWorld Posted December 18, 2007 Share Posted December 18, 2007 love you Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! Link to comment Share on other sites More sharing options...
jvanegmond Posted December 18, 2007 Share Posted December 18, 2007 (edited) I have looked every for the game Travian! My uncle told me about it, but I forgot the name.. Then I really did a lot of searching, but found nothing.. Thanks!! For the name.. Edited December 18, 2007 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
MadBoy Posted December 18, 2007 Share Posted December 18, 2007 my bot now has some nice features ( but bots are not allowed so i will not post source but if you have questions maybe i can help....)Since when bots are not allowed? Those are most likely not allowed in game but not on AutoIt Forum. So feel free to post one My little company: Evotec (PL version: Evotec) Link to comment Share on other sites More sharing options...
Linux Posted December 19, 2007 Share Posted December 19, 2007 (edited) Since when bots are not allowed? Those are most likely not allowed in game but not on AutoIt Forum. So feel free to post one To me this is like a hobby. im a computer technician and i like to program.Plus, I like the game, i also buy gold to help support them, only play with ONE account per server, so the game dont get to much time consumig.I'm working on a bot to meet the following features:-Queue-A.I. to spend resources upgrading buildings (if queue is empty)-(Several languages, with help)-Nice interfaceI changed the auto-login code, because im now able to detect a unespected logout. and the code starts with the /dorf1.php, so it only logins if it realy has to.i've read a lot about autoit, and i love it.i hope that soon i have a stable version.edit: i dont have the following problem anymoreAlso, i would like to create a func that returns the following:Current building: Ex: Woodcutter lvl 3Time to the building to finish: 00:15:12Finish at: 16.23But i will post some if i cant solve them meanwhile. Edited December 19, 2007 by Linux You can help! Donate to AutoIt! or, visit ClimatePREDICTION.netMy posts:Travian Bot Example (100+ servers) BETAHow to Host you code/app for free! (unlimited team number) (Public or Private)"Sir, we're surrounded!" "Excellent. We can attack in any direction!" Link to comment Share on other sites More sharing options...
Linux Posted December 19, 2007 Share Posted December 19, 2007 (edited) Hi all! does anyone one knows how the best way to make a timed event?if i have the time of the next move (ex: 16:21:20) how can i make a timed event to make the next move?im open to all type of sugestions.thanks in advance, LinuxEdit: I found this Edited December 19, 2007 by Linux You can help! Donate to AutoIt! or, visit ClimatePREDICTION.netMy posts:Travian Bot Example (100+ servers) BETAHow to Host you code/app for free! (unlimited team number) (Public or Private)"Sir, we're surrounded!" "Excellent. We can attack in any direction!" Link to comment Share on other sites More sharing options...
Linux Posted December 24, 2007 Share Posted December 24, 2007 (edited) hi all! i'm having some problems while filling a table with data.can someone tellme what is the problem with this code?$ListView1 = GUICtrlCreateListView("Madeira|Barro|Ferro|Cereal|", 8, 304, 226, 150)for $i = 1 to 6 GuiCtrlCreateListViewItem($campos[$i][1] & " |" & $campos[$i][2] & " |" & $campos[$i][3] & " |" & $campos[$i][4], $ListView1) ConsoleWrite($campos[$i][1] & " |" & $campos[$i][2] & " |" & $campos[$i][3] & " |" & $campos[$i][4] & @CRLF)NextEven if i change that expression to something like: GuiCtrlCreateListViewItem("a | b | c | d", $ListView) it wont work! thank you in advanceedit: i managed to make it work. but i have a simple question. can i see witch COLumn and ROW is selected by the mouse click? Edited December 24, 2007 by Linux You can help! Donate to AutoIt! or, visit ClimatePREDICTION.netMy posts:Travian Bot Example (100+ servers) BETAHow to Host you code/app for free! (unlimited team number) (Public or Private)"Sir, we're surrounded!" "Excellent. We can attack in any direction!" Link to comment Share on other sites More sharing options...
Zepx Posted December 27, 2007 Share Posted December 27, 2007 (edited) Nobbe do you plan to share it with us in any ways? Edited December 27, 2007 by Zepx Link to comment Share on other sites More sharing options...
Linux Posted December 27, 2007 Share Posted December 27, 2007 (edited) Nobbe do you plan to share it with us in any ways? Hi Zepx! I spoke to him in private, and he is not willing to share his code. I dont criticism him, since there is a lot of hard work in it. Try to make it yourself, and you will fell the same. im experien it myself. But, i'm willing to share it. maybe to someone who proves be honored and willing to share his development. or maybe someday, when i get tired of the game, and decide to make it public, like Jex. Note: i'm using some functions from Jex. Thank you very much. yet, im working hard to make myself a bot. i manage to learn how to read the info from the website. now that the hard work is done(only exception is the dorf2.php page) is time to make a queue and a some A.I. to self manage the village. i plan to archive this goals in the end of the next 2 month: -dorf2.php (buildings) -Queue for each village -A.I. to spend resources in upgrading resources -Defense Plan -Market Managing System -External: Aquire array of "full farms" from a world analizer (ex: all players near X,Y that dont change population in 5 days) -Attack an array of enemies, Village independent Yet, im having a problem. is in the IE auto refresh. if make an actions, like produce 2 soldiers, and wait for the 1st to be ready without making any other action, a dialog box pop's up and ask to resend the data for the refresh. i'll have to force a random refresh before the first timer expires, im working on that. will also be very good to disable it on the registry. Nobbe also helped a lot in a function to calc the resources needed for upgrading a resource. Here is the result, i tweak since im using arrays when i can. Global $res_target_wood[5] = [1.67,40,100,50,60], $res_target_clay[5] = [1.67,80,40,80,50], $res_target_iron[5] = [1.67,100,80,30,60], $res_target_crop[5] = [1.67,70,90,70,20] _arrayDisplay(CalcResources("crop",10)) Func CalcResources($Building ,$BLvl) Local $StringB = StringLower($Building), $needed[5] Local $res_info[7], $Lvl = int($BLvl), $resource = $glob_account_current_resource Switch $StringB Case "madeira" or "1" ;WOOD $res_info = $res_target_wood Case "barro" or "2" ; CLAY $res_info = $res_target_clay Case "ferro" or "3" ; IRON $res_info = $res_target_iron Case "crop" or "4" ; CROOP $res_info = $res_target_crop EndSwitch For $Index = 1 to 4 $needed[$Index] = Ceiling(((($res_info[0]) ^ $Lvl) / 5) * int($res_info[$Index]) * 5) - $resource[$Index] Next if (_ArrayMax($needed) < 0) then Output("We have enough resources. MAX: " & _ArrayMax($needed)) return -1 Else for $Index = 1 to 4 $needed[$Index] = Ceiling($needed[$Index] / ($resource[$Index] / 60) ) Next EndIf $Lvl = _ArrayMax($needed) return $Lvl EndFunc This is a screenshot of today Edited December 27, 2007 by Linux You can help! Donate to AutoIt! or, visit ClimatePREDICTION.netMy posts:Travian Bot Example (100+ servers) BETAHow to Host you code/app for free! (unlimited team number) (Public or Private)"Sir, we're surrounded!" "Excellent. We can attack in any direction!" Link to comment Share on other sites More sharing options...
nobbe Posted December 27, 2007 Share Posted December 27, 2007 Nobbe do you plan to share it with us in any ways?hi all as linux already said i will not share the whole bot or code of the complete bot since my work in the program is already more than one year i also feel that it will ruin the whole game experience if everybody can freely use a well configured bot to play the gamemy bot was only intended to play the "routine" parts of the game, like upgrading resource or buildings and delivering market shares to my other townsthe game itself contains more strategic parts when you are part of an alliance which coordinates attacks etc. therefore you will need still substantial game knowledge to be successful (with or without a bot usage)i will assist linux in terms of knowledge or game strategy - if he then releases a code or full bot its his decision..the bot building itself is straightforward hereanalyse dorf1.php for each town - detect it enough resource are present to upgrade a resource building, also figure out which are useful resource (in a crop town you will not really put all crop to lev 10 but others first..)- detect if troops are present ( your own) then decide if to attack other towns ( by random list) and with which kinds of troops and "how many" (for farming etc you will need little troop numbers) - detect if attack is coming ( to your town) then use "escape mode for your troops" and deliver resource to "your" other towns..analyse dorf2.php for each town - build buildings according to setting of town (on some towns you need a residence really fast now because you need to build a new town etc.)- follow the links to the "research buildings" to upgrade weapons if needed- follow the links to "party" .. - follow the market links to deliver resources calculated to your other towns eg (1/3,1/3,1/3,0) to town 123,123all other ideas are always to the "bot builder" and some ideas are evolving over year -. there it was always a good idea for me to play it in speed rounds to test new ideas and strategies.. (my bot was on rank 80 last speed round :-) another idea i had was to build new towns according to a template, eg on ID20=market, ID 21=stables etc. but i lost interest in the game and havent continued much here..basically its an easy game bot building - just figure out which links you have to follow and how they are setup to perform a certain task - here i found autoit is the perfect langage to do this..another bot of mine was finding other crop fields in certain areas (eg scan area 23-40 for crop fields) since 9 or 15 crop fields will be most useful later in the gamegreetings nobbe Link to comment Share on other sites More sharing options...
Linux Posted December 28, 2007 Share Posted December 28, 2007 (edited) see the attachment The bot is able to spend all resource once in AUTO mode. its from the first version. and its in portuguese, so you may have to change it to the string. I didnd developed more since it was very dificult to enable the diferente types of villages (ex: 5346, 3339), and several villages. version 2.0 i have this and much more Edit: dont touch the $Autopilot = "off" change that variavel by hiting the button AUTO. i know the cado isnt very tidy, but you get the point. if you figure a better way to do something, pls send me you idea. Edited December 28, 2007 by Linux You can help! Donate to AutoIt! or, visit ClimatePREDICTION.netMy posts:Travian Bot Example (100+ servers) BETAHow to Host you code/app for free! (unlimited team number) (Public or Private)"Sir, we're surrounded!" "Excellent. We can attack in any direction!" Link to comment Share on other sites More sharing options...
dumbledor Posted December 28, 2007 Share Posted December 28, 2007 I am learning autoit becouse i want to make my own travian bot. Between my spare time. So don t give hole code, just pieces to help and direct me. I like my own solutions. I found this topic very useful. See you soon i hope. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now