php code doesn't work: a screen print program, who help ?
Posted: Thu Sep 25, 2008 9:58 pm
I need to print screen via php, below is the code I got through google, but it doesn't work, and I can't find out what wrong.
Code: Select all
<?php
//Screenshot
$im = imagegrabscreen();
imagejpeg($im, "myscreenshot.jpg");
//Capture a window (IE for example)
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$im = imagegrabwindow($handle);
$browser->Quit();
imagepng($im, "iesnap.png");
$im = imagegrabscreen();
//Capture a window (IE for example) but with its content!
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Navigate("http://www.baidu.com");
// Still working?
while ($browser->Busy) {
com_message_pump(4000);
}
$im = imagegrabwindow($handle, 0);
$browser->Quit();
imagepng($im, "iesnap.png");
//set IE in fullscreen mode
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->FullScreen = true;
$browser->Navigate("http://www.google.com");
// 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");
?>