This function was painfully slow when I was testing it on my machine. It took about 2 or 3 seconds for it to return an image. It also fails to work if the Apache service doesn't have access to "Interact with the desktop".
imagegrabwindow
(PHP 5 >= 5.2.2)
imagegrabwindow — Capturar una ventana
Descripción
resource imagegrabwindow
( int
$window_handle
[, int $client_area = 0
] )Captura una ventana o su área de cliente usando un gestor de ventanas (la propiedad HWND en instancia COM)
Parámetros
-
window_handle -
El ID del HWND de ventana.
-
client_area -
Incluye el área del cliente de la ventana de aplicación.
Valores devueltos
Devuelve un identificador de recurso de imagen si tiene éxito, FALSE si falló.
Errores/Excepciones
E_NOTICE es emitido si window_handle no es un
gestor de ventana válido.
E_WARNING es emitido si la API de Windows es demasiado antigua.
Ejemplos
Ejemplo #1 Ejemplo de imagegrabwindow()
Capturar una ventana (IE por ejemplo)
<?php
$navegador = new COM("InternetExplorer.Application");
$gestor = $navegador->HWND;
$navegador->Visible = true;
$im = imagegrabwindow($gestor);
$navegador->Quit();
imagepng($im, "iesnap.png");
imagedestroy($im);
?>
Capturar una ventana (IE por ejemplo) pero con su contenido
<?php
$navegador = new COM("InternetExplorer.Application");
$gestor = $navegador->HWND;
$navegador->Visible = true;
$navegador->Navigate("http://www.libgd.org");
/* ¿Todavía funciona? */
while ($navegador->Busy) {
com_message_pump(4000);
}
$im = imagegrabwindow($gestor, 0);
$navegador->Quit();
imagepng($im, "iesnap.png");
imagedestroy($im);
?>
Notas
Nota:
Esta función sólo está disponible en Windows.
Xeon ¶
5 years ago
nico ->atdot ¶
5 years ago
If you just want to take a screenshot of a website WITHOUT the ugly IE window around it, the easiest way is setting the "Fullscreen" property to TRUE.
$browser->Fullscreen = true;
This is basically the same as pressing F11 once the browser is open, so you just get the actual website.
