aNewLyfe Posted November 2, 2007 Share Posted November 2, 2007 (edited) im writing a script to download warcraft 3 maps. also i want to download map preview images at same time. but theres an error i dunno why i worked on it too much but nope, cant get it to work. im using stringbetween command for get file link and its working, but when i use to get img too ; autoit says array used with non-array bla blas ... heres my entire script. if u cant see fonts please rename it to verdana or something. expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.2.4.9 Author: sup man ? Script Function: Gives non-array errors 4 u :) #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #AutoIt3Wrapper_useupx = 0 #include <GUIConstants.au3> #include <guistatusbar.au3> #include <string.au3> #include <inet.au3> #include <array.au3> Opt("GUIOnEventMode", 1) Opt("TrayMenuMode", 1) Opt("TrayOnEventMode",1) $trayhide = TrayCreateItem("Hide Main Window") TrayItemSetOnEvent($trayhide,"_trayshow") $trayexit = TrayCreateItem("Exit") TrayItemSetOnEvent($trayexit,"_trayexit") #Region ### START Koda GUI section ### Form=C:\Documents and Settings\313\Desktop\Warcraft MapZ DownloadeR\mainform.kxf $Form1 = GUICreate("Warcraft.Org Download All MapZ", 376, 533, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "AForm1Close") $Group1 = GUICtrlCreateGroup(" 313 Toolz ", 8, 8, 361, 313, $BS_CENTER) GUICtrlSetFont(-1, 24, 800, 0, "Necropsy") $Label1 = GUICtrlCreateLabel(" Map Type Select :", 16, 56, 345, 41, BitOR($SS_CENTERIMAGE,$SS_SUNKEN)) GUICtrlSetState(-1,$gui_disable) $Label9 = GUICtrlCreateLabel("Map Type Select :", 24, 72, 91, 17) $Combo1 = GUICtrlCreateCombo("", 160, 64, 193, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL,$WS_BORDER)) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetData(-1,"Single Player Maps|Melee Maps|Custom Maps","Single Player Maps") $Checkbox1 = GUICtrlCreateCheckbox("Also Download Map Preview Pictures", 16, 160, 233, 17) GUICtrlSetFont(-1, 8, 400, 0, "Verdana") $Label2 = GUICtrlCreateLabel(" Download Directory :", 16, 103, 345, 41, BitOR($SS_CENTERIMAGE,$SS_SUNKEN)) GUICtrlSetState(-1,$gui_disable) $Label10 = GUICtrlCreateLabel("Download Directory :", 23, 118, 123, 17) $Input1 = GUICtrlCreateInput(@ScriptDir&"\test", 160, 112, 137, 21, BitOR($ES_AUTOHSCROLL,$ES_READONLY)) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) GUICtrlSetBkColor(-1,0xFFFFFF) $Button1 = GUICtrlCreateButton("Set", 302, 112, 51, 21, 0) GUICtrlSetFont(-1, 8, 400, 0, "Verdana") GUICtrlSetOnEvent(-1, "AButton1Click") $Checkbox2 = GUICtrlCreateCheckbox("Create Directories per Map", 16, 184, 185, 17) GUICtrlSetFont(-1, 8, 400, 0, "Verdana") $Checkbox3 = GUICtrlCreateCheckbox("Save Log of Downloaded MapZ ( at script directory )", 16, 208, 321, 17) GUICtrlSetFont(-1, 8, 400, 0, "Verdana") $Checkbox5 = GUICtrlCreateCheckbox("Hide Main Window", 16, 232, 137, 17) GUICtrlSetFont(-1, 8, 400, 0, "Verdana") $Button2 = GUICtrlCreateButton("Start Download", 16, 264, 343, 41, 0) GUICtrlSetFont(-1, 16, 400, 0, "Mark") GUICtrlSetOnEvent(-1, "AButton2Click") GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("Download", 8, 328, 361, 177, $BS_CENTER) GUICtrlSetFont(-1, 26, 800, 0, "SolsticeOfSuffering") $Label3 = GUICtrlCreateLabel(" Current File :", 16, 392, 344, 17, BitOR($SS_CENTERIMAGE,$SS_SUNKEN)) GUICtrlSetFont(-1, 8, 400, 0, "Verdana") GUICtrlSetColor(-1, 0x0000FF) $Label4 = GUICtrlCreateLabel(" Status :", 16, 415, 344, 17, BitOR($SS_CENTERIMAGE,$SS_SUNKEN)) GUICtrlSetFont(-1, 8, 400, 0, "Verdana") GUICtrlSetColor(-1, 0xFF0000) $Label5 = GUICtrlCreateLabel(" Get Info Progress :", 16, 438, 344, 17, BitOR($SS_CENTERIMAGE,$SS_SUNKEN)) GUICtrlSetFont(-1, 8, 400, 0, "Verdana") GUICtrlSetColor(-1, 0x008000) $Label6 = GUICtrlCreateLabel("", 104, 393, 242, 14) GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) $Label7 = GUICtrlCreateLabel("", 72, 416, 104, 17) GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) $Progress1 = GUICtrlCreateProgress(184, 416, 176, 16) GUICtrlSetData(-1, 0) $Label8 = GUICtrlCreateLabel("", 120, 440, 33, 17) GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT) $Progress2 = GUICtrlCreateProgress(184, 439, 176, 16) GUICtrlSetData(-1, 0) GUICtrlSetColor(-1, 0x800000) $Button3 = GUICtrlCreateButton("Abort download", 15, 464, 171, 25, 0) GUICtrlSetFont(-1, 12, 400, 0, "Mark") GUICtrlSetOnEvent(-1, "AButton3Click") $Button4 = GUICtrlCreateButton("Hide this window", 190, 464, 171, 25, 0) GUICtrlSetFont(-1, 12, 400, 0, "Mark") GUICtrlSetOnEvent(-1, "AButton4Click") GUICtrlCreateGroup("", -99, -99, 1, 1) Local $a_PartsRightEdge[1] = [380] Local $a_PartsText[1] = ["Tool edited by 313 - 02/11/2007 - codegenX"] $StatusBar1 = _GUICtrlStatusBarCreate ($Form1, $a_PartsRightEdge, $a_PartsText) GUICtrlSetState($Group2,$gui_disable) GUICtrlSetState($Button3,$gui_disable) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $started = 0 Global $mainimglink = "null" Global $dlword = "null" Global $imgsrc = "null" While 1 Sleep(100) if $started = 1 Then ;~ GET MAP TYPE $readfirst = GUICtrlRead($Combo1) if $readfirst = "Single Player Maps" Then $mainlink = "http://www.warcraft.org/maps/details/s" $dlword = "s" $imgsrc = "single.0/" ElseIf $readfirst = "Melee Maps" Then $mainlink = "http://www.warcraft.org/maps/details/m" $dlword = "m" $imgsrc = "melee.0/" ElseIf $readfirst = "Custom Maps" Then $mainlink = "http://www.warcraft.org/maps/details/c" $dlword = "c" $imgsrc = "custom.0/" EndIf ;~ END OF GET MAP TYPE for $i = 1 to 1999 Step 1 GUICtrlSetData($Progress1,0) GUICtrlSetData($Progress2,0) _GUICtrlStatusBarSetText($StatusBar1,"Connecting to URL : "&$mainlink&$i,0) $source = _INetGetSource($mainlink&$i) if @error Then _GUICtrlStatusBarSetText($StatusBar1,"Failed to connect URL..",0) Sleep(500) if InetGetSize($mainlink&$i) < "2500" Then _GUICtrlStatusBarSetText($StatusBar1,"Cannot find map file @ this url..",0) Sleep(500) Else GUICtrlSetData($Progress2,50) $dlink = _StringBetween($source,"/maps/download/",'">Download Now</a>') _GUICtrlStatusBarSetText($StatusBar1,"Map Found : "&$dlink[0]&" - Downloading...",0) $w3link = "http://www.warcraft.org/maps/download/" $endlink = $w3link&$dlink[0] $getfilename = _StringBetween($source,$dlword&$i&"/",'">Download Now</a>') $filename = $getfilename[0] $imgname = $filename&".jpg" if GUICtrlRead($Checkbox2) = $GUI_CHECKED Then $fileshort = _StringBetween($source,$dlword&$i&"/",'.zip">Download Now</a>') $dldir = GUICtrlRead($input1)&"\"&$fileshort[0] DirCreate($dldir) if @error then MsgBox(0,"","dir create error") Else $dldir = GUICtrlRead($input1) EndIf $finaldl2hdd = $dldir&$filename if FileExists($finaldl2hdd) Then $filename = Random(1,9999,1)&$filename EndIf $size = InetGetSize($endlink) GUICtrlSetData($Progress2,100) if GUICtrlRead($Checkbox3) = $GUI_CHECKED Then FileWriteLine(@ScriptDir&"\mapLOG.txt",$endlink&":"&$dldir&$filename&@CRLF) EndIf ;~ GET IMG / not working ;~ if GUICtrlRead($Checkbox1) = $GUI_CHECKED Then ;~ $str = _StringBetween($source,'/maps/data/'&$imgsrc,'" width=256 height=256>') ;~ $mainimglink = "http://www.warcraft.org/maps/data/"&$imgsrc&$str[0] ;~ InetGet($mainimglink,$dldir&"\"&$imgname,1,1) ;~ EndIf ;~ GET IMG / END of get img InetGet($endlink,$dldir&"\"&$filename,1,1) if @error then _GUICtrlStatusBarSetText($StatusBar1,"Failed to Write file.. Directory Error..",0) While @InetGetActive $p = (100 * @InetGetBytesRead) / $size GUICtrlSetData($Label6,$filename&" "&Round(@InetGetBytesRead/1024) & " kb" & " / " & Round($size/1024) &" kb") GUICtrlSetData($Label7,"Downloading : "&Round($p*1)&"%") GUICtrlSetData($Progress1,$p) Sleep(500) Wend _GUICtrlStatusBarSetText($StatusBar1,"Download Completed of : "&$filename,0) GUICtrlSetData($Label6,$filename&" Completed..") GUICtrlSetData($Label7,"Completed.. 100%") Sleep(500) EndIf Next MsgBox(262208,"313 Toolz - Warcraft III 4eva","All "&Guictrlread($combo1)&" Successfully Downloaded to "& Guictrlread($input1)&"..") EndIf WEnd Func _trayexit() InetGet("abort") $started = 0 Exit EndFunc Func _trayshow() if TrayItemGetText($trayhide) = "Show Main Window" Then GUISetState(@SW_SHOW,$Form1) GUISetState(@SW_RESTORE,$Form1) TrayItemSetText($trayhide,"Hide Main Window") Else GUISetState(@SW_MINIMIZE,$Form1) Sleep(250) GUISetState(@SW_HIDE,$Form1) TrayItemSetText($trayhide,"Show Main Window") EndIf EndFunc Func AButton1Click() $fold = FileSelectFolder("Select folder to save map files :",@ComputerName,1) if not @error then GUICtrlSetData($Input1,$fold) EndFunc Func AButton2Click() $started = 1 GUICtrlSetState($Group1,$gui_disable) GUICtrlSetState($combo1,$gui_disable) GUICtrlSetState($input1,$gui_disable) GUICtrlSetState($Button1,$gui_disable) GUICtrlSetState($Checkbox1,$gui_disable) GUICtrlSetState($Checkbox2,$gui_disable) GUICtrlSetState($Checkbox3,$gui_disable) GUICtrlSetState($Checkbox5,$gui_disable) GUICtrlSetState($Button2,$gui_disable) if GUICtrlRead($Checkbox5) = $GUI_CHECKED Then GUISetState(@SW_MINIMIZE,$Form1) Sleep(250) GUISetState(@SW_HIDE,$Form1) TrayItemSetText($trayhide,"Show Main Window") EndIf GUICtrlSetState($Group2,$gui_enable) GUICtrlSetState($Button3,$gui_enable) EndFunc Func AButton3Click() InetGet("abort") $started = 0 Exit EndFunc Func AButton4Click() GUISetState(@SW_MINIMIZE,$Form1) Sleep(250) GUISetState(@SW_HIDE,$Form1) TrayItemSetText($trayhide,"Show Main Window") EndFunc Func AForm1Close() InetGet("abort") $started = 0 Exit EndFunc Edited November 2, 2007 by mistakilla ~ Every Living Thing is a Code Snippet of World Application ~ Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 2, 2007 Moderators Share Posted November 2, 2007 You're using the regexp way. Which means you have to escape characters... This: /maps/data/ Should be \/maps\/data\/ And you should always check to make sure it's an array first with IsArray($src) ... if it's not, do something different. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
aNewLyfe Posted November 2, 2007 Author Share Posted November 2, 2007 You're using the regexp way. Which means you have to escape characters... This: /maps/data/ Should be \/maps\/data\/ And you should always check to make sure it's an array first with IsArray($src) ... if it's not, do something different. tnx for reply smoken but i still cant get it to work heres a test script i tried, this works, #include <inet.au3> #include <string.au3> #include <array.au3> $mainlink = "http://www.warcraft.org/maps/details/s" $i = "307" $imgsrc = "single.0/" $source = _INetGetSource($mainlink&$i) $str = _StringBetween($source,'/maps/data/'&$imgsrc,'" width=256 height=256>') $mainimglink = "http://www.warcraft.org/maps/data/"&$imgsrc&$str[0] $imgname = "test.jpg" InetGet($mainimglink,@ScriptDir&"\"&$imgname,1,1) but when i insert this to main script, same thing happens can u explain a little more, im not so professional on autoit ~ Every Living Thing is a Code Snippet of World Application ~ 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