Sign in to follow this  
Followers 0
DarkAngelBGE

Taking a picture of a website automatically

11 posts in this topic

Hi there is there a way to take a picture of a website automatically using php's functions? Could not find anything on google unfortunately. :)

Thanks for your help. :)

Share this post


Link to post
Share on other sites



Hi there is there a way to take a picture of a website automatically using php's functions? Could not find anything on google unfortunately. :)

Thanks for your help. :)

Wouldn't this be a question to ask on a PHP forum? :)

Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

Hrm yeah, I did it in fact. :) But I also wanted to try here because a desktop application is often a cooler solution. :)

Share this post


Link to post
Share on other sites

Hrm yeah, I did it in fact. :) But I also wanted to try here because a desktop application is often a cooler solution. :)

Well, I don't know about PHP functions, but you can do this with AutoIt. Is that what you're after?

Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

Yeah, basically. Is it possible?

Share this post


Link to post
Share on other sites

Yeah, basically. Is it possible?

Sure is. There is a screen capture module in Auto3Lib that will allow you to take a picture of any region of the screen or take a screen shot of a specific window based on it's window handle. All you need to do is get the handle to IE (or whatever you're using) and feed it to _ScreenCap_CaptureHWND. There are several examples that come with the library that show how to do this. See my sig for the download and feel free to give me a shout if you need help.

Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

Thank you for your help. :)

here is my source code:

#include <GUIConstants.au3>
#include <A3LScreenCap.au3>
$oIE = ObjCreate("Shell.Explorer.2")

; Create a simple GUI for our output
GUICreate ( "Taking photo of a website - Tim Koschuetzki", @DesktopWidth-100, @Desktopheight-100,10, 10 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX         = GUICtrlCreateObj      ( $oIE,      10, 40 , @DesktopWidth-150 , @Desktopheight-200)
$GUI_Button_Back    = GuiCtrlCreateButton   ("Back",     10, @Desktopheight-150, 100,  30)
$GUI_Button_Forward = GuiCtrlCreateButton   ("Forward", 120, @Desktopheight-150, 100,  30)
$GUI_Button_Home    = GuiCtrlCreateButton   ("Home",    230, @Desktopheight-150, 100,  30)
$GUI_Button_Stop    = GuiCtrlCreateButton   ("Stop",    330, @Desktopheight-150, 100,  30)

GUISetState ()    ;Show GUI

$oIE.navigate("http://linklift.de")

sleep(5000)
;_ScreenCap_Capture(@DesktopDir&"me.jpg")


; Full screen capture
_ScreenCap_Capture("c:\full.bmp")

; Region capture
_ScreenCap_Capture("c:\part1.bmp", 0, 0, 300, 400)

; Waiting for user to close the window
While 1
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_Button_Home
            $oIE.navigate("http://linklift.de")
        Case $msg = $GUI_Button_Back
            $oIE.GoBack
        Case $msg = $GUI_Button_Forward
            $oIE.GoForward
        Case $msg = $GUI_Button_Stop
            $oIE.Stop
    EndSelect
    
Wend

GUIDelete ()

Exit

What I want to do is take a screenshot of the $GUIActiveX window. is that possible? Also with the above code I get the following error at the first call to screencap:

C:\PROGRA~2\AutoIt3\Include\A3LWinAPI.au3 (1009) : ==> AutoIt has encountered a fatal crash as a result of:

Unable to execute DLLCall.:

$aResult = DllCall("Kernel32.dll", "int", "FormatMessageA", "int", $iFlags, "hwnd", $pSource, "int", $iMessageID, "int", $iLanguageID, "ptr", $pBuffer, "int", $iSize, "ptr", $vArguments)

too bad. :/

Share this post


Link to post
Share on other sites

Okay using screen capture now.

#include <GUIConstants.au3>
#include <A3LScreenCap.au3>

$pictureWidth = 300
$pictureHeight = 200

$oIE = ObjCreate("Shell.Explorer.2")


; Create a simple GUI for our output
GUICreate ( "Taking photo of a website - Tim Koschuetzki", @DesktopWidth-100, @Desktopheight-100,10, 10 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX         = GUICtrlCreateObj      ( $oIE,      10, 40 , $pictureWidth , $pictureHeight)
$GUI_Button_Back    = GuiCtrlCreateButton   ("Back",     10, @Desktopheight-150, 100,  30)
$GUI_Button_Forward = GuiCtrlCreateButton   ("Forward", 120, @Desktopheight-150, 100,  30)
$GUI_Button_Home    = GuiCtrlCreateButton   ("Home",    230, @Desktopheight-150, 100,  30)
$GUI_Button_Stop    = GuiCtrlCreateButton   ("Stop",    330, @Desktopheight-150, 100,  30)

GUISetState ()    ;Show GUI

$oIE.navigate("http://linklift.de")

sleep(3000)

DllCall("captdll.dll", "int", "CaptureRegion", "str", @DesktopDir&"\dump_full.jpg", "int", 30,"int",75,"int", $pictureWidth,"int",$pictureHeight,"int",100)
;DllCall("captdll.dll", "int", "CaptureRegion", "str", @DesktopDir&"\dump_partial.jpg", "int", 100, "int", 100, "int", 300, "int", 200, "int", -1)
Exit

; Capture given region
; Fist parameter - filename, next four: left, top, width, height. Last one - jpeg quality.
; Set quality to any negative number to capture into BMP
;DllCall("captdll.dll", "int", "CaptureRegion", "str", "dump_partial.bmp", "int", 100, "int", 100, "int", 300, "int", 200, "int", -1)

; Waiting for user to close the window
While 1
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_Button_Home
            $oIE.navigate("http://linklift.de")
        Case $msg = $GUI_Button_Back
            $oIE.GoBack
        Case $msg = $GUI_Button_Forward
            $oIE.GoForward
        Case $msg = $GUI_Button_Stop
            $oIE.Stop
    EndSelect
    
Wend

GUIDelete ()

Exit

Problem is that now the ActiveX opens the website in its original size, whereas I want to create a thumbnail. Can I open the site in 300x200 without scrolling to make a thumbnail?

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Thank you for your help. :)

here is my source code:

#include <GUIConstants.au3>
#include <A3LScreenCap.au3>
$oIE = ObjCreate("Shell.Explorer.2")

; Create a simple GUI for our output
GUICreate ( "Taking photo of a website - Tim Koschuetzki", @DesktopWidth-100, @Desktopheight-100,10, 10 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX         = GUICtrlCreateObj      ( $oIE,      10, 40 , @DesktopWidth-150 , @Desktopheight-200)
$GUI_Button_Back    = GuiCtrlCreateButton   ("Back",     10, @Desktopheight-150, 100,  30)
$GUI_Button_Forward = GuiCtrlCreateButton   ("Forward", 120, @Desktopheight-150, 100,  30)
$GUI_Button_Home    = GuiCtrlCreateButton   ("Home",    230, @Desktopheight-150, 100,  30)
$GUI_Button_Stop    = GuiCtrlCreateButton   ("Stop",    330, @Desktopheight-150, 100,  30)

GUISetState ();Show GUI

$oIE.navigate("http://linklift.de")

sleep(5000)
;_ScreenCap_Capture(@DesktopDir&"me.jpg")
; Full screen capture
_ScreenCap_Capture("c:\full.bmp")

; Region capture
_ScreenCap_Capture("c:\part1.bmp", 0, 0, 300, 400)

; Waiting for user to close the window
While 1
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_Button_Home
            $oIE.navigate("http://linklift.de")
        Case $msg = $GUI_Button_Back
            $oIE.GoBack
        Case $msg = $GUI_Button_Forward
            $oIE.GoForward
        Case $msg = $GUI_Button_Stop
            $oIE.Stop
    EndSelect
    
Wend

GUIDelete ()

Exit

What I want to do is take a screenshot of the $GUIActiveX window. is that possible? Also with the above code I get the following error at the first call to screencap:

C:\PROGRA~2\AutoIt3\Include\A3LWinAPI.au3 (1009) : ==> AutoIt has encountered a fatal crash as a result of:

Unable to execute DLLCall.:

$aResult = DllCall("Kernel32.dll", "int", "FormatMessageA", "int", $iFlags, "hwnd", $pSource, "int", $iMessageID, "int", $iLanguageID, "ptr", $pBuffer, "int", $iSize, "ptr", $vArguments)

too bad. :/

If you'd read the instructions and use the latest version of AutoIt, you wouldn't get such errors. Might want to go back to the download section and read this:

Read this before you download:

Make sure you have the latest production version of AutoIt installed before installing Auto3Lib.

It's too bad you can't read. Edited by PaulIA

Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

With all respect I downloaded the last beta, instealled and the code gives me the error I posted...

Share this post


Link to post
Share on other sites

With all respect I downloaded the last beta, instealled and the code gives me the error I posted...

The instructions tell you (in 3 different places) to install the latest production release, not the latest beta. This is the same error that people get when they're using an older version of AutoIt. If you'd do a bit of searching, you'd see I've answered this exact question probably a dozen times in the past month. But hey, what do I know? I'm just the guy who wrote the library. :)

Auto3Lib: A library of over 1200 functions for AutoIt

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