以下截图程序要运行在PHP5.2.2以上的环境。
//IE全屏模式
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Fullscreen = true;
$browser->Navigate("http://www.emtit.com");
/* Still working? */
while ($browser->Busy) {
com_message_pump(4000);
}
$im = imagegrabwindow($handle, 0);
$browser->Quit();
$new_img = imagecreatetruecolor(200,150);
imagecopyresampled($new_img,$im,0,0,0,0,200,150,1024,768);
imagejpeg($new_img , 'image/'.time().'.jpg',100);
imagedestroy($new_img);
?>
// 屏幕快照
$im = imagegrabscreen();
imagepng($im, "myscreenshot.png");
?>
//抓取一个窗口(IE为例)
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$im = imagegrabwindow($handle);
$browser->Quit();
imagepng($im, "iesnap.png");
$im = imagegrabscreen();
?>
// 抓取IE窗口及窗口内容(IE为例)
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Navigate("http://www.emtit.com");
/* Still working? */while ($browser->Busy) {com_message_pump(4000);}$im = imagegrabwindow($handle, 0);$browser->Quit();imagepng($im, "iesnap.png");?>