Home  >  Article  >  Backend Development  >  PHP screen capture function implements screen snapshot code sharing_PHP tutorial

PHP screen capture function implements screen snapshot code sharing_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:42:34898browse

Copy code The code is as follows:

* Screenshot
$im = imagegrabscreen( );
imagepng($im, "myscreenshot.png");


* Capture a window (IE as an example)

$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$im = imagegrabwindow($ handle);
$browser->Quit();
imagepng($im, "iesnap.png");
$im = imagegrabscreen();

// Capture IE window and window content (IE as an example)

$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Navigate ("http://www.jb51.net");

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


//IE full screen mode

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

$browser->Visible = true;
$browser->FullScreen = true;
$browser->Navigate("http://www.jb51.nett");

/* 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");
?>

A few points need to be explained
1. These two methods can only work under windows,
2. Black screen solution--->>When the web server (iis or apache) is used as a windows service , the option "Allow interaction with desktop" must be turned on. (Click service properties->Login->Check "Allow interaction with desktop". (Be sure to remember to restart apache or other servers to make it useful. I have succeeded. , no doubt)
3. The required gb library version is 2.0.34 (php5.2.2 comes with it by default)

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/634426.htmlTechArticleCopy the code code as follows: ?php * Screenshot $im = imagegrabscreen(); imagepng($im, "myscreenshot .png"); * Capture a window (IE as an example) $browser = new COM("InternetExplorer.Appli...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn