Instance code _php instance of PHP Imagegrabscreen and Imagegrabwindow (intercepting Web site thumbnails)

Source: Internet
Author: User
1. Intercept the entire screen screenshot
Copy Code code as follows:

<?php
$im = Imagegrabscreen ();
Imagepng ($im, "myscreenshot.png");
?>

2. Intercepting a window Capture a Windows (IE for example)
Copy Code code as follows:

<?php
$browser = new COM ("Internetexplorer.application");
$handle = $browser->hwnd;
$browser->visible = true;
$im = Imagegrabwindow ($handle);
$browser->quit ();
Imagepng ($im, "iesnap.png");
$im = Imagegrabscreen ();
?>

3. Intercept IE Content Capture a window(IE for example) but and its content!
Copy Code code as follows:

<?php
$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");
?>

4. Interception of IE Full-screen modeIE in fullscreen mode
Copy Code code as follows:

<?php
$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");
?>

This is how to use PHP com to call the IE window to open the Web page to screen, but a lot of friends to get the result is a picture of pure black, this is why?
There may be two scenarios, the first of which is that the COM component applies only to Windows servers, and the servers of other systems are not supported, because he does not have IE, and the second is not open to allow services to interact with the desktop! The second is the most common, open method is to click on the computer (My Computer)-> right-> management-> services and application-> services-> Apache (I use the Apache server)-> right key-> properties-&G T Login-> Login ID below both!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.