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 — ウィンドウをキャプチャする
説明
resource imagegrabwindow
( int $window_handle
[, int $client_area = 0
] )
ウィンドウあるいはそのクライアント領域のキャプチャを、 ウィンドウハンドル (COM インスタンスの HWND プロパティ) を指定して取得します。
パラメータ
- window_handle
-
HWND ウィンドウ ID。
- client_area
-
アプリケーションのクライアント領域を含めるかどうか。
返り値
成功した場合に画像リソースの ID、失敗した場合に FALSE を返します。
エラー / 例外
window_handle が無効なウィンドウハンドルである場合に E_NOTICE、 Windows API のバージョンが古すぎる場合に E_WARNING が発生します。
例
例1 imagegrabwindow() の例
ウィンドウ (ここでは IE) のキャプチャを行います。
<?php
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$im = imagegrabwindow($handle);
$browser->Quit();
imagepng($im, "iesnap.png");
imagedestroy($im);
?>
ウィンドウ (ここでは IE) の中身のキャプチャを行います。
<?php
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Navigate("http://www.libgd.org");
/* Still working? */
while ($browser->Busy) {
com_message_pump(4000);
}
$im = imagegrabwindow($handle, 0);
$browser->Quit();
imagepng($im, "iesnap.png");
imagedestroy($im);
?>
注意
注意: この関数は Windows 上でしか使用できません。
imagegrabwindow
Xeon
30-Sep-2007 03:01
30-Sep-2007 03:01
nico ->atdot
29-Sep-2007 03:37
29-Sep-2007 03: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.