Jump to content

Pull Google Images


 Share

Recommended Posts

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("

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 weeks later...

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
 Share

×
×
  • Create New...