Jump to content
Sign in to follow this  
Medic873

Pull Google Images

Recommended Posts

Medic873

Okay ive seen another program like this somewhere but im just trying to build it for myself

basicly what I want to do is set a keyword (simple input box)

and then once every hour my program will go to google images and pull a photo under that keyword and make it your background

so far Im just trying to tactil part one pull the image from google images

<p>#include <IE.au3>

#Include <ScreenCapture.au3>

#include <Excel.au3>

#include "array.au3"

#Include <File.au3>

#include <string.au3>

#include <INet.au3>

$GoogleImagesHTML = _INetGetSource("

Share this post


Link to post
Share on other sites
FireFox

Hi,

Like this :

#include <INet.au3>
#include <String.au3>

Global $sSource, $aImgURL, $sKeyWord

$sKeyWord = "toto"

$sSource = _INetGetSource("http://www.google.fr/search?q=" & $sKeyWord & "&tbm=isch")

$aImgURL = _StringBetween($sSource, '<a href="/imgres?imgurl=', '&amp;imgrefurl=')

ConsoleWrite($aImgURL[0] & @CrLf)

Br, FireFox.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
PhoenixXL

Great reply by firefox

here is an example of the code firefox posted

#include <INet.au3>
#include <String.au3>

Global $sSource, $aImgURL, $sKeyWord

$sKeyWord = "hello"

$sSource = _INetGetSource("http://www.google.fr/search?q=" & $sKeyWord & "&tbm=isch")

$aImgURL = _StringBetween($sSource, '<a href="/imgres?imgurl=', '&amp;imgrefurl=')

$aImgURL=$aImgURL[Random(0,UBound($aImgURL)-1,1)]

$nFile=@ScriptDir&'Downloaded.'&StringRight($aImgURL,3)
InetGet($aImgURL,$nFile)

GUICreate('')
GUICtrlCreatePic($nFile,0,0)

GUISetState()

While GUIGetMsg()<>-3
Sleep(10)
WEnd
Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
FireFox

Great reply by firefox

:graduated: thanks.

hehe, you can also display a mosaic of all images :idiot:


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
PhoenixXL

yup,

good idea

here is the code of mosaic

#include <INet.au3>
#include <String.au3>
Global $sSource, $aImgURL, $sKeyWord

$sKeyWord = "hello"

$sSource = _INetGetSource("http://www.google.fr/search?q=" & $sKeyWord & "&tbm=isch")

$aImgURL = _StringBetween($sSource, '<a href="/imgres?imgurl=', '&amp;imgrefurl=')
Local $iBound=UBound($aImgURL)
Local $nFile[$iBound]
For $i=0 To $iBound-1
$nFile[$i]=@ScriptDir&'Downloaded'&$i+1&StringRight($aImgURL[$i],4)
InetGet($aImgURL[$i],$nFile[$i])
Next

GenerateButtons($nFile,UBound($nFile)-1,5)

Exit


Func GenerateButtons($nButtonNameArray,$sNumber,$sLine=1,$Width=70,$Height=50,$sButtonSpacing=10,$hBorderSpacing=20)
If $sLine>=$sNumber Then $sLine=$sNumber
Local $sMaxButton=Ceiling($sNumber/$sLine)
Local $Form2 = GUICreate("Phoenix XL _Testing.au3", _
($sMaxButton*$Width)+(2*$hBorderSpacing)+(($sMaxButton-1)*$sButtonSpacing), _
($sLine*$Height)+(2*$hBorderSpacing)+(($sLine-1)*$sButtonSpacing))
Global $Buttons[$sNumber+1]
Local $h = $hBorderSpacing
Local $w = $hBorderSpacing
If Not IsArray($nButtonNameArray) Then
Local $nMakeArray[1]=[0]
Local $iCount,$iDimension
For $n=1 To $sNumber
_ArrayAddEx($nMakeArray,0,$iDimension,$iCount)
Next
ReDim $nMakeArray[$iCount]
$nButtonNameArray=$nMakeArray
EndIf
For $i=1 To $sNumber
$Buttons[$i]=GUICtrlCreatePic($nButtonNameArray[$i],$w,$h,$Width,$Height)
GUICtrlSetTip(-1,'Button Number: '&$i,'Information',1,3)
If IsMultiple($i,$sMaxButton) Then
$h+=$Height+$sButtonSpacing
$w = $hBorderSpacing
Else
$w+=$Width+$sButtonSpacing
EndIf
Next
GUISetState()
Local $nMsg
While 1
$nMsg=GUIGetMsg()
Switch $nMsg
Case -3
Return GUIDelete($Form2)
Case $Buttons[1] To $Buttons[$sNumber]
GUICtrlSetData($nMsg,Number(GUICtrlRead($nMsg))+1)
EndSwitch
WEnd
EndFunc

Func IsMultiple($nNumber,$sFactor)
If IsInt($nNumber/$sFactor) Then Return 1
Return 0
EndFunc

Func _ArrayAddEx(ByRef $aArray, $sData, ByRef $iDimension, ByRef $iCount) ; Taken from Array.au3 and modified by guinness to reduce the use of ReDim.
    If IsArray($aArray) = 0 Then
        Return SetError(1, 0, -1)
    EndIf

    If UBound($aArray, 0) <> 1 Then
        Return SetError(2, 0, -1)
    EndIf

    If $iCount = 0 Then
        $iCount = UBound($aArray, 1)
    EndIf

    $iCount += 1
    If ($iCount + 1) >= $iDimension Then
        $iDimension = (UBound($aArray) + 1) * 2
        ReDim $aArray[$iDimension]
    EndIf
    $aArray[$iCount - 1] = $sData
    Return $iCount - 1
EndFunc   ;==>_ArrayAddEx
Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
FireFox

here is the code of mosaic

muttley I was almost sure that you would do it.

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
PhoenixXL

good guess :graduated:


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
PhoenixXL

Some pngs were not getting set,

therefore i modified, added the support of GDIPlus

#include <INet.au3>
#include <String.au3>
#include <Gdiplus.au3>
#include <Array.au3>
_GDIPlus_Startup()
Global $sSource, $aImgURL, $sKeyWord

$sKeyWord = "love"

$sSource = _INetGetSource("http://www.google.com/search?q=" & $sKeyWord & "&tbm=isch")

$aImgURL = _StringBetween($sSource, '<a href="/imgres?imgurl=', '&amp;imgrefurl=')
_ArrayInsert($aImgURL,0,UBound($aImgURL))
Local $iBound = UBound($aImgURL)
Local $nFile[$iBound]
For $i = 1 To $iBound-1
$nFile[$i] = @ScriptDir & 'Downloaded' & $i & StringRight($aImgURL[$i], 4)
InetGet($aImgURL[$i], $nFile[$i])
Next

GenerateButtons($nFile, UBound($nFile) - 1, 5,300,120)
_GDIPlus_Shutdown()
Exit


Func GenerateButtons($nButtonNameArray, $sNumber, $sLine = 1, $Width = 70, $Height = 50, $sButtonSpacing = 10, $hBorderSpacing = 20)
If $sLine >= $sNumber Then $sLine = $sNumber
Local $sMaxButton = Ceiling($sNumber / $sLine)
Local $Form2 = GUICreate("Phoenix XL _Testing.au3", _
($sMaxButton * $Width) + (2 * $hBorderSpacing) + (($sMaxButton - 1) * $sButtonSpacing), _
($sLine * $Height) + (2 * $hBorderSpacing) + (($sLine - 1) * $sButtonSpacing))
Global $Buttons[$sNumber + 1]
Local $h = $hBorderSpacing
Local $w = $hBorderSpacing
If Not IsArray($nButtonNameArray) Then
Local $nMakeArray[1] = [0]
Local $iCount, $iDimension
For $n = 1 To $sNumber
_ArrayAddEx($nMakeArray, 0, $iDimension, $iCount)
Next
ReDim $nMakeArray[$iCount]
$nButtonNameArray = $nMakeArray
EndIf
For $i = 1 To $sNumber
$Buttons[$i] = GUICtrlCreatePic('', $w, $h, $Width, $Height)
_PicSetImage($nButtonNameArray[$i],$Buttons[$i],$Form2)
GUICtrlSetTip(-1, 'Button Number: ' & $i, 'Information', 1, 3)
If IsMultiple($i, $sMaxButton) Then
$h += $Height + $sButtonSpacing
$w = $hBorderSpacing
Else
$w += $Width + $sButtonSpacing
EndIf
Next
WinSetOnTop($Form2,'',1)
GUISetState()
Local $nMsg
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Return GUIDelete($Form2)
Case $Buttons[1] To $Buttons[$sNumber]
GUICtrlSetData($nMsg, Number(GUICtrlRead($nMsg)) + 1)
EndSwitch
WEnd
EndFunc   ;==>GenerateButtons

Func IsMultiple($nNumber, $sFactor)
If IsInt($nNumber / $sFactor) Then Return 1
Return 0
EndFunc   ;==>IsMultiple

Func _ArrayAddEx(ByRef $aArray, $sData, ByRef $iDimension, ByRef $iCount) ; Taken from Array.au3 and modified by guinness to reduce the use of ReDim.
If IsArray($aArray) = 0 Then
Return SetError(1, 0, -1)
EndIf

If UBound($aArray, 0) <> 1 Then
Return SetError(2, 0, -1)
EndIf

If $iCount = 0 Then
$iCount = UBound($aArray, 1)
EndIf

$iCount += 1
If ($iCount + 1) >= $iDimension Then
$iDimension = (UBound($aArray) + 1) * 2
ReDim $aArray[$iDimension]
EndIf
$aArray[$iCount - 1] = $sData
Return $iCount - 1
EndFunc   ;==>_ArrayAddEx

Func _PicSetImage($nFile, $nPic, $hGUI)
$hBmp = _GDIPlus_ImageLoadFromFile($nFile)
$hBmp_Logo = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp)
_GDIPlus_BitmapDispose($hBmp)
$nPos=ControlGetPos($hGUI,'',$nPic)
GUICtrlSendMsg($nPic, 0x0172, 0, $hBmp_Logo)
ControlMove($hGUI,'',$nPic,Default,Default,$nPos[2],$nPos[3])
EndFunc   ;==>_PicSetImage

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
Medic873

BTW Forgot to say thank you for this, was a real help.

Share this post


Link to post
Share on other sites
FireFox

BTW Forgot to say thank you for this, was a real help.

muttley finally woke up from his long sleep.

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

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  

  • Similar Content

    • corz
      By corz
      We've been able to drag images out of web browsers since forever. Can I drag one into my GUI?
      Or rather, can I drag an image from my web browser onto my GUI and have my app *do* something with that image?
      My fingers bleed from searching. Any ideas much appreciated!
      ;o) Cor
    • fatpig
      By fatpig
      can anyone tell me how I stop this from occuring when I place a jpg in my GUI?
      White parts become black. might be transparent, too. Not sure.
      thanks

    • passwd
      By passwd
      Hello. I'm trying to make a form with two pictures and one button. But pictures must overlap one another. First picture I'm getting from screenshot of another window, but second picture must be with alfa channel and positioning on that first image.
      Something like that:
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <ScreenCapture.au3> Global Const $AC_SRC_ALPHA = 1 $Form1_1 = GUICreate("Document", 701, 671, -1, -1) GUISetBkColor(0xFFFFFF) $Pic1 = GUICtrlCreatePic("", 8, 8, 409, 657) $Button1 = GUICtrlCreateButton("Take Picture", 424, 8, 161, 33) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Generate() EndSwitch WEnd Func Generate() Local $hBMP, $hBitmap, $hGraphic, $WindowToCapture WinActivate("Notepad") $WindowToCapture = ControlGetHandle("Notepad", "", "[CLASS:Edit; INSTANCE:1]") $hBMP = _ScreenCapture_CaptureWnd ( '', $WindowToCapture,4,4,400,470,False) ; Initialize GDI+ library _GDIPlus_Startup() $PicHandle = GUICtrlGetHandle($Pic1) $myGuiHandle = ControlGetHandle("Document", "", $PicHandle) $TransparentButtonTest = GUICreate("", 0, 0, 390, 130, $WS_EX_MDICHILD, $WS_EX_LAYERED, $myGuiHandle) $hImageButton = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\2-f.png") SetBitMap($TransparentButtonTest, $hImageButton, 255) GUISetState() WinActivate("Document") ; Draw bitmap to GUI $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) $hGraphic = _GDIPlus_GraphicsCreateFromHWND(GUICtrlGetHandle($Pic1)) _GDIPlus_GraphicsDrawImage($hGraphic, $hBitmap, 0, 100) ; Clean up resources _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_BitmapDispose($hBitmap) _WinAPI_DeleteObject($hBMP) ; Shut down GDI+ library _GDIPlus_Shutdown() EndFunc Func SetBitmap($hGUI, $hImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetBitmap But the most interesting, that I need to move second picture(png FromFile) by draging it with mouse ontop of first image.
      Can you tell me what I have done wrong and maybe there is some easier ways to do this?
    • Michiel
      By Michiel
      I'm trying to use '?do=embed' frameborder='0' data-embedContent>> but none of the examples work. Mostly, I'm just not seeing any pictures, just nothing, a window with some text but no picture. What am I doing wrong? Do these examples work for anybody else?
×