以下是環境相關:
-PHP 5.2.X
-PHP GD2
1.Print screen
$im = imagegrabscreen();
imagepng($im, "myscreenshot.png");
2.取得InternetExplorer的圖片
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$im = imagegrabwindow($handle);
$browser->Quit();
imagepng($im, "iesnap.png");
3.去掉InternetExplorer的程式外框,只取得網站版面
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Fullscreen = true;
$browser->Navigate("http://www.domain.com");
/* Still working? */
while ($browser->Busy) {
com_message_pump(4000);
}
$im = imagegrabwindow($handle, 0);
$browser->Quit();
imagepng($im, "iesnap.png");
問題來了...發現並不是每次也能成功地取得圖片,上網再找相關的問題,最後找到答案,但不知道是不是完美的答案=.="(汗)
現在我們需要設定Apache,以下是相關的步驟:
1.right-click My Computer
2.select Manage/Services and Applications/Services
3.find the apache service (like Apache2) and right-click, select Properties
4.choose the Log on tab and check the 'Allow service to interact with desktop' checkbox
5.Restart Apache.
沒有留言:
張貼留言