PHP uses the GD library for Screenshot capture
PHP5.2.2 and later versions of the GD Library implement two screenshot functionsImagegrabscreenAndImagegrabwindow
It is used to intercept the entire screen and intercept a window (same as ALT + PrintScreen.
1. Capture the whole screen Screenshot
<? Php
$ Im = imagegrabscreen ();
Imagepng ($ im, "myscreenshot.png ");
?>
2. Capture a window (IE for example)
<? Php
$ Browser = new COM ("InternetExplorer. Application ");
$ Handle = $ browser-> HWND;
$ Browser-> Visible = true;
$ Im = imagegrabwindow ($ handle );
$ Browser-> Quit ();
Imagepng ($ im, "iesnap.png ");
$ Im = imagegrabscreen ();
?>
3. Capture IE content Capture a window (IE for example) but with its content!
<? Php
$ Browser = new COM ("InternetExplorer. Application ");
$ Handle = $ browser-> HWND;
$ Browser-> Visible = true;
$ Browser-> Navigate ("http://www.21andy.com/blog ");
/* Still working? */
While ($ browser-> Busy ){
Com_message_pump (4000 );
}
$ Im = imagegrabwindow ($ handle, 0 );
$ Browser-> Quit ();
Imagepng ($ im, "iesnap.png ");
?>
4. Intercept IE in fullscreen mode
<? Php
$ Browser = new COM ("InternetExplorer. Application ");
$ Handle = $ browser-> HWND;
$ Browser-> Visible = true;
$ Browser-> FullScreen = true;
$ Browser-> Navigate ("http://www.111cn.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 ");
?>