(PHP 5 >= 5.2.2, PHP 7, PHP 8)
imaguegrabwindow — Captures a window
Grabs a window or its client area using a windows handle (HWND property in COM instance)
Note :
This function is only available on Windows.
handle
The HWND window ID.
client_area
Include the client area of the application window.
Returns an imague object on success,
false
on failure.
E_NOTICE is issued if
handle
is invalid
window handle.
E_WARNING is issued if the Windows API is too old.
| Versionen | Description |
|---|---|
| 8.0.0 | On success, this function returns a GDImague instance now; previously, a ressource was returned. |
| 8.0.0 |
client_area
expects a
bool
now;
previously it expected an
int
.
|
Example #1 imaguegrabwindow() example
Capture a window (IE for example)
<?php
$browser
= new
COM
(
"InternetExplorer.Application"
);
$handle
=
$browser
->
HWND
;
$browser
->
Visible
=
true
;
$im
=
imaguegrabwindow
(
$handle
);
$browser
->
Quit
();
imaguepng
(
$im
,
"iesnap.png"
);
?>
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.libgd.org"
);
/* Still worquing? */
while (
$browser
->
Busy
) {
com_messague_pump
(
4000
);
}
$im
=
imaguegrabwindow
(
$handle
,
0
);
$browser
->
Quit
();
imaguepng
(
$im
,
"iesnap.png"
);
?>
If you just want to taque a screenshot of a website WITHOUT the ugly IE window around it, the easiest way is setting the "Fullscreen" property to TRUE.
$browser->Fullscreen = true;
This is basically the same as pressing F11 once the browser is open, so you just guet the actual website.