Sign in to follow this  
Followers 0
Maffe811

StanceWorks Image Downloader

9 posts in this topic

This is a basic version.

Things i'll fix:

- The blacklist is hardcoded and not in an external file.

- I got variables that contais how far the download has come (X of Y), make a Gui-something-bar for this. (Someone has a udf, don't remember what its called, i'll find it)

- Try to make the name extraction (_Stringifier) more... efficient? idk, i can almost gurantee there is an easier way to do it. :P

#include
#include
#include
#include
#include

Global $HorizontalPlacement = 1
Global $HorizontalSpacing = 10
Global $ArrayImages[1]
Global $ArrayDownload[1]
Global $DropdownBlacklistText = "Select blacklist"
Global $SaveFolderLocation = "XXX" ;@DesktopDir & "\Temp\"
;~ http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/

$GUI = GUICreate("StanceWorks Image Batch Downloader", 230, 120)
;~ $InputLink = GUICtrlCreateInput("Link", 10, ($HorizontalPlacement * $HorizontalSpacing), 210)
$InputLink = GUICtrlCreateInput("http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/", 10, ($HorizontalPlacement * $HorizontalSpacing), 210)
$HorizontalPlacement += 3
$DropdownBlacklist = GUICtrlCreateCombo($DropdownBlacklistText, 10, ($HorizontalPlacement * $HorizontalSpacing), 210)
$HorizontalPlacement += 3
$ButtonBrowse = GUICtrlCreateButton("Browse", 10, ($HorizontalPlacement * $HorizontalSpacing), 80)
$ButtonDownload = GUICtrlCreateButton("Download", 220 - 10 - 70, ($HorizontalPlacement * $HorizontalSpacing), 80)

_WriteSWBlacklist()
_BlacklistDropdownUpdater()

GUISetState(@SW_SHOW)



Func _WriteSWBlacklist()
Global $SWBlacklist[1]
Local $ArrayCounter = 0

_ArrayAdd($SWBlacklist, "StanceWorks.com")
_ArrayAdd($SWBlacklist, "http://cdn.stanceworks.com/wp-content/themes/saviour/images/Vendors/stanceworks-avila-show2.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/AvilaBanner.jpg")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/IphoneBanner.jpg")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://cdn.stanceworks.com/wp-content/uploads/2012/03/Resizebanner1.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/previous-article.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/next-article.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://cdn.stanceworks.com/wp-content/uploads/trackableshare//facebook.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://cdn.stanceworks.com/wp-content/uploads/trackableshare//twitter.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://cdn.stanceworks.com/wp-content/uploads/trackableshare//tumblr.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://cdn.stanceworks.com/wp-content/uploads/trackableshare//stumbleupon.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://cdn.stanceworks.com/wp-content/uploads/trackableshare//reddit.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://cdn.stanceworks.com/wp-content/uploads/trackableshare//email.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-facebook.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-vimeo.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png")
$ArrayCounter += 1
_ArrayInsert($SWBlacklist, 0, $ArrayCounter)
_ArrayDelete($SWBlacklist, 1)

;~ _ArrayDisplay($SWBlacklist)
;~ MsgBox("","", $ArrayCounter)

EndFunc ;==>_WriteSWBlacklist


Func _BlacklistDropdownUpdater()
_GUICtrlComboBox_AddString($DropdownBlacklist, $SWBlacklist[1])
EndFunc ;==>_BlacklistDropdownUpdater

Func _BlacklistUpdater()
Global $ArrayBlacklist;[1]
;~ MsgBox("", "", GUICtrlRead($DropdownBlacklist))
Select
Case GUICtrlRead($DropdownBlacklist) = "StanceWorks.com"
$ArrayBlacklist = $SWBlacklist
EndSelect
;~ _ArrayDisplay($ArrayBlacklist)
EndFunc ;==>_BlacklistUpdater


Func _ImageFilter($SiteLink)

_BlacklistUpdater()

Local $oIE = _IECreate($SiteLink)
_IELoadWait($oIE)
Local $sTags = _IETagNameGetCollection($oIE, "img")
Local $ImageCount = @extended
Local $iCounter1
Local $iCounter2
Local $ArrayDownloadCounter = 0


;~ MsgBox("", "", $ImageCount)
$ArrayImages[0] = $ImageCount
For $tag In $sTags
;~ MsgBox("", "", $tag.src)
_ArrayAdd($ArrayImages, $tag.src)
Next
;~ _ArrayDisplay($ArrayImages)
;~ _ArrayDisplay($ArrayBlacklist)
;~ _ArrayDisplay($ArrayDownload)

For $iCounter1 = 1 To $ArrayImages[0] Step 1
;~ ConsoleWrite("-Image to check " & $ArrayImages[$iCounter1] & @CRLF)
For $iCounter2 = 2 To $ArrayBlacklist[0] + 1 Step 1
;~ ConsoleWrite("!Checking against " & $ArrayBlacklist[$iCounter2] & @CRLF)
If $ArrayImages[$iCounter1] = $ArrayBlacklist[$iCounter2] Then
ExitLoop
ElseIf $iCounter2 = ($ArrayBlacklist[0] + 1) Then
;~ ConsoleWrite("+Match found, adding to array " & $ArrayImages[$iCounter1] & @CRLF)
_ArrayAdd($ArrayDownload, $ArrayImages[$iCounter1])
$ArrayDownloadCounter += 1
EndIf

Next
Next

ProcessClose("iexplore.exe")

_ArrayInsert($ArrayDownload, 0, $ArrayDownloadCounter)
_ArrayDelete($ArrayDownload, 1)
;~ _ArrayDisplay($ArrayDownload)
_ImageDownloader()

EndFunc ;==>_ImageFilter

Func _ImageDownloader()
Local $DLCounter
Local $iDeleteCounter

;~ MsgBox("", "", $SaveFolderLocation)
If Not FileExists($SaveFolderLocation) Then
DirCreate($SaveFolderLocation)
If @error = 0 Then
ConsoleWrite("!Error creating directory" & @CRLF)
Else
ConsoleWrite("+No error creating directory" & @CRLF)
EndIf
EndIf

For $DLCounter = 1 To $ArrayDownload[0] Step 1
$DownloadName = _Stringifier($ArrayDownload[$DLCounter])
InetGet($ArrayDownload[$DLCounter], $SaveFolderLocation & $DownloadName)
ConsoleWrite("!Downloading file " & $DLCounter & " of " & $ArrayDownload[0] & @CRLF)
ConsoleWrite("-" & $ArrayDownload[$DLCounter] & @CRLF)
ConsoleWrite("+" & $SaveFolderLocation & $DownloadName & @CRLF)
Next
;~ _ArrayDisplay($ArrayDownload)
For $iDeleteCounter = $ArrayDownload[0] to 0 step -1
_ArrayDelete($ArrayDownload,$iDeleteCounter)
Next
Global $ArrayDownload[1]
;~ _ArrayDisplay($ArrayDownload)
MsgBox("", "", "Download completed!")

GUICtrlSetData($InputLink,"Link")
$SaveFolderLocation = "XXX"
EndFunc ;==>_ImageDownloader


Func _Stringifier($Link)
Local $Counter
Local $Feedback
Local $ArraySize
Local $Array[2]
Local $CutValue
Local $String

;~ $Link = "http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png"
$Pattern = "(/*.)?"


$Array = StringRegExp($Link,$Pattern,3)
;~ _ArrayDisplay($Array)

$ArraySize = (UBound($Array)-1)

;~ MsgBox("","",$ArraySize )
For $Counter = $ArraySize to 0 step -1
$Feedback = StringInStr($Array[$Counter],"/")
;~ ConsoleWrite("!" & $Counter & "-" & $Array[$Counter] & ": " & $Feedback & @CRLF)
If $Feedback = 1 then ExitLoop
Next

;~ MsgBox("","",$Feedback)
;~ MsgBox("","",$Counter)

$CutValue = $ArraySize - $Counter

;~ MsgBox("","",$CutValue)
$String = StringRight($Link,$CutValue)
;~ MsgBox("","",$String)
Return $String
EndFunc

;~ http://www.stanceworks.com/2012/06/vegas-lights-the-rotiform-audi-allroad-on-sjcs/

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $ButtonBrowse
If GUICtrlRead($DropdownBlacklist) = $DropdownBlacklistText Then
MsgBox("", "", "Please select a blacklist!")
Else
$SaveFolderLocation = (FileSaveDialog("Choose directory", @UserProfileDir & "\pictures", "Folder(*.*)", -1, "Images") & "\")
MsgBox("", "", $SaveFolderLocation)

_BlacklistUpdater()
EndIf

Case $ButtonDownload
If GUICtrlRead($DropdownBlacklist) = $DropdownBlacklistText Then
MsgBox("", "", "Please select a blacklist!")
ElseIf $SaveFolderLocation = "XXX" Then
MsgBox("", "", "Please select a save folder" & @CRLF & "(Click browse)")
Else
_ImageFilter(GUICtrlRead($InputLink))
EndIf
EndSwitch
WEnd

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites



Did anyone test the last version? :P

I guess not, since no one mentioned that the includes we're gone.

Anyways i remembered them this time.

Todolist:

- The blacklist is hardcoded and not in an external file.

- A way to create the blacklist if it doesn't exist.

- Change from a combobox to a dropdown

- I got variables that contais how far the download has come (X of Y), make a Gui-something-bar for this. (Someone has a udf, don't remember what its called, i'll find it)

- Remove the msgbox'es that apear after download complete, when a blacklist isn't selected and when a file directory isn't chosen.

- Try to make the name extraction (_Stringifier) more... efficient? idk, i can almost gurantee there is an easier way to do it. :P

- Try to make the timer thing for the label and the progressbar better in someway.

- Create a label with "Blacklist" and then remove the "select blacklist" from the combobox

If anyone can point me to an UDF or if i missed something in the helpfile about standard dropdownboxes (not comboboxes) then i would apreciate it.

The other option is to do some dark magics and make the combobox look and act like a drop down.

Ask if you wonder about anything and i'll try to answear as best as i can.

#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <IE.au3>
#include <Array.au3>
#include <GuiComboBox.au3>
#include <File.au3>

Global $HorizontalPlacement = 1
Global $HorizontalSpacing = 10
Global $ArrayImages[1]
Global $ArrayDownload[1]
Global $DropdownBlacklistText = "Select blacklist"
Global $SaveFolderLocation = "XXX" ;@DesktopDir & "\Temp\"
Global $ClearTimer
Global $ProgressEmptied = 1

;~ http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/

$GUI = GUICreate("StanceWorks Image Batch Downloader", 230, 160)
;~ $InputLink = GUICtrlCreateInput("Link", 10, ($HorizontalPlacement * $HorizontalSpacing), 210)
$InputLink = GUICtrlCreateInput("http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/", 10, ($HorizontalPlacement * $HorizontalSpacing), 210)
$HorizontalPlacement += 3
$DropdownBlacklist = GUICtrlCreateCombo($DropdownBlacklistText, 10, ($HorizontalPlacement * $HorizontalSpacing), 210)
$HorizontalPlacement += 3
$ButtonBrowse = GUICtrlCreateButton("Browse", 10, ($HorizontalPlacement * $HorizontalSpacing), 80)
$ButtonDownload = GUICtrlCreateButton("Download", 220 - 10 - 70, ($HorizontalPlacement * $HorizontalSpacing), 80)
$HorizontalPlacement += 3
$ProgressBar = GUICtrlCreateProgress(10, ($HorizontalPlacement * $HorizontalSpacing), 210, -1,$PBS_SMOOTH)
$HorizontalPlacement += 3
$ProgressName = GUICtrlCreateLabel("Ready",10,($HorizontalPlacement * $HorizontalSpacing), 210, 20,$SS_SUNKEN)

_WriteSWBlacklist()
_BlacklistDropdownUpdater()

GUISetState(@SW_SHOW)

Func _WriteSWBlacklist()
Global $SWBlacklist[1]
Local $ArrayCounter = 0

_ArrayAdd($SWBlacklist, "StanceWorks.com")
_ArrayAdd($SWBlacklist, "http://cdn.stanceworks.com/wp-content/themes/saviour/images/Vendors/stanceworks-avila-show2.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/AvilaBanner.jpg")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/IphoneBanner.jpg")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://cdn.stanceworks.com/wp-content/uploads/2012/03/Resizebanner1.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/previous-article.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/next-article.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://cdn.stanceworks.com/wp-content/uploads/trackableshare//facebook.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://cdn.stanceworks.com/wp-content/uploads/trackableshare//twitter.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://cdn.stanceworks.com/wp-content/uploads/trackableshare//tumblr.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://cdn.stanceworks.com/wp-content/uploads/trackableshare//stumbleupon.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://cdn.stanceworks.com/wp-content/uploads/trackableshare//reddit.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://cdn.stanceworks.com/wp-content/uploads/trackableshare//email.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-facebook.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-vimeo.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png")
$ArrayCounter += 1
_ArrayInsert($SWBlacklist, 0, $ArrayCounter)
_ArrayDelete($SWBlacklist, 1)

;~ _ArrayDisplay($SWBlacklist)
;~ MsgBox("","", $ArrayCounter)

EndFunc ;==>_WriteSWBlacklist


Func _BlacklistDropdownUpdater()
_GUICtrlComboBox_AddString($DropdownBlacklist, $SWBlacklist[1])
EndFunc ;==>_BlacklistDropdownUpdater

Func _BlacklistUpdater()
Global $ArrayBlacklist;[1]
;~ MsgBox("", "", GUICtrlRead($DropdownBlacklist))
Select
Case GUICtrlRead($DropdownBlacklist) = "StanceWorks.com"
$ArrayBlacklist = $SWBlacklist
EndSelect
;~ _ArrayDisplay($ArrayBlacklist)
EndFunc ;==>_BlacklistUpdater


Func _ImageFilter($SiteLink)

_BlacklistUpdater()

Local $oIE = _IECreate($SiteLink)
_IELoadWait($oIE)
Local $sTags = _IETagNameGetCollection($oIE, "img")
Local $ImageCount = @extended
Local $iCounter1
Local $iCounter2
Local $ArrayDownloadCounter = 0


;~ MsgBox("", "", $ImageCount)
$ArrayImages[0] = $ImageCount
For $tag In $sTags
;~ MsgBox("", "", $tag.src)
_ArrayAdd($ArrayImages, $tag.src)
Next
;~ _ArrayDisplay($ArrayImages)
;~ _ArrayDisplay($ArrayBlacklist)
;~ _ArrayDisplay($ArrayDownload)

For $iCounter1 = 1 To $ArrayImages[0] Step 1
;~ ConsoleWrite("-Image to check " & $ArrayImages[$iCounter1] & @CRLF)
For $iCounter2 = 2 To $ArrayBlacklist[0] + 1 Step 1
;~ ConsoleWrite("!Checking against " & $ArrayBlacklist[$iCounter2] & @CRLF)
If $ArrayImages[$iCounter1] = $ArrayBlacklist[$iCounter2] Then
ExitLoop
ElseIf $iCounter2 = ($ArrayBlacklist[0] + 1) Then
;~ ConsoleWrite("+Match found, adding to array " & $ArrayImages[$iCounter1] & @CRLF)
_ArrayAdd($ArrayDownload, $ArrayImages[$iCounter1])
$ArrayDownloadCounter += 1
EndIf

Next
Next

ProcessClose("iexplore.exe")

_ArrayInsert($ArrayDownload, 0, $ArrayDownloadCounter)
_ArrayDelete($ArrayDownload, 1)
;~ _ArrayDisplay($ArrayDownload)
_ImageDownloader()

EndFunc ;==>_ImageFilter

Func _ImageDownloader()
Local $DLCounter
Local $iDeleteCounter

;~ MsgBox("", "", $SaveFolderLocation)
If Not FileExists($SaveFolderLocation) Then
DirCreate($SaveFolderLocation)
If @error = 0 Then
ConsoleWrite("!Error creating directory" & @CRLF)
Else
ConsoleWrite("+No error creating directory" & @CRLF)
EndIf
EndIf

For $DLCounter = 1 To $ArrayDownload[0] Step 1
$DownloadName = _Stringifier($ArrayDownload[$DLCounter])
InetGet($ArrayDownload[$DLCounter], $SaveFolderLocation & $DownloadName)
GUICtrlSetData($ProgressBar, ($DLCounter/$ArrayDownload[0]*100))
GUICtrlSetData($ProgressName,$DownloadName)
ConsoleWrite("!Downloading file " & $DLCounter & " of " & $ArrayDownload[0] & @CRLF)
ConsoleWrite("-" & $ArrayDownload[$DLCounter] & @CRLF)
ConsoleWrite("+" & $SaveFolderLocation & $DownloadName & @CRLF)
Next
;~ _ArrayDisplay($ArrayDownload)
For $iDeleteCounter = $ArrayDownload[0] To 0 Step -1
_ArrayDelete($ArrayDownload, $iDeleteCounter)
Next
Global $ArrayDownload[1]
;~ _ArrayDisplay($ArrayDownload)
;~ MsgBox("", "", "Download completed!")
;~ GUICtrlSetData($ProgressBar, 0)
GUICtrlSetData($ProgressName,"Download complete!")
GUICtrlSetData($InputLink, "Link")
$SaveFolderLocation = "XXX"

$ProgressEmptied = 0
$ClearTimer = TimerInit()

EndFunc ;==>_ImageDownloader


Func _Stringifier($Link)
Local $Counter
Local $Feedback
Local $ArraySize
Local $Array[2]
Local $CutValue
Local $String

;~ $Link = "http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png"
$Pattern = "(/*.)?"


$Array = StringRegExp($Link, $Pattern, 3)
;~ _ArrayDisplay($Array)

$ArraySize = (UBound($Array) - 1)

;~ MsgBox("","",$ArraySize )
For $Counter = $ArraySize To 0 Step -1
$Feedback = StringInStr($Array[$Counter], "/")
;~ ConsoleWrite("!" & $Counter & "-" & $Array[$Counter] & ": " & $Feedback & @CRLF)
If $Feedback = 1 Then ExitLoop
Next

;~ MsgBox("","",$Feedback)
;~ MsgBox("","",$Counter)

$CutValue = $ArraySize - $Counter

;~ MsgBox("","",$CutValue)
$String = StringRight($Link, $CutValue)
;~ MsgBox("","",$String)
Return $String
EndFunc ;==>_Stringifier

;~ http://www.stanceworks.com/2012/06/vegas-lights-the-rotiform-audi-allroad-on-sjcs/

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $ButtonBrowse
;~ If GUICtrlRead($DropdownBlacklist) = $DropdownBlacklistText Then
;~ MsgBox("", "", "Please select a blacklist!")
;~ Else
$SaveFolderLocation = (FileSaveDialog("Choose directory", @UserProfileDir & "\pictures", "Folder(*.*)", -1, "Images") & "\")
;~ MsgBox("", "", $SaveFolderLocation)

_BlacklistUpdater()
;~ EndIf

Case $ButtonDownload
If GUICtrlRead($DropdownBlacklist) = $DropdownBlacklistText Then
;~ MsgBox("", "", "Please select a blacklist!")
GUICtrlSetData($ProgressName,"Please select a blacklist!")
$ClearTimer = TimerInit()
$ProgressEmptied = 0
ElseIf $SaveFolderLocation = "XXX" Then
;~ MsgBox("", "", "Please select a save folder" & @CRLF & "(Click browse)")
GUICtrlSetData($ProgressName,"Please select a save folder(Click browse)")
$ClearTimer = TimerInit()
$ProgressEmptied = 0
Else
_ImageFilter(GUICtrlRead($InputLink))
EndIf
EndSwitch

If (TimerDiff($ClearTimer)/1000) > "3" and $ProgressEmptied = 0 Then
GUICtrlSetData($ProgressBar, 0)
GUICtrlSetData($ProgressName,"Ready")
$ProgressEmptied = 1
EndIf
;~ $TimerDifference = (TimerDiff($ClearTimer)/1000)
;~ ConsoleWrite($TimerDifference & @Crlf)
WEnd

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites

Todolist:

- The blacklist is hardcoded and not in an external file.

- A way to create the blacklist if it doesn't exist.

- Change from a combobox to a dropdown (Disallow text input)

- I got variables that contais how far the download has come (X of Y), make a Gui-something-bar for this. (Someone has a udf, don't remember what its called, i'll find it)

- Remove the msgbox'es that apear after download complete, when a blacklist isn't selected and when a file directory isn't chosen.

- Try to make the name extraction (_Stringifier) more... efficient? idk, i can almost gurantee there is an easier way to do it. :P

- Try to make the timer thing for the label and the progressbar better in someway.

- Create a label with "Blacklist" and then remove the "select blacklist" from the combobox, and also make Stanceworks the standard choice.

- Fix some bug where it report folder creation as unsuccessful when it is successful.

- Add points where the download stops if something breaks.

#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <IE.au3>
#include <Array.au3>
#include <GuiComboBox.au3>
#include <File.au3>

Global $HorizontalPlacement = 1
Global $HorizontalSpacing = 10
Global $ArrayImages[1]
Global $ArrayDownload[1]
Global $DropdownBlacklistText = ""
Global $SaveFolderLocation = "XXX" ;@DesktopDir & "\Temp\"
Global $ClearTimer
Global $ProgressEmptied = 1

;~ http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/

$GUI = GUICreate("StanceWorks Image Batch Downloader", 230, 160)
;~ $InputLink = GUICtrlCreateInput("Link", 10, ($HorizontalPlacement * $HorizontalSpacing), 210)
$InputLink = GUICtrlCreateInput("http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/", 10, ($HorizontalPlacement * $HorizontalSpacing), 210)
$HorizontalPlacement += 2.5
GUICtrlCreateLabel("Select blacklist:", 10, ($HorizontalPlacement * $HorizontalSpacing), 210)
$HorizontalPlacement += 1.5
$DropdownBlacklist = GUICtrlCreateCombo($DropdownBlacklistText, 10, ($HorizontalPlacement * $HorizontalSpacing), 210)
$HorizontalPlacement += 3
$ButtonBrowse = GUICtrlCreateButton("Browse", 10, ($HorizontalPlacement * $HorizontalSpacing), 80)
$ButtonDownload = GUICtrlCreateButton("Download", 220 - 10 - 70, ($HorizontalPlacement * $HorizontalSpacing), 80)
$HorizontalPlacement += 3
$ProgressBar = GUICtrlCreateProgress(10, ($HorizontalPlacement * $HorizontalSpacing), 210, -1, $PBS_SMOOTH)
$HorizontalPlacement += 3
$ProgressName = GUICtrlCreateLabel("Ready", 10, ($HorizontalPlacement * $HorizontalSpacing), 210, 20, $SS_SUNKEN)

_WriteSWBlacklist()
_BlacklistDropdownUpdater()

GUISetState(@SW_SHOW)

Func _WriteSWBlacklist()
Global $SWBlacklist[1]
Local $ArrayCounter = 0

_ArrayAdd($SWBlacklist, "StanceWorks.com")
_ArrayAdd($SWBlacklist, "http://cdn.stanceworks.com/wp-content/themes/saviour/images/Vendors/stanceworks-avila-show2.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/AvilaBanner.jpg")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/IphoneBanner.jpg")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://cdn.stanceworks.com/wp-content/uploads/2012/03/Resizebanner1.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/previous-article.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/next-article.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://cdn.stanceworks.com/wp-content/uploads/trackableshare//facebook.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://cdn.stanceworks.com/wp-content/uploads/trackableshare//twitter.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://cdn.stanceworks.com/wp-content/uploads/trackableshare//tumblr.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://cdn.stanceworks.com/wp-content/uploads/trackableshare//stumbleupon.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://cdn.stanceworks.com/wp-content/uploads/trackableshare//reddit.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://cdn.stanceworks.com/wp-content/uploads/trackableshare//email.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-facebook.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-vimeo.png")
$ArrayCounter += 1
_ArrayAdd($SWBlacklist, "http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png")
$ArrayCounter += 1
_ArrayInsert($SWBlacklist, 0, $ArrayCounter)
_ArrayDelete($SWBlacklist, 1)

;~ _ArrayDisplay($SWBlacklist)
;~ MsgBox("","", $ArrayCounter)

EndFunc ;==>_WriteSWBlacklist


Func _BlacklistDropdownUpdater()
_GUICtrlComboBox_AddString($DropdownBlacklist, $SWBlacklist[1])
_GUICtrlComboBox_SetCurSel($DropdownBlacklist, 0)
EndFunc ;==>_BlacklistDropdownUpdater

Func _BlacklistUpdater()
Global $ArrayBlacklist;[1]
;~ MsgBox("", "", GUICtrlRead($DropdownBlacklist))
Select
Case GUICtrlRead($DropdownBlacklist) = "StanceWorks.com"
$ArrayBlacklist = $SWBlacklist
EndSelect
;~ _ArrayDisplay($ArrayBlacklist)
EndFunc ;==>_BlacklistUpdater


Func _ImageFilter($SiteLink)

_BlacklistUpdater()

_ProgressUpdater("Gathering info")

Local $oIE = _IECreate($SiteLink)
_IELoadWait($oIE)
Local $sTags = _IETagNameGetCollection($oIE, "img")
Local $ImageCount = @extended
Local $iCounter1
Local $iCounter2
Local $ArrayDownloadCounter = 0


;~ MsgBox("", "", $ImageCount)
$ArrayImages[0] = $ImageCount
For $tag In $sTags
;~ MsgBox("", "", $tag.src)
_ArrayAdd($ArrayImages, $tag.src)
Next
;~ _ArrayDisplay($ArrayImages)
;~ _ArrayDisplay($ArrayBlacklist)
;~ _ArrayDisplay($ArrayDownload)

_ProgressUpdater("Blacklist check")

For $iCounter1 = 1 To $ArrayImages[0] Step 1
;~ ConsoleWrite("-Image to check " & $ArrayImages[$iCounter1] & @CRLF)
For $iCounter2 = 2 To $ArrayBlacklist[0] + 1 Step 1
;~ ConsoleWrite("!Checking against " & $ArrayBlacklist[$iCounter2] & @CRLF)
If $ArrayImages[$iCounter1] = $ArrayBlacklist[$iCounter2] Then
ExitLoop
ElseIf $iCounter2 = ($ArrayBlacklist[0] + 1) Then
;~ ConsoleWrite("+Match found, adding to array " & $ArrayImages[$iCounter1] & @CRLF)
_ArrayAdd($ArrayDownload, $ArrayImages[$iCounter1])
$ArrayDownloadCounter += 1
EndIf

Next
Next

ProcessClose("iexplore.exe")

_ArrayInsert($ArrayDownload, 0, $ArrayDownloadCounter)
_ArrayDelete($ArrayDownload, 1)
;~ _ArrayDisplay($ArrayDownload)
_ImageDownloader()

EndFunc ;==>_ImageFilter

Func _ImageDownloader()
Local $DLCounter
Local $iDeleteCounter

_ProgressUpdater("Downloading")

;~ MsgBox("", "", $SaveFolderLocation)
If Not FileExists($SaveFolderLocation) Then
DirCreate($SaveFolderLocation)
;~ If @error = 0 Then
;~ ConsoleWrite("!Error creating directory, -> " & @extended & @CRLF)
;~ Else
;~ ConsoleWrite("+No error creating directory" & @CRLF)
;~ EndIf
EndIf

If Not FileExists($SaveFolderLocation) Then
MsgBox("", "", "Error creating directory")
Exit
EndIf

For $DLCounter = 1 To $ArrayDownload[0] Step 1
$DownloadName = _Stringifier($ArrayDownload[$DLCounter])
InetGet($ArrayDownload[$DLCounter], $SaveFolderLocation & $DownloadName)

GUICtrlSetData($ProgressBar, ($DLCounter / $ArrayDownload[0] * 100))
GUICtrlSetData($ProgressName, $DownloadName)

ConsoleWrite("!Downloading file " & $DLCounter & " of " & $ArrayDownload[0] & @CRLF)
ConsoleWrite("-" & $ArrayDownload[$DLCounter] & @CRLF)
ConsoleWrite("+" & $SaveFolderLocation & $DownloadName & @CRLF)
Next
For $iDeleteCounter = $ArrayDownload[0] To 0 Step -1
_ArrayDelete($ArrayDownload, $iDeleteCounter)
Next
Global $ArrayDownload[1]

$SaveFolderLocation = "XXX"
_ProgressUpdater("Download complete!", "Link")


EndFunc ;==>_ImageDownloader

Func _ProgressUpdater($PUName, $PULink = "")
;~ GUICtrlSetData($ProgressBar, 0)
GUICtrlSetData($ProgressName, $PUName)
If Not $PULink = "" Then GUICtrlSetData($InputLink, $PULink)
;Timer stuff
$ProgressEmptied = 0
$ClearTimer = TimerInit()
EndFunc ;==>_ProgressUpdater

Func _Stringifier($Link)
Local $Pattern
Local $Array
Local $String

;~ $Link = "http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png"

;~ MsgBox("", "", $Link)
$Pattern = ".+/(.+\.png|.+\.jpg).*"
$String = StringRegExp($Link, $Pattern, 1)

;~ ConsoleWrite(">" & "String:" & $String[0] & @CRLF)

Return $String[0]
EndFunc ;==>_Stringifier

;~ http://www.stanceworks.com/2012/06/vegas-lights-the-rotiform-audi-allroad-on-sjcs/

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $ButtonBrowse
$SaveFolderLocation = (FileSaveDialog("Choose directory", @UserProfileDir & "\pictures", "Folder(*.*)", 16, "Images") & "\")
If @error = 1 Then $SaveFolderLocation = "XXX"
;~ MsgBox("", "", $SaveFolderLocation)

_BlacklistUpdater()

Case $ButtonDownload
If GUICtrlRead($DropdownBlacklist) = $DropdownBlacklistText Then
_ProgressUpdater("Please select a blacklist!")
ElseIf $SaveFolderLocation = "XXX" Then
_ProgressUpdater("Please select a save folder(Click browse)")
Else
_ImageFilter(GUICtrlRead($InputLink))
EndIf
EndSwitch

If (TimerDiff($ClearTimer) / 1000) > "3" And $ProgressEmptied = 0 Then
GUICtrlSetData($ProgressBar, 0)
GUICtrlSetData($ProgressName, "Ready")
$ProgressEmptied = 1
EndIf
;~ $TimerDifference = (TimerDiff($ClearTimer)/1000)
;~ ConsoleWrite($TimerDifference & @Crlf)
WEnd

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Batch downloader

This now takes a site you input.

Gather all images within <img> tags

Check them against a blacklist you selected from a menu.

And downloads the ones not found

The bl

Todolist:

- Get the blacklist from an external file, instead of hardcoded.

- A way to create the blacklist if it doesn't exist.

- Change from a combobox to a dropdown (Disallow text input)

- I got variables that contais how far the download has come (X of Y), make a Gui-something-bar for this. (Someone has a udf, don't remember what its called, i'll find it)

- Remove the msgbox'es that apear after download complete, when a blacklist isn't selected and when a file directory isn't chosen.

- Try to make the name extraction (_Stringifier) more... efficient? idk, i can almost gurantee there is an easier way to do it. :P

- Try to make the timer thing for the label and the progressbar better in someway.

- Create a label with "Blacklist" and then remove the "select blacklist" from the combobox, and also make Stanceworks the standard choice.

- Fix some bug where it reports folder creation as unsuccessful when it is successful.

- Add points where the download stops if something breaks.

- Add "open folder after download" checkmark and make it happen

- Remove the Internet Explorer popup

- Fix blacklist importation.

- Fix blacklist setup, change the first line from title to blacklisted image (also add this to the code)

#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <IE.au3>
#include <Array.au3>
#include <GuiComboBox.au3>
#include <File.au3>
Global $HorizontalPlacement = 1
Global $HorizontalSpacing = 10
Global $ArrayImages[1]
Global $ArrayDownload[1]
Global $DropdownBlacklistText = ""
;~ Global $SaveFolderLocation = "XXX"
Global $SaveFolderLocation = @DesktopDir & "Temp"
Global $ClearTimer
Global $ProgressEmptied = 1
Global $ButtonsBlocked = 0

;~ http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/

;~ $GUI = GUICreate("StanceWorks Image Batch Downloader", 230, 172,(@DesktopWidth-240),(@DesktopHeight-74-170),-1,$WS_EX_TOPMOST)
$GUI = GUICreate("StanceWorks Image Batch Downloader", 230, 172, -1, -1, -1, $WS_EX_TOPMOST)
;~ $InputLink = GUICtrlCreateInput("Link", 10, ($HorizontalPlacement * $HorizontalSpacing), 210)
$InputLink = GUICtrlCreateInput("http://www.stanceworks.com/2012/06/the-quest-to-break-10-johans-turbo-e30-m3/", 10, ($HorizontalPlacement * $HorizontalSpacing), 210)
$HorizontalPlacement += 2.5
GUICtrlCreateLabel("Select blacklist:", 10, ($HorizontalPlacement * $HorizontalSpacing), 210)
$HorizontalPlacement += 1.5
$DropdownBlacklist = GUICtrlCreateCombo($DropdownBlacklistText, 10, ($HorizontalPlacement * $HorizontalSpacing), 210)
$HorizontalPlacement += 2
$CheckboxOpenDir = GUICtrlCreateCheckbox("Open image folder after downloading", 10, ($HorizontalPlacement * $HorizontalSpacing), 210)
$HorizontalPlacement += 2
$ButtonBrowse = GUICtrlCreateButton("Browse", 10, ($HorizontalPlacement * $HorizontalSpacing), 80)
$ButtonDownload = GUICtrlCreateButton("Download", 220 - 10 - 70, ($HorizontalPlacement * $HorizontalSpacing), 80,-1,$BS_DEFPUSHBUTTON)
$HorizontalPlacement += 3
$ProgressBar = GUICtrlCreateProgress(10, ($HorizontalPlacement * $HorizontalSpacing), 210, -1, $PBS_SMOOTH)
$HorizontalPlacement += 3
$ProgressName = GUICtrlCreateLabel("Ready", 10, ($HorizontalPlacement * $HorizontalSpacing), 210, 20, $SS_SUNKEN)

_BlacklistImporter()
;~ _BlacklistDropdownUpdater()

GUISetState(@SW_SHOW)

Func _BlacklistImporter()
;~ Global $SWBlacklist[1]
Global $BlacklistDatabase[1]
Local $ArrayCounter = 0
Local $iBlacklistCounter = 2

FileChangeDir(@ScriptDir & "blacklist folder")
$FirstFile = FileFindFirstFile("*.blk")
Do
$BlacklistFile = FileFindNextFile($FirstFile)
$NextFileError = @error
;~ _ArrayDisplay($BlacklistDatabase)
_GUICtrlComboBox_AddString($DropdownBlacklist, StringTrimRight($BlacklistFile, 4))
;~ _GUICtrlComboBox_AddString($DropdownBlacklist, $BlacklistDatabase[1])
;~ MsgBox("","", $ArrayCounter)
Until $NextFileError = 1

_GUICtrlComboBox_SetCurSel($DropdownBlacklist, 0)
$DropdownStringCount = _GUICtrlComboBox_GetCount($DropdownBlacklist)
_GUICtrlComboBox_DeleteString($DropdownBlacklist, $DropdownStringCount - 1)

EndFunc ;==>_BlacklistImporter

Func _BlacklistActivator()
Local $iActivatorCounter
Local $ActivatorArrayCounter
Global $CurrentBlacklist[1]

$ActivatorCurrentBlacklist = _GUICtrlComboBox_GetEditText($DropdownBlacklist)
;~ ConsoleWrite("Current: " & $ActivatorCurrentBlacklist & @CRLF)

FileChangeDir(@ScriptDir & "blacklist folder")
$ActivatorFile = FileOpen($ActivatorCurrentBlacklist & ".blk")
;~ ConsoleWrite(@error & @CRLF)
Do
$iActivatorCounter += 1
$TempFileRead = FileReadLine($ActivatorFile, $iActivatorCounter)
$FileReadError = @error

If Not $FileReadError = -1 Or $FileReadError = 1 Then
_ArrayAdd($CurrentBlacklist, $TempFileRead)
;~ ConsoleWrite("Current array entry: " & $TempFileRead & @CRLF)
$ActivatorArrayCounter += 1
EndIf
Until $FileReadError = -1 Or $FileReadError = 1

FileClose($ActivatorFile)

;~ ConsoleWrite("Read error: " & $FileReadError & @CRLF)
;~ ConsoleWrite("Activator Counter " & $ActivatorArrayCounter & @CRLF)
_ArrayInsert($CurrentBlacklist, 0, $ActivatorArrayCounter)
_ArrayDelete($CurrentBlacklist, 1)

;~ Global $BlacklistArray[1]
;~ $BlacklistArray = $CurrentBlacklist
;~ _ArrayDisplay($BlacklistArray)
;~ _ArrayDisplay($CurrentBlacklist)

;~ MsgBox("", "", $CurrentBlacklist[1])
;~ _ArrayDisplay($CurrentBlacklist)
Return ($CurrentBlacklist)
EndFunc ;==>_BlacklistActivator


Func _ImageFilter($SiteLink)

;~ _ArrayDisplay($BlacklistDatabase)
;~ _ArrayDisplay($BlacklistArray)

Global $BlacklistArray[1]

$BlacklistArray = _BlacklistActivator()
;~ _ArrayDisplay($BlacklistArray)
;~ MsgBox("", "*", $BlacklistArray[1])

_ProgressUpdater("Gathering info")

Local $oIE = _IECreateEmbedded()
Local $hGUI = GUICreate("Info gathering", 200, 200, -1, -1, BitOR(0x00010000, 0x00020000))
Local $InternetinGui = GUICtrlCreateObj($oIE, 0, 0)
_IENavigate($oIE, $SiteLink)
_IELoadWait($oIE)
Local $sTags = _IETagNameGetCollection($oIE, "img")
Local $ImageCount = @extended
Local $iTotalImageCounter
Local $iComparisonCounter
Local $ArrayDownloadCounter = 0

;~ MsgBox("", "", $ImageCount)
$ArrayImages[0] = $ImageCount
For $tag In $sTags
;~ MsgBox("", "", $tag.src)
;~ ConsoleWrite("Current image entry: " & $tag.src & @CRLF)
_ArrayAdd($ArrayImages, $tag.src)
Next

;~ _ArrayDisplay($ArrayImages)
;~ _ArrayDisplay($BlacklistArray)
;~ _ArrayDisplay($ArrayDownload)

_ProgressUpdater("Blacklist check")
ProcessClose("iexplore.exe")

;~ MsgBox("","",$ArrayImages[0]) = 28


;~ $iTotalImageCounter
;~ $iComparisonCounter
;~ $BlacklistArray[0]
;~ $ArrayImages[0]



For $iTotalImageCounter = 1 To $ArrayImages[0] Step 1
For $iComparisonCounter = 2 To $BlacklistArray[0] Step 1
ConsoleWrite("Counter: " & $iComparisonCounter & "/" & $BlacklistArray[0] & @CRLF)
ConsoleWrite("+" & $ArrayImages[$iTotalImageCounter] & " - Images" & @CRLF)
If $ArrayImages[$iTotalImageCounter] = $BlacklistArray[$iComparisonCounter] Then
ConsoleWrite("-" & $BlacklistArray[$iComparisonCounter] & " - Blacklisted" & @CRLF)
ExitLoop
EndIf
ConsoleWrite("Blacklist tester:" & $iTotalImageCounter & @CRLF)
If $iComparisonCounter = $BlacklistArray[0] Then
_ArrayAdd($ArrayDownload, $ArrayImages[$iTotalImageCounter])
$ArrayDownloadCounter += 1
EndIf

;~ ConsoleWrite($iComparisonCounter & @CRLF)
;~ ConsoleWrite(">-----" & @CRLF)
Next
Next

;~ ProcessClose("iexplore.exe")

_ArrayInsert($ArrayDownload, 0, $ArrayDownloadCounter)
_ArrayDelete($ArrayDownload, 1)
;~ _ArrayDisplay($ArrayDownload)

;~ MsgBox("","","Array: " & $ArrayDownload[1] & @CRLF & "IsString: " & IsString($ArrayDownload[1]))
If IsString($ArrayDownload[1]) = 1 Then
_ImageDownloader()
Else
_ProgressUpdater("No files found or all blacklisted")
EndIf
EndFunc ;==>_ImageFilter

Func _ImageDownloader()
Local $DLCounter
Local $iDeleteCounter

_ProgressUpdater("Downloading")

;~ MsgBox("", "", $SaveFolderLocation)
If Not FileExists($SaveFolderLocation) Then
DirCreate($SaveFolderLocation)
;~ If @error = 0 Then
If Not FileExists($SaveFolderLocation) Then
ConsoleWrite("!Error creating directory, -> " & @extended & @CRLF)
Else
ConsoleWrite("+No error creating directory" & @CRLF)
EndIf
EndIf

For $DLCounter = 1 To $ArrayDownload[0] Step 1
$DownloadName = _Stringifier($ArrayDownload[$DLCounter])
InetGet($ArrayDownload[$DLCounter], $SaveFolderLocation & $DownloadName)

GUICtrlSetData($ProgressBar, ($DLCounter / $ArrayDownload[0] * 100))
GUICtrlSetData($ProgressName, $DownloadName)

ConsoleWrite("!Downloading file " & $DLCounter & " of " & $ArrayDownload[0] & @CRLF)
ConsoleWrite("-" & $ArrayDownload[$DLCounter] & @CRLF)
ConsoleWrite("+" & $SaveFolderLocation & $DownloadName & @CRLF)
Next
For $iDeleteCounter = $ArrayDownload[0] To 0 Step -1
_ArrayDelete($ArrayDownload, $iDeleteCounter)
Next
Global $ArrayDownload[1]


If GUICtrlRead($CheckboxOpenDir) = 1 then
ShellExecute("Explorer.exe",$SaveFolderLocation)
EndIf
$SaveFolderLocation = "XXX"
_ProgressUpdater("Download complete!", "Link")


EndFunc ;==>_ImageDownloader

Func _ProgressUpdater($PUName, $PULink = "")
;~ GUICtrlSetData($ProgressBar, 0)
GUICtrlSetData($ProgressName, $PUName)
If Not $PULink = "" Then GUICtrlSetData($InputLink, $PULink)
;Timer stuff
$ProgressEmptied = 0
$ClearTimer = TimerInit()
EndFunc ;==>_ProgressUpdater

Func _Stringifier($Link)
Local $Pattern
Local $Array
Local $String[1]

;~ $Link = "http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png"

;~ MsgBox("", "", $Link)
$Pattern = "(?i).+/(.+.png|.+.jpg).*"
Local $String = StringRegExp($Link, $Pattern, 1)

;~ $String = _ArrayToString($String[0])

;~ ConsoleWrite(">" & "String:" & $String & @CRLF)
ConsoleWrite(">" & "String:" & $String[0] & @CRLF)

Return $String[0]
EndFunc ;==>_Stringifier

;~ http://www.stanceworks.com/2012/06/vegas-lights-the-rotiform-audi-allroad-on-sjcs/

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $ButtonBrowse
$SaveFolderLocation = (FileSaveDialog("Choose directory", @UserProfileDir & "pictures", "Folder(*.*)", 16, "Images") & "")
If @error = 1 Then $SaveFolderLocation = "XXX"
;~ MsgBox("", "", $SaveFolderLocation)
Case $ButtonDownload
If $SaveFolderLocation = "XXX" Then
_ProgressUpdater("Please select a save folder(Click browse)")
Else
GUICtrlSetState($ButtonBrowse,$GUI_DISABLE)
GUICtrlSetState($ButtonDownload,$GUI_DISABLE)
$ButtonsBlocked = 1
_ImageFilter(GUICtrlRead($InputLink))
EndIf
EndSwitch

If (TimerDiff($ClearTimer) / 1000) > "3" And $ProgressEmptied = 0 Then
GUICtrlSetData($ProgressBar, 0)
GUICtrlSetData($ProgressName, "Ready")
$ProgressEmptied = 1
EndIf
If $ButtonsBlocked = 1 Then
GUICtrlSetState($ButtonBrowse,$GUI_ENABLE)
GUICtrlSetState($ButtonDownload,$GUI_ENABLE)
$ButtonsBlocked = 0
EndIf
WEnd

Edit:

Most of the comments are, as in the previous versions, code that are there for debugging and therefore commented out so i got it if i need to re-debug.

If anyone shows any interest, i can explain it all

Edited by Maffe811

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites

Hey there,

nice script! But i always get an error in the latest version.

C:UsersSX200Desktopdownload_img.au3 (189) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

If IsString($ArrayDownload[1]) = 0 Then

If IsString(^ ERROR

There are 26 Images in $ArrayImages but $ArrayDownload is always empty. I did nothing to the blacklist.

Maybe you want to have a look at it

Share this post


Link to post
Share on other sites

Okay I found the error. I created a blacklist and it starts checking the blacklist against the $ArrayDownload. But then it tolds me that all images are blacklisted. The console only shows a few blacklisted images.

Share this post


Link to post
Share on other sites

Somehow i'm not allowed to edit my last post.

It was my bad! I copied your Code again and it works like a charm now!

Share this post


Link to post
Share on other sites

Somehow i'm not allowed to edit my last post.

Just as an FYI, 5 is the magic number of posts before you're allowed to do some things, including edit old posts.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

It was my bad! I copied your Code again and it works like a charm now!

Awesome! :D

Dag nabbit, i just remembered that the script DOESN'T write its own blacklist if none is found :(

Crap.

Write this in your editor of choice and save as *Blacklistname*.blk (can be stanceworks.com)

StanceWorks.com
http://cdn.stanceworks.com/wp-content/themes/saviour/images/Vendors/stanceworks-avila-show2.png
http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/AvilaBanner.jpg
http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/IphoneBanner.jpg
http://cdn.stanceworks.com/wp-content/uploads/2012/03/Resizebanner1.png
http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/previous-article.png
http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/next-article.png
http://cdn.stanceworks.com/wp-content/uploads/trackableshare//facebook.png
http://cdn.stanceworks.com/wp-content/uploads/trackableshare//twitter.png
http://cdn.stanceworks.com/wp-content/uploads/trackableshare//tumblr.png
http://cdn.stanceworks.com/wp-content/uploads/trackableshare//stumbleupon.png
http://cdn.stanceworks.com/wp-content/uploads/trackableshare//reddit.png
http://cdn.stanceworks.com/wp-content/uploads/trackableshare//email.png
http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-facebook.png
http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-vimeo.png
http://www.stanceworks.com/wp-content/themes/saviour/images/graphics/stanceworks-twitter.png

Place this in a folder named "blacklist folder", if you change the folder name, you have to change the name in the script too.

I will fix this in the next release.

Edited by Maffe811

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0