PHP screen capture function for screen snapshot code sharing

Source: Internet
Author: User
Who said that screenshot capture can only be done by QQ, screen printing, and PHP? this article mainly introduces how to implement screen snapshot using the PHP screen capture function The code is as follows:
* Screen snapshot
$ Im = imagegrabscreen ();
Imagepng ($ im, "myscreenshot.png ");


* Capture a window (IE is used 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 is used as an example)

$ Browser = new COM ("InternetExplorer. Application ");
$ Handle = $ browser-> HWND;
$ Browser-> Visible = true;
$ Browser-> Navigate ("http://www.bitsCN.com ");

/* 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.bitsCN.comt ");

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

Notes
1. the two methods can only work under windows,
2. black screen solution ---> when a web server (iis or apache) is used as a windows service, you must enable the "allow desktop interaction" option. (Click "service properties"> "log on"> "allow desktop interaction ". (Remember to restart apache or other servers to make it useful. I have succeeded and have no doubt)
3. the version of the gb library is 2.0.34 (php5.2.2 comes with it by default)

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.