I am trying to prepare desktop application using PHP Nightrain. I want to take screen shot of open window after every 10 seconds. I tried using html2canvas but it is taking screen shot of application open page. If I will open Microsoft word and work inside it that time i want screen shot of it using PHP. Is it possible using PHP? And one more thing I want to make desktop application using PHP which is OS compatible.
This cannot be done with php alone. You will need javascript to take the screenshot, convert it into a string and send it via ajax to a php script which would then save the content.
To do that you can use this library http://html2canvas.hertzen.com/. Now the magic happens in the next few lines of code:
// an example html page
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<script type="text/javascript" src="./javascripts/html2canvas.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#screenshot').on('click', function(e){
e.preventDefault();
html2canvas($('body'), {
onrendered: function(canvas){
var imgString = canvas.toDataURL();
window.open(imgString);
$.ajax({
url: '',
type: 'POST',
data: {
file: imgString
},
success: function(response){
//alert('Everything works fine.');
},
error: function(response){
//alert('Server response error.');
}
});
}
});
});
});
</script>
</head>
<body>
As far as the IE 7 & 8 support goes - google (and other giant web sites) have stated to support up to 1 version back from the latest. So, if the current version is 10, they will only support 9 and 10. I believe this is a good practice and I'm using it with my clients as well. IE < 8 is a big pain in the ... to be working with if you're developing advanced web pages. If your client still insists having IE 7 & 8 support, you may want to checkout Modernizr and html5shiv which may be able to help you bring the html5 support to IE.
Will only work on servers, check how about this:
<?php
// capture the screen
$img = imagegrabscreen();
imagepng($img, 'screenshot.png');
?>
OR
<?php
// Capture the browser window
$Browser = new COM('InternetExplorer.Application');
$Browserhandle = $Browser->HWND;
$Browser->Visible = true;
$Browser->Fullscreen = true;
$Browser->Navigate('http://www.stackoverflow.com');
while($Browser->Busy){
com_message_pump(4000);
}
$img = imagegrabwindow($Browserhandle, 0);
$Browser->Quit();
imagepng($img, 'screenshot.png');
?>
Searching is useful for a fast answer ;)