此问题非常常见,解决方案是允许Apache interact with desktop
。所以我允许它
并重新启动Apache service
并仍然捕获黑屏
这是代码
<?php
set_time_limit(0);
$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');
?>
我在Windows 10 Pro build 10586
Xampp 3.2.1
PHP 5.6.8