Jump to content
Danyfirex

Google Image Save

Recommended Posts

Danyfirex

Hi Mates. Recently  I was needing to download some images from google images. but I got tired,frustrated when I had to click in the imagen then click again to be able to download the image with its real size. so For That I write this small code.

For downloading just simple go over the image in google image page., then press CTRL+MOUSE(just a little move is enowgh) that make a drag&drop so in that moment the code show a little window(5*5 LOL + transparency) so when realease the  mouse (mouse up event) the code start new process(itself) to download the image. 

 

For well in Google Chrome Broswer.

For Firefox almost always fails. 

Feactures.

  • Allow choose a folder for download save.
  • Allow Open the downloadfolder.

 

#NoTrayIcon
#include <GuiRichEdit.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <MsgBoxConstants.au3>
#include <TrayConstants.au3>
#include <File.au3>
#include <InetConstants.au3>

Opt("GUIOnEventMode", 1)
Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 3)

Local $AppExist = 0
If $CmdLine[0] = 0 Then
    If _Singleton('Danyfirex', 1) = 0 Then
        MsgBox(64, "", "Aplication is Already Running")
        Exit
    EndIf
EndIf

If $CmdLine[0] = 2 Then ;Downloader to Folder
    Local $sSaveFolder = $CmdLine[2] ;URL
    Local $sURL = $CmdLine[1] ;Folder
    Download($sURL, $sSaveFolder)
    Exit
EndIf


If Not @Compiled Then
    MsgBox(64, "", "Must be Compile For Download")
EndIf


HotKeySet("{ESC}", "Terminate")

Global $sFolderPath = @UserProfileDir & "\Pictures\"

Local $hDLL = DllOpen("user32.dll")
Local $hGUI, $hRichEdit = 0

$hGUI = GUICreate("Google Image Save", 5, 5, -1, -1, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
$hRichEdit = _GUICtrlRichEdit_Create($hGUI, "", 0, 0, 5, 5, -1)

TrayCreateItem("Set Folder to Save")
TrayItemSetOnEvent(-1, "SetFolder")
TrayCreateItem("")
TrayCreateItem("Open Folder")
TrayItemSetOnEvent(-1, "OpenFolder")
TrayCreateItem("")
TrayCreateItem("About...")
TrayItemSetOnEvent(-1, "About")
TrayCreateItem("")
TrayCreateItem("Exit")
TrayItemSetOnEvent(-1, "Terminate")

TraySetState($TRAY_ICONSTATE_SHOW)

WinSetTrans($hGUI, '', 1)
GUISetState(@SW_HIDE)

Local $aMouse = 0
Local $bCheck = False
Local $sDecode = ""
Local $i = 0
While True

    If _IsPressed("11", $hDLL) And _IsPressed("01", $hDLL) Then
        GUISetState(@SW_SHOW)
        $aMouse = MouseGetPos()
        WinMove($hGUI, '', $aMouse[0] - 2, $aMouse[1] - 2)
        $bCheck = True
    EndIf


    If _GUICtrlRichEdit_GetText($hRichEdit) <> '' And $bCheck Then
        $sDecode = GetURL(_GUICtrlRichEdit_GetText($hRichEdit))
        If $sDecode = "" Then
            $i += 1
            TrayTip($i & " Oops :(", 'Not Valid URL', 5)

        Else
            $i += 1
            TrayTip("[" & $i & "] Downloading :)", $sDecode, 5)
            If Not @Compiled Then
                MsgBox(64, "", "Must be Compile For Download")
            Else
                ShellExecute("GoogleImageSave.exe", $sDecode & " " & $sFolderPath)
            EndIf

        EndIf
        ConsoleWrite($sDecode & @CRLF)
        _GUICtrlRichEdit_SetText($hRichEdit, '')
        GUISetState(@SW_HIDE)
        $bCheck = False;
    EndIf

Sleep(100)


WEnd

Func GetURL($BADURL)
    Local $GoodURL = StringRegExp($BADURL, 'imgurl=(.*)\.(jpg|png|gif|bmp)', 3)
    If @error Then Return ''
    Return $GoodURL[0] & '.' & $GoodURL[1]
EndFunc   ;==>GetURL


Func Terminate()
    If MsgBox($MB_YESNO, "Exit", "¿Do You Want to Exit") = 6 Then Exit
EndFunc   ;==>Terminate

Func SetFolder()
    $sFolderPath = FileSelectFolder('Select a Folder', "")
    If $sFolderPath <> "" Then $sFolderPath &= '\'
    If $sFolderPath = "" Then $sFolderPath = @UserProfileDir & "\Pictures\"

EndFunc   ;==>SetFolder

Func OpenFolder()
    ShellExecute($sFolderPath)
EndFunc   ;==>OpenFolder


Func About()
    MsgBox(0, "Autoit Forum :)", "Written by Danyfirex")
EndFunc   ;==>About

Func _GetName($psFilename)
    Local $szDrive, $szDir, $szFName, $szExt
    _PathSplit($psFilename, $szDrive, $szDir, $szFName, $szExt)
    Return $szFName & $szExt
EndFunc   ;==>_GetName


Func Download($Url, $sSaveFolder)
    Local $sImageName = _GetName($Url)
    InetGet($Url, $sSaveFolder & $sImageName, $INET_FORCERELOAD)
    TraySetState($TRAY_ICONSTATE_SHOW)
    TrayTip("Downloaded :)", "", 0)
    TrayTip("Downloaded :)", $Url, 5)
    Sleep(5000)
EndFunc   ;==>Download

Saludos

  • Like 1

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

  • Similar Content

    • nacerbaaziz
      By nacerbaaziz
      Hello
      Can we pause and resume the download in the InetGet function?
      If is possible, what is the solution please?
      I used this code To manage the download

      #include <INet.au3> func _downloader($name, $linc, $filepath, $RTLF = false, $link = false) global $downloader = GUICreate("downloader", 400, 200, -1, -1, $WS_CLIPCHILDREn, $RTLF, $link) global $path = $filePath $labelTxt = GUICtrlCreateLabel("downloading " & $name, 50, 10, 200, 20) global $labelTxt0 = GUICtrlCreateLabel("downloaded size 0 MB " & "OF 0 MB", 50, 60, 300, 20) global $Progress = "" global $sText = ""     For $i = 1 To Random(5, 20, 1) ; Return an integer between 5 and 20 to determine the length of the string.         $sText &= Chr(Random(65, 122, 1)) ; Return an integer between 65 and 122 which represent the ASCII characters between a (lower-case) to Z (upper-case). next global $labelTxt2 = GUICtrlCreateInput("0%", 50, 80, 50, 20) _GUICtrlEdit_SetReadOnly(-1, true) GUIStartGroup("") global $beep = GUICtrlCreateCheckBox("use the progress beep notification", 150, 120, 200, 20) GUIStartGroup("") $button = GUICtrlCreateButton("Cancel', 130, 150, 180, 25, 0x01) $iIndex = 0 global $Target global $url GUIStartGroup("") global $Progress = GUICtrlCreateProgress(50, 90, 150, 20) global $Target = $filepath global $url = $linc global $path = $filepath global $hDownloadNo = _RSMWare_GetData($url, $Target) global $status = false AdlibRegister("SetProgress") global $onprogress = false, $curent = false GUISetState(@sw_Show) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $button $asc = MsgBox(4132,"exit download?","if you click yes the downloading will be cancel, do you want to cancel it ?") if $asc = 6 then AdlibUnRegister("SetProgress") GUIDelete() If $hDownloadNo <> 0 Then InetClose($hDownloadNo) exitLoop endIf EndSwitch if $status = -1 then $status = 0 $hDownloadNo = _RSMWare_GetData($url, $Target) $onprogress = false $curent = false elseIf $Status = 1 then $status = $path GUIDelete() AdlibUnRegister("SetProgress") exitLoop endIf WEnd return $status endFunc Func _RSMWare_GetData($url, $Target) Local $hDownload = InetGet($url, $Target, 1, 1) Return $hDownload EndFunc ;==>_RSMWare_GetData Func SetProgress() Local $state If $hDownloadNo <> 0 Then $state = InetGetInfo($hDownloadNo) If @error = 0 Then $infor = "downloaded size " & Round(Execute(InetGetInfo($hDownloadNo, $INET_DOWNLOADREAD) / 1048576), 2) & " MB of " & Round(Execute(InetGetInfo($hDownloadNo, $INET_DOWNLOADSIZE) / 1048576), 2) & " MB " $onprogress = Round(Ceiling(($state[0] / $state[1]) * 100)) if not (InetGetInfo($hDownloadNo, $INET_DOWNLOADSIZE) = 0) then if $onProgress <= 0 then $onProgress = 0 GUICtrlSetData($Progress, $onProgress) GUICtrlSetData($labelTxt0, $infor) GUICtrlSetData($labelTxt2, $onProgress & "%") if _isChecked($beep) then if $onprogress > $curent then beep((100 + $onprogress * 20), 100) $curent = $onprogress endIf endIf endIf If $state[2] Then If $state[3] Then InetClose($hDownloadNo) $status = 1 else InetClose($hDownloadNo) $status = -1 endIf endIf EndIf endIf EndFunc ;==>SetProgress
    • Xandy
      By Xandy
      MapIt is a tile world editor.  MapIt was built around the concept of reversing Dragon Warrior map images.  MapIt can take image input and produce a tile and world array.
      MapIt features Unity style dragable labels that adjust property values.

      MapParser is a C++ project that scans images for unique tiles.  MapParser is very fast.  Due to hard drive failure, many bugs were restored b/c I had to rewind many years.  Frustrated with the design, I wrote a new version from the ground up.  This New Version:  AutoIt Front-end, command line controls, and shared with the world; so that I can't lose it again.
      You can toggle the C++ MapParser off to see the difference in speeds between the MapParser CPP verse AutoIt function.  Function is named Scan_Tiles() in AutoIt.  You can also chose to download without MapParser.exe.
      At the moment Scanning a image resets the arrays, but you can add tiles after scanning.
      Images can be added as tiles without scan image at all.  Then configure settings to give your world parameters and manually fill the world data with tile indexes.
      Using the settings you can change tile size after a scan.  Example: you wanted to replace a map with different sized tiles.
      Changing and replacing tile / world data is easy.  B/c tile world editor.

      Hotkeys, I use CTRL+R in image above to signal replace tile action and I use "G" to Get the tile under mouse.
      Hotkeys are not saved to disk and thus are set to default between sessions.
      I might draw the world to pre-rendered surfaces and use them as multi-layer someday.  I do that in my AutoIt, DragonWarrior Remake but I could spend forever unsure what features are important for this.  The DW_Remake has a method of replacing a tile with a tile on two layers.  So you could replace a tree on the first layer with a grass, and a tree in the second layer.  This is all getting very confusing.
      I attempted to write the good code.  If something could be better, please advise.
      Fifth release.  Enjoy.
      For download, videos, and example of created world file data; please visit the MapIt webpage: http://songersoft.com/programming/mapit/mapit_about.phtml
      Special thanks: @AdmiralAlkex, @Melba23, @MrCreatoR
      Main AutoIt source file: Will not run without other Includes and SDL DLLs.
      Last Update: 5/26/2018 3:45 PM EST
      REMOVED CODE BLOCK:  I was informed the this page loaded very slowly, one solution so far has been to remove the 2k lines in the code block.
      When I recieve more feedback from the User I may reduce image size or remove images.
      Next Version Added: $eSETTING_TILE_LAST_PATH I have the weekend, I want to write world layers with aBoard surfaces.  
    • tintin92
      By tintin92
      Hello,

      How can I automatically download a list of zip files, like the ones in the quote, using a AutoIt script?
      Is it possible with AutoIt script?
       
    • lenclstr746
      By lenclstr746
      HELLO GUYS
      I'm a work on a background see and click bot project 
      I can complete it if your help me
      (using imagesearch , gdi+ and  fastfind)
    • dadalt95
      By dadalt95
      I would like to know if it's possible to pass an image recognition (captcha) system.
       
      What are the ways to achieve this?
      Just the references or links is enough for me by now.
       
      Thanks by now!
       
      Thanks!
×