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 — Capture une fenêtre
Description
Capture une fenêtre ou l'espace de son client, en utilisant un gestionnaire de fenêtre (propriété HWND de l'instance COM).
Liste de paramètres
- window
-
L'identifiant HWND de la fenêtre.
- client_area
-
Inclure ou non l'espace du client de la fenêtre de l'application.
Valeurs de retour
Retourne une ressource image en cas de succès, ou FALSE si une erreur survient.
Erreurs / Exceptions
Une alerte de type E_NOTICE est émise si window_handle est un gestionnaire de fenêtre invalide. Une alerte de type E_WARNING est émise si l'API Windows est trop ancienne.
Exemples
Exemple #1 Exemple avec imagegrabwindow()
Capture une fenêtre (IE par exemple).
<?php
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$im = imagegrabwindow($handle);
$browser->Quit();
imagepng($im, "iesnap.png");
?>
Capture une fenêtre (IE par exemple) mais avec son contenu.
<?php
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Navigate("http://www.libgd.org");
/* Fonctionne toujours ? */
while ($browser->Busy) {
com_message_pump(4000);
}
$im = imagegrabwindow($handle, 0);
$browser->Quit();
imagepng($im, "iesnap.png");
?>
Notes
Note: Cette fonction n'est disponible que sous Windows.
imagegrabwindow
29-Sep-2007 08:01
29-Sep-2007 08:37
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.
