PHP抓屏函数

| |
2010/12/06 22:16 ArthurXF
* 屏幕快照
$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://blog.thepimp.net");

/* Still working? */
while ($browser->Busy) {
com_message_pump(4000);
}
$im = imagegrabwindow($handle, 0);
$browser->Quit();
imagepng($im, "iesnap.png");
?>


* IE全屏模式

$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;

$browser->Visible = true;
$browser->FullScreen = true;
$browser->Navigate("http://blog.thepimp.net");

/* Is it completely loaded? (be aware of frames!)*/
while ($browser->Busy) {
com_message_pump(4000);
}
$im = imagegrabwindow($handle, 0);
$browser->Quit();
imagepng($im, "iesnap.png");
?>


需要说明几点
1.这二种方法只能工作在windows下面,
2.黑屏解决办法--->>web 服务器(iis或apache)做为windows服务时,必须打开"允许与桌面交互"的选项.(点击服务属性->登录->勾选"允许与桌面交互".(一定要记得重起apache或其他的服务器才会有用,我已经成功,无庸质疑)
3.需要gb库版本为2.0.34(php5.2.2默认自带)
Tags: ,
PHP | 评论(0) | 引用(0) | 阅读(12630)
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]