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)