Wednesday, September 12, 2007

Interesting in PHP

While digging through the GD section of the online PHP manual I noticed two new entries on the function list that immediately caught my eye: imagegrabscreen() and imagegrabwindow(). Upon further investigation both of these commands can be used to take screen shots of the desktop of your server, or any applications window (such as a web browser).Both commands are listed as being "Windows only" and also possibly only in CVS, but I found both of them are in the 5.2.3 standard release and compile without error. However at the moment neither appear to actually do anything other than return fully black images. The grabscreen command did indeed produce a PNG file exactly the same dimensions as my server, it just wasn't populated with anything. The grabwindow command didn't fare so well, and in attempting to launch and grab IEs current session my script just timed out. This could possibly be a simple COM issue, or perhaps the command just doesn't work properly yet.Eitherway they are both quite interesting additions to the GD section, and while Windows only I could still think of a few nice uses for them in an admin capacity (certainly of limited use on a public web site). For example if your Windows anti-virus software doesn't have command-line access to its interface, you could schedule a window grab to run each night that launched your AV and grabbed the last updated time, so you could see if it had updated itself overnight. Alternatively you could grab browser windows ala Browsercam. Or perhaps screen shots from a package like TreeSize Pro.I'm not so sure about the use of grabbing the entire server desktop, but I'm sure someone will come up with something. If you've managed to get either of these two functions to work then please comment about it.

No comments: