lagoon Posted May 8, 2013 Posted May 8, 2013 First of all I want to say that I don't understand autoit at all! In that sense, I couldn't even be regarded as a beginner. So I hope you can make things in this topic understandable even for someone like me. Thank you So the thing is I looked around google for a simple little script to mass download galleries of images and what I found was InetGet. Even I could understand that simple command.Now I've got this:InetGet("http://xyz.com/xyz.php?id=1&imgname=001.jpg","C:\001.jpeg") InetGet("http://xyz.com/xyz.php?id=1&imgname=002.jpg","C:\002.jpeg") InetGet("http://xyz.com/xyz.php?id=1&imgname=003.jpg","C:\003.jpeg")And that goes on for another ~150 lines. It all works fine however there's one annoying thing:When I want to download another "gallery" of images I'd have to change the "id=1" to, let's say "id=2" or "id=3" ...Sounds simple but it's really a pain in the ass to do it for almost 200 lines ^^So.. I think you understand with that. I'd thought of some way to automatically or easily replace the "1" with another number. But of course, if you know of some completely different way to mass download images like this that I could use, feel free to tell me about it!.. I really wrote quite a lot about such a "simple" problem, didn't I? I really really hope someone can help me on this.Thank you for reading!
FireFox Posted May 8, 2013 Posted May 8, 2013 (edited) Hi, Welcome to the autoit forum ;this script will download the 100 first images of the 5 first galleries ;e.g: gallery 1: img: 1, 2, 3... 100 ;gallery 2: img: 1... 100 ;... ;gallery 5: ... 100 Local $hDl = 0, $sImgName = "" For $iGallery = 1 To 5 ;will loop from 1 to 5, incrementing the variable iGallery For $iImg = 1 To 100 ;will loop from 1 to 100, incrementing the variable iImg $sImgName = StringFormat("%.3d", $iImg) ;will fill the number to 3 digits (e.g: 5 will be 005) $hDl = InetGet("http://xyz.com/xyz.php?id=" & $iGallery & "&imgname=" & $sImgName & ".jpg","C:\" & $sImgName & ".jpeg") InetClose($hDl) ;releases the resources Next Next I hope this is clear for you Edit: There is a VERY useful helpfile for each function, press F1 in SciTE and voila ! Br, FireFox. Edited May 8, 2013 by FireFox
lagoon Posted May 8, 2013 Author Posted May 8, 2013 What a fast reply!I just tested it out and it works perfectly! This is exactly what I have been looking forA thousand thanks to you! Edit: There is a VERY useful helpfile for each function, press F1 in SciTE and voila !Br, FireFox.Thanks, I didn't see that before. I will use it when I ever need any help again!
guinness Posted May 8, 2013 Posted May 8, 2013 First of all I want to say that I don't understand autoit at all! In that sense, I couldn't even be regarded as a beginner. So I hope you can make things in this topic understandable even for someone like me. Thank you My advice, if you're new to something don't try to run before you can walk" FireFox was kind enough to help you, but accepting free code isn't going to improve your learning curve, that comes from you talking the help file and their code and breaking down what they and why they did it. This is how I learnt and many before me. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
lagoon Posted May 18, 2013 Author Posted May 18, 2013 (edited) Oookay, it seems like I'm stuck again I tried to change the code a little bit: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form2 = GUICreate("Downloader", 405, 294, 264, 168) $Input1 = GUICtrlCreateInput("", 32, 48, 153, 21) $Downloadstart = GUICtrlCreateButton("Download", 232, 48, 145, 33, $WS_GROUP) $hDl = 0 GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Downloadstart $read = GUICtrlRead($Input1) $hDl = InetGet("address" & $Input1,"directory" & ".png") InetClose($hdl) For $iImg = 2 To 240 ;will loop from 1 to 100, incrementing the variable iImg $sImgName = StringFormat("%.3d", $iImg) ;will fill the number to 3 digits (e.g: 5 will be 005) $hDl = InetGet("address" & $Input1 & "&imgname=" & $sImgName & ".jpg","directory" & StringFormat("%.3d", $sImgName) & ".jpg") InetClose($hDl) ;releases the resources Next EndSwitch WEnd I guess you people can see what I tried to do just by this ^^ I wanted it to open a window where I can input the ID and then click the download button to download the images It doesn't seem to be working though. I simply get "empty" images. Like, images with 0 bytes that don't show anything. I'd also like to try adding 2 other things later on (the program automatically recognizing when the gallery ends // when restarting the program not having to reload images that have already been downloaded) but fixing this problem comes first. I tried using the help file.. to no avail Edited May 18, 2013 by lagoon
Developers Jos Posted May 18, 2013 Developers Posted May 18, 2013 For starters: $input1 contains the controlhandle, not the content of the control. You need to use GUICtrlRead() for that. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
lagoon Posted May 18, 2013 Author Posted May 18, 2013 Such a simple thing.. Well it works now One thing though: It seems like I can't stop the program normally by pressing the X, how do I fix that? Also, it'd be nice if someone could "push me in the right direction" for the earlier mentioned 2 improvements.
Developers Jos Posted May 18, 2013 Developers Posted May 18, 2013 Use the eventmode for the controls as you now are in a loop not reading the messages from the GUI. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
lagoon Posted May 18, 2013 Author Posted May 18, 2013 Tried looking for what that eventmode is in the first place and implementing it with the help of this and other sites but no idea.. Doesn't work for me ;(
MouseSpotter Posted May 18, 2013 Posted May 18, 2013 Google: Autoit Control Events http://www.autoitscript.com/autoit3/docs/guiref/GUIRef_OnEventMode.htm
lagoon Posted May 19, 2013 Author Posted May 19, 2013 Yeah, as I said in my previous comment I already know of that site Well, I tried it again anyway. This is what I got: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode $mainwindow = GUICreate("Downloader", 405, 294, 264, 168) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") $Downloadstart = GUICtrlCreateButton("Download", 232, 48, 145, 33, $WS_GROUP) GUICtrlSetOnEvent($Downloadstart, "Downloadstart") $Input1 = GUICtrlCreateInput("", 32, 48, 153, 21) $hDl = 0 GUISetState(@SW_SHOW) While 1 Sleep(1000) ; Idle around WEnd Func Downloadstart() $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Downloadstart $read = GUICtrlRead($Input1) $hDl = InetGet("address" & $read,"directory" & ".png") InetClose($hdl) For $iImg = 2 To 240 ;will loop from 1 to 100, incrementing the variable iImg $sImgName = StringFormat("%.3d", $iImg) ;will fill the number to 3 digits (e.g: 5 will be 005) $hDl = InetGet("address" & $read & "&imgname=" & $sImgName & ".jpg","directory" & StringFormat("%.3d", $sImgName) & ".jpg") InetClose($hDl) ;releases the resources Next EndSwitch EndFunc Func CLOSEClicked() ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE, ;and @GUI_WINHANDLE would equal $mainwindow MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...") Exit EndFunc Problem: The download won't start
lagoon Posted May 19, 2013 Author Posted May 19, 2013 Okay I got it to work (more or less, it downloads the images now ) #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode $mainwindow = GUICreate("Downloader", 405, 294, 264, 168) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") $Downloadstart = GUICtrlCreateButton("Download", 232, 48, 145, 33, $WS_GROUP) GUICtrlSetOnEvent($Downloadstart, "Downloadstart") $Input1 = GUICtrlCreateInput("", 32, 48, 153, 21) $hDl = 0 GUISetState(@SW_SHOW) While 1 Sleep(1000) ; Idle around WEnd Func Downloadstart() $read = GUICtrlRead($Input1) $hDl = InetGet("address" & $read,"directory" & ".png") InetClose($hdl) For $iImg = 2 To 240 ;will loop from 1 to 100, incrementing the variable iImg $sImgName = StringFormat("%.3d", $iImg) ;will fill the number to 3 digits (e.g: 5 will be 005) $hDl = InetGet("address" & $read & "&imgname=" & $sImgName & ".jpg","directory" & StringFormat("%.3d", $sImgName) & ".jpg") InetClose($hDl) ;releases the resources Next EndFunc Func CLOSEClicked() ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE, ;and @GUI_WINHANDLE would equal $mainwindow MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...") Exit EndFunc Yet, closing the program by clicking on the X still won't work Also, the program is very laggy and will not react after downloading ~30 or so images :/
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