1. Screenshot the entire screen Screenshot
Copy the code The code is as follows:
$im = imagegrabscreen();
imagepng($im, “myscreenshot.png”);
?>
2. Capture a window ( IE for example)
Copy code The code is as follows:
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$im = imagegrabwindow($handle);
$ browser->Quit();
imagepng($im, “iesnap.png”);
$im = imagegrabscreen();
?>
3. Capture a window (IE for example) but with its content!
Copy code The code is as follows:
$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(); ;
?>
4. Capture IE in fullscreen mode
The code is as follows:
$browser = new COM("InternetExplorer.Application"); $handle = $browser->HWND;
$browser->Visible = true;
$browser->FullScreen = true;
$browser->Navigate("http://www.jb51.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”);
?>
The above is about how to use PHP COM to call the IE window to open a webpage and take a screenshot, but many friends only get a pure black picture. Why is this?
There may be two situations. The first situation is that this COM component is only applicable to WINDOWS servers. Servers of other systems are not supported because they do not have IE browsers. The second situation is that the allowed service and desktop are not turned on. Interact! The second case is the most common. The way to open it is to click on Computer (My Computer) -> Right-click -> Management -> Services and Applications -> Services -> Apache (I use apache server myself) - > Right click-> Properties-> Login-> Login identity is below!
http://www.bkjia.com/PHPjc/825074.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/825074.htmlTechArticle1. Screenshot the entire screen Screenshot Copy the code as follows: ?php $im = imagegrabscreen(); imagepng($im , “myscreenshot.png”); ? 2. Capture a window (IE for ex...