GRB Posted January 27, 2008 Posted January 27, 2008 Does anyone also have this error? The code in line 286 is: $o_object.navigate ($s_Url) But i always get an error about that line!
GRB Posted January 27, 2008 Author Posted January 27, 2008 C:\Program Files\AutoIt3\Include\IE.au3 (286) : ==> The requested action with this object has failed.: $o_object.navigate ($s_Url) $o_object.navigate ($s_Url)^ ERROR AutoIT3.exe ended.rc:1 AutoIt3Wrapper Finished
GRB Posted January 27, 2008 Author Posted January 27, 2008 expandcollapse popup#include <IE.au3> #include <INet.au3> #include <GUIConstants.au3> #include <String.au3> #include <Array.au3> #include <Date.au3> #cs Original Code by JEX & Linux from AUTOIT3 Forum Travian v. 1.3 PT further development by GRB from autoit forum TODO Several Villages check in : 00:03:12 Doble Slot Timed events Queue Autopilot #ce $Intro = GUICreate("", 80, 100, 500, 300) GUICtrlCreateLabel("Choose", 25, 5) GUICtrlCreateLabel("Your", 32, 18) GUICtrlCreateLabel("Player", 28, 32) $Button_1 = GUICtrlCreateButton("GRB", 15, 50, 50, 20) $Button_2 = GUICtrlCreateButton("LittleNurse", 10, 70, 60, 20) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 Global $User = "GRB" Global $Pass = "....." ExitLoop Case $msg = $Button_2 Global $User = "LittleNurse" Global $Pass = "......." ExitLoop EndSelect Wend GUIDelete ($Intro) ;Form & variavel Global $AlreadyExecuted = False ; Make sure only 1 program at time. $g_szVersion = "!Travian v.1.3 PT" If WinExists($g_szVersion) Then $AlreadyExecuted = True Exit; It's already running EndIf AutoItWinSetTitle($g_szVersion) Global $Link = "http://s2.travian.pt", $AutoPilot = "off", $Randomfactor = Random(10,20,1) Global $5Minute = 0, $TimerDiff = 0, $Checkin = 0, $GetSource = "", $MinCrop = 12 Global $CBuilding[5], $GetMaterials[5][5], $GetProductions[5][5], $GetResourceFields [7][7] ,$ResourceMinutes [7][7] , $Button[5][7], $Label[6], $Label2[5] 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] Global $glob_account_current_resource[5] = [ 0 , 0 , 0 , 0, 0] if 1 Then TrayTip("", "Loading...", 1) $oIE = _IECreateEmbedded() $Form = GUICreate("!Travian v.1.4 PT", 1024, 780) GUISetBkColor(0xFFFFFF) $GUIActiveX = GUICtrlCreateObj($oIE, 10, 250, 900, 500) _IENavigate ($oIE, $Link & "/dorf1.php") $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)) $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, 20) $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) $Label28 = GUICtrlCreateLabel("Next:", 10, 210, 50, 17) $Label28 = GUICtrlCreateLabel("em", 120, 210, 50, 17) $LabelNextB = GUICtrlCreateLabel("<none>", 40, 210, 300, 27) $LabelFinishIn = GUICtrlCreateLabel("", 180, 210, 50, 17) $LabelFinishAt= GUICtrlCreateLabel("", 260,210,90,17) $Attake = GUICtrlCreateButton("Attake", 450, 176, 50, 25, 0) $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) HotKeySet("^!x", "Hkey") endif;Form Loading ;Load IE ;RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Display Inline Images", "REG_SZ", "no") TrayTip("","Login " & $User, 0) ;_IELoadWait($oIE,1000,30000) GUISetState(@SW_SHOW) Login($User, $Pass) Check() TrayTip("", "", 0) 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() If $msg = $Attake Then Attake() $TimerDiff += TimerDiff($Timer) If ($TimerDiff >= 10000) Then Checkbox() $TimerDiff = 0 ;$t1 = API_GetLocalTime() ;ConsoleWrite( $t1 & @crlf) EndIf If ( $Checkin <> (10 - int($TimerDiff/1000)) ) Then $Checkin = (10 - int($TimerDiff/1000)) GUICtrlSetData($LabelDeb, "Check in: " & ($Randomfactor - $5Minute) - 1 & 9 - int($TimerDiff/1000)) EndIf WEnd; MAIN PROGRAM Func Check() _IELoadWait($oIE) ConsoleWrite("Starting check..." & @CRLF) $GetSource = _IEDocReadHTML($oIE) if StringInStr($GetSource, "0:00:0</span>?") then _IENavigate($oIE, $Link & "/dorf1.php", 1) _IELoadWait($oIE) $GetSource = _IEDocReadHTML($oIE) EndIf ConsoleWrite("Materials" & @CRLF) $GetMaterials = GetMaterials() ;if StringInStr($GetSource,"Tropas:") then ConsoleWrite("prod" & @CRLF) $GetProductions = GetProductions() ConsoleWrite("Rtimes" & @CRLF) $GetTimes = CalculateResourceTime() ConsoleWrite("RFields" & @CRLF) $GetResourceFields = GetResourceFields() ;EndIf ConsoleWrite("Show Data!" & @CRLF) 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 $ResourceMinutes[$x][$y] = CalcResources($x ,$GetResourceFields[$x][$y]) GUICtrlSetData($Button[$x][$y], "Lvl " & $GetResourceFields[$x][$y] & " -> " & $ResourceMinutes[$x][$y]) If $x = 4 And $y = 4 Then $ResourceMinutes[$x][$y + 1] = CalcResources($x ,$GetResourceFields[$x][$y + 1]) $ResourceMinutes[$x][$y + 2] = CalcResources($x ,$GetResourceFields[$x][$y + 2]) GUICtrlSetData($Button[$x][$y + 1], "Lvl " & $GetResourceFields[$x][$y + 1] & " -> " & $ResourceMinutes[$x][$y]) GUICtrlSetData($Button[$x][$y + 2], "Lvl " & $GetResourceFields[$x][$y + 2] & " -> " & $ResourceMinutes[$x][$y]) EndIf Next Next CheckWorkers() ConsoleWrite("End check..." & @CRLF) EndFunc ;==>Check Func Checkbox() If $AutoPilot = "on" Then $5Minute += 1 If $5Minute = $Randomfactor Then $Randomfactor = Random(10,20,1) $5Minute = 0 If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then Check() EndIf EndIf EndFunc Func Login($Username, $Password) $GetSource = _IEDocReadHTML($oIE) if (StringInStr($GetSource, 'Obrigado pela visita') or StringInStr($GetSource, "sendo o cookie apagado no fim de cada sessão")) Then $oForm = _IEFormGetCollection($oIE, 0) $oQuery = _IEFormElementGetCollection($oForm, 2) _IEFormElementSetValue($oQuery, $Username) $oQuery = _IEFormElementGetCollection($oForm, 3) _IEFormElementSetValue($oQuery, $Password) _IEFormSubmit($oForm) Local $Source = _IEDocReadHTML($oIE) If Not StringInStr($Source, 'tuado em <b>') Then MsgBox("", "Error!", "Username or password wrong.") EndIf _IELoadWait($oIE); Sleep(random(1000,2000,1)) EndIf if StringInStr($GetSource, "continuar</a>") Then _IELinkClickByText($oIE,"Continuar") ;$oLinks = _IELinkGetCollection ($oIE, 15) ;_IEAction($oLinks, "click") _IELoadWait($oIE) sleep(Random(2000,4000,1)) $GetSource = _IEDocReadHTML($oIE) sleep(Random(2000,4000,1)) ;_IENavigate($oIE, "http://speed.travian.com.br/spieler.php?s=4&ok=1") ;_IELoadWait($oIE) EndIf EndFunc ;==>Login Func Build($xx, $yy) $Number = GetResourceNumbers() _IENavigate($oIE,($Link & "/build.php?id=" & $Number[$xx][$yy])) $GetSource = _IEDocReadHTML($oIE) ;$GetSource = _INetGetSource($Link & "/build.php?id=" & $Number[$xx][$yy]) If StringInStr($GetSource, "Poucos recursos") Then TrayTip("", "Poucos recursos!", 1) Sleep(random(1000,2000,1)) _IENavigate($oIE,($Link & "/dorf1.php")) _IELoadWait($oIE) Sleep(random(1000,2000,1)) Return 0 ElseIf StringInStr($GetSource, "se encontram ocupados") Then TrayTip("", "Os trabalhadores já se encontram ocupados!", 1) Sleep(random(1000,2000,1)) _IENavigate($oIE,($Link & "/dorf1.php")) _IELoadWait($oIE) Sleep(random(1000,2000,1)) Return 0 ElseIf StringInStr($GetSource, "desenvolve um campo de cereais primeiro") Then TrayTip("", "Carencia de cereal!", 1) Sleep(random(1000,2000,1)) _IENavigate($oIE,($Link & "/dorf1.php")) _IELoadWait($oIE) Sleep(random(1000,2000,1)) Return 0 Else TrayTip("", "Building...", 1) sleep(1200+Random(1200,4000)) Local $found = 0, $Goodlink = 0, $URL, $linkURL, $links = $oIE.document.links For $URL In $links $found += 1 $linkURL = $URL.href If StringInStr($linkURL,"dorf1.php?a") Then ConsoleWrite($linkURL & @CRLF & " At: " & $found) $Goodlink = $found - 1 EndIf Next if $Goodlink <> 0 then $oLinks = _IELinkGetCollection ($oIE, $Goodlink) _IEAction($oLinks, "click") _IELoadWait($oIE) $GetSource = _IEDocReadHTML($oIE) CheckWorkers() Else ConsoleWrite("No Link! " & @CRLF) EndIf EndIf EndFunc ;==>Build Func CheckWorkers() ConsoleWrite("Starting work check..." & @CRLF) if StringInStr($GetSource, "acabado ") Then $oTable = _IETableGetCollection ($oIE) $iNumTables = @extended Local $Found = false For $Count = 0 to $iNumTables - 1 $oTable = _IETableGetCollection($oIE, $Count) Local $aTableData = _IETableWriteToArray($oTable) if (UBound($aTableData,1 ) = 4 and (UBound($aTableData,2 ) = 1 or UBound($aTableData,2 ) = 2)) then $CBuilding = $aTableData $Found = true EndIf Next If $Found Then GUICtrlSetData($LabelNextB ,$CBuilding[1][0]) GUICtrlSetData($LabelFinishIn ,$CBuilding[2][0]) GUICtrlSetData($LabelFinishAt ,$CBuilding[3][0]) Else ConsoleWrite("Next Building table not found!" & @CRLF) EndIf Else ConsoleWrite("workers not found") GUICtrlSetData($LabelNextB ,"None") GUICtrlSetData($LabelFinishIn ,"") GUICtrlSetData($LabelFinishAt ,"") if $AutoPilot = "on" then BuildResources() EndIf ConsoleWrite("end work check..." & @CRLF) EndFunc 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" $res_info = $res_target_wood Case "barro" or "2" $res_info = $res_target_clay Case "ferro" or "3" $res_info = $res_target_iron Case "crop" or "4" $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 ConsoleWrite("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 Func Auto() if $AutoPilot = "off" Then TrayTip("","Auto on!",0) $AutoPilot = "on" check() Else TrayTip("","Auto off!",0) $AutoPilot = "off" EndIf EndFunc Func Attake() $AttakeForm = GUICreate("Attake", 100, 200, 538, 13) $Button_3 = GUICtrlCreateButton("Optimus", 10, 10, 50, 25) $Button_4 = GUICtrlCreateButton("Goleiro", 10, 40, 50, 25) $Button_5 = GUICtrlCreateButton("Enrique", 10, 70, 50, 25) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_3 _IENavigate($oIE,($Link & "/a2b.php?z=379264")) _IELoadWait($oIE) $oForm = _IEFormGetCollection($oIE, 0) $oQuery = _IEFormElementGetCollection($oForm, 1) $oQuery1 = _IEFormElementGetCollection($oForm, 12) _IEFormElementSetValue($oQuery, "14") _IEFormElementRadioSelect($oQuery1, "", 1) ExitLoop Case $msg = $Button_4 _IENavigate($oIE,($Link & "/karte.php")) _IELoadWait($oIE) ExitLoop Case $msg = $Button_5 _IENavigate($oIE,($Link & "/karte.php")) _IELoadWait($oIE) ExitLoop EndSelect Wend GUIDelete ($AttakeForm) EndFunc Func BuildResources() local $Nextx = 0, $Nexty = 0 local $TTable[7] ;Test Crop prod if $GetProductions[4] < $MinCrop then ConsoleWrite("Forcing build Crop") $Nextx = 4 else for $Index = 1 to 4 $TTable[$Index] = $GetMaterials[$Index][1] Next $Nextx = ArrayMinIndex($TTable);min resource? EndIf If $Nextx = 0 Then ConsoleWrite("No decition! Maybe few resources..." & @CRLF) Return 0 EndIf ;_ArrayDisplay($GetMaterials) ;_ArrayDisplay($TTable) ConsoleWrite("Nextx = " & $Nextx) for $Index = 1 to 4 $TTable[$Index] = $GetResourceFields[$Nextx][$Index] if (($Index = 4) and ($Nextx = 4)) then $TTable[5] = $GetResourceFields[$Nextx][5] $TTable[6] = $GetResourceFields[$Nextx][6] EndIf Next ;_ArrayDisplay($GetResourceFields) ;_ArrayDisplay($TTable) $Nexty = ArrayMinIndex($TTable) ConsoleWrite("Nexty = " & $Nexty & @CRLF) if ($Nexty <> 0) then build($Nextx, $Nexty) EndFunc;==> Auto 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], $Countt = 0 For $Index = 1 To 7 Step 2 $Countt = $Countt + 1 $Split = StringSplit($aTableData[$Index][0], "/", 1) $Materials[$Countt][1] = $Split[1] $glob_account_current_resource[$Countt] = Number($Split[1]) $Materials[$Countt][2] = $Split[2] Next $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], "Bosque nível ", "") $Areas[$i] = StringReplace($Areas[$i], "Poço de barro nível ", "") $Areas[$i] = StringReplace($Areas[$i], "Mina de ferro nível ", "") $Areas[$i] = StringReplace($Areas[$i], "Campo de cereais nível ", "") 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] = "Floresta: " & $ResourceFields[$i][$y] ElseIf $i = 2 And $y = 1 Then $Fields[2] &= @CRLF & "Poço de Barro: " & $ResourceFields[$i][$y] ElseIf $i = 3 And $y = 1 Then $Fields[2] &= @CRLF & "Mina de Ferro: " & $ResourceFields[$i][$y] ElseIf $i = 4 And $y = 1 Then $Fields[2] &= @CRLF & "Campo de Cereal: " & $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 if ($GetMaterials[$i][1] = $GetMaterials[$i][2]) then $Minute = 0 Else $Minute = Round(($GetMaterials[$i][2] - $GetMaterials[$i][1]) / ($GetProductions[$i] / 60), 0) EndIf $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 API_GetLocalTime() Local $stSystemTime = DllStructCreate('ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort') DllCall('kernel32.dll', 'none', 'GetLocalTime', 'ptr', DllStructGetPtr($stSystemTime)) Local $gst=DllStructGetData($stSystemTime, 1) For $i = 2 to 8 $gst = $gst & ":" & DllStructGetData($stSystemTime, $i) Next $stSystemTime = 0; free structure from memory return $gst EndFunc;Get System Time Func ArrayMinIndex(Const ByRef $avArray, $iCompNumeric = 0, $i_Base = 1) Local $iCntr = 0, $iMinIndex = $i_Base If Not IsArray($avArray) Then ConsoleWrite("ERROR! not array!") SetError(1) Return "" EndIf Local $iUpper = UBound($avArray) For $iCntr = $i_Base To ($iUpper - 1) if (String($avArray[$iCntr]) <> "") then If $iCompNumeric = 1 Then If Number($avArray[$iMinIndex]) > Number($avArray[$iCntr]) Then $iMinIndex = $iCntr EndIf Else If $avArray[$iMinIndex] > $avArray[$iCntr] Then $iMinIndex = $iCntr EndIf EndIf EndIf Next SetError(0) Return $iMinIndex EndFunc Func Hkey() Exit EndFunc;HOTKEY CTRL + ALT + X Func OnAutoItExit() ;_IEQuit($oIE) if ($AlreadyExecuted = False) then If WinExists($oIE) then _IENavigate($oIE, $Link & "/logout.php", 1) $oIE.Quit ; Close IE Window $oIE=0 ; Remove IE from memory (not really necessary). EndIf EndIf GUIDelete () ;RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main", "Display Inline Images", "REG_SZ", "yes") EndFunc ;==>OnAutoItExit
PsaltyDS Posted January 28, 2008 Posted January 28, 2008 First, codeBOX man ...codeBOX!!! Something is funky about the URL string you are passing to _IENavigate(). Put _IEErrorHandlerRegister() near the top of your script and run it from SciTE to see if you get more info.I had thought this stuff looked suspicious as a way to format strings:Func Build($xx, $yy) $Number = GetResourceNumbers() _IENavigate($oIE, ($Link & "/build.php?id=" & $Number[$xx][$yy])) $GetSource = _IEDocReadHTML($oIE) ; ... EndFuncoÝ÷ ØÜ(®K0éȵë-yØÂ+a¶¬jëh×6Global $Number[2][2] = [["00", "01"], ["10", "11"]] $xx = 0 $yy = 1 $Link = "http://www.google.com" ConsoleWrite("Debug: " & ($Link & "/build.php?id=" & $Number[$xx][$yy]) & @LF) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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