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

    • Xandy
      By Xandy
      Special thanks: AdmiralAlkex, Melba23, MrCrearoR, Dragon Warrior 3, SDL
      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.  
      Changing and replacing tile / world data is easy.  B/c tile world editor.

      CTRL+R in image above to signal replace tile action and I use "G" to Get the tile under mouse.
      A full list of hotkeys can be assigned in the: Help Menu\Hotkeys
       
      MapParser is a C++ project that scans images for unique tiles. 
      MapIt can be downloaded without MapParser. MapParser can be toggled off in the Scan_Image dialog. Without MapParser, MapIt will use the Scan_Tiles() function written in AutoIt ; which is 100 * slower Idk. If MapParser.exe will not run for you:      Installing Visual C++ Redistributable for Visual Studio 2015 should fix it: https://www.microsoft.com/en-us/download/details.aspx?id=48145   
      You can start with example world and tiles.
      Example world was made following these steps:
      Started with a tile map image of DragonWarrior3 town of: Reeve From MapIt World Menu \ New \ Scan_Image dialog, I set the area to exclude the key legend to the far right of image. After scanning the map image to world and tile array.  I removed a few of the map artifacts.  More work could be done on this world; removing unwanted tiles, but it is fine for now. I saved my world to disk.  This creates folder: Worldname: Containing folder of Tiles and a Worldname.txt. Using The Gimp, I edited some tiles to have a transparent color: Stairs, Trees, Desk Tables, Chest-of-drawers, Chairs, Signs, Doors, Beds. I changed the world layers to 2: World Menu \ Properties. F9 Finds all selected tile on current layer and changes to a new selected tile on new layer. I used F9 to change all Trees on layer: 0 to Trees on layer: 1. Then I used F9 to change all Trees on layer: 0 to Grass on layer: 0  
      In this video you can see how I used the Tile Menu \ Replace From Disk option to remap tile images to my custom tiles.  Conveniently my tiles already have a transparent pixel.
      See video for how that was done:
      To use the example world:
      First unzip the world save file: http://songersoft.com/programming/mapit/worlds/Reeve_Swapped.zip From the World Menu: choose \Load Navigate to the Reeve_Swapped.txt located in the extracted zip. Or you can scan any image.
      The map images I used are here: http://www.realmofdarkness.net/dq/games/nes/dw3/maps/world
      For download, videos, and example of created world file data; please visit the MapIt webpage: http://songersoft.com/programming/mapit/mapit_about.phtml
    • Skeletor
      By Skeletor
      Hi All,
      While creating a few excel spreadsheets using AutoIt, I came across something which to my limiting time to research the forums I don't anyone has mentioned. 
      The color pallettes are reversed. 
      Huge shock to me.
       
      I wanted to produce a red row but kept on getting blue. 
      Seems like 0xFF0000 was red on the charts but when running the script, I got blue. 
      I then played around with the colors, and after a few tries, I finally got Red. 
      Reversed the FF0000 and the result is 0000FF.
       
      So for Excel compared to Html
      0000FF (Red) - Excel
      0000FF (Blue) - Html

      FFFF00 (Cyan) - Excel
      FFFF00(Yellow) - Html
       
    • Atoxis
      By Atoxis
      Howdy, I've gone through a lot of au3 forums, and I once had a working Imagesearch script that I got from here.  However, and i'm just totally not sure how but my imagesearch scripts aren't working anymore.
      I'm not new to au3 but i'm not the most experienced with it's syntax/commands.

      Anyways, I've looked over the big threads involving imagesearch.

      Does anyone have a working Imagesearch x64 for win10 that is currently working as of the date with the post.

      Dll's and what not is fine, just when I tell the script to run, I want to be able to find the image on the screen!
      Can't find a working copy so if anyone has one please send it my way lol.

      I've taken all the imagesearch downloads and what not and have played with them but I can't get any of them working on my end, despite others saying they're working.
      Thanks.
    • 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
    • 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?
       
×