imagegrabwindow打开两个窗口并抓取错误的屏幕截图

时间:2020-12-31 19:18:31

I am wanting to grab a screenshot using PHP and on my local Vista machine. For starters I just wanted to get the standard example set up:

我想用PHP和我的本地Vista机器抓取截图。对于初学者我只想设置标准示例:

$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Navigate("http://www.libgd.org");
/* Still working? */
while ($browser->Busy) {
    com_message_pump(4000);
}
$im = imagegrabwindow($handle, 0);
$browser->Quit();
imagepng($im, "iesnap.png");
imagedestroy($im);

When I run the script (command line), it opens up two IE windows. One (the first) remains empty and the second goes to the designated URL. The screenshot is taken, saved and the first window gets closed. The window that went to the URL remains open. The screenshot itself taken from the first, empty IE window.

当我运行脚本(命令行)时,它会打开两个IE窗口。一个(第一个)保持为空,第二个转到指定的URL。屏幕截图被拍摄,保存并关闭第一个窗口。转到URL的窗口仍然打开。截图本身取自第一个空的IE窗口。

How can I target the second window?

我如何定位第二个窗口?

-- EDIT #1 -- After all the help from Breakthrough it still does not work on my system. :( For now I am going to try to work it out with: http://iecapt.sourceforge.net/ or http://cutycapt.sourceforge.net/ which both seem to work during preliminary testing. I am still interested in a "real" PHP solution.

- 编辑#1 - 在突破的所有帮助之后,它仍然无法在我的系统上运行。 :(目前我将尝试使用:http://iecapt.sourceforge.net/或http://cutycapt.sourceforge.net/,它们似乎都在初步测试期间工作。我仍然感兴趣一个“真正的”PHP解决方案。

2 个解决方案

#1


0  

What version of IE are you using (7 or 8)?

您使用的是什么版本的IE(7或8)?

What happens when you set the Visible property of $browser after navigating to the page?

导航到页面后设置$ browser的Visible属性会发生什么?

-- EDIT IN RESPONSE TO COMMENT --

- 编辑回应评论 -

Go to Start -> Run, and type in "services.msc"

转到开始 - >运行,然后输入“services.msc”

In the list, ensure that the Server Service and Remote Procedure Call (RPC) services are both set to automatic. Also, make sure that the Remote Procedure Call (RPC) Locator service is set to manual...

在列表中,确保将服务器服务和远程过程调用(RPC)服务都设置为自动。此外,请确保将远程过程调用(RPC)定位器服务设置为手动...

Try that and let us know what happens. :)

试试看,让我们知道会发生什么。 :)

-- EDIT #2 --

- 编辑#2 -

In your php.ini file, make sure that com.allow_dcom is set to "1".

在php.ini文件中,确保com.allow_dcom设置为“1”。

#2


0  

For me also doesn't work, but I managed it to work but have no idea when it is, I guess it has to do with that message that comes up from interactive Serivces Detection, if I click view message and do something in internet explorer screen it got once screenshot, all in all one big S***

对我来说也不起作用,但我设法让它工作,但不知道它是什么时候,我想它与交互式Serivces Detection产生的那条消息有关,如果我点击查看消息并在Internet Explorer中做一些事情屏幕它有一次截图,所有一个大S ***

#1


0  

What version of IE are you using (7 or 8)?

您使用的是什么版本的IE(7或8)?

What happens when you set the Visible property of $browser after navigating to the page?

导航到页面后设置$ browser的Visible属性会发生什么?

-- EDIT IN RESPONSE TO COMMENT --

- 编辑回应评论 -

Go to Start -> Run, and type in "services.msc"

转到开始 - >运行,然后输入“services.msc”

In the list, ensure that the Server Service and Remote Procedure Call (RPC) services are both set to automatic. Also, make sure that the Remote Procedure Call (RPC) Locator service is set to manual...

在列表中,确保将服务器服务和远程过程调用(RPC)服务都设置为自动。此外,请确保将远程过程调用(RPC)定位器服务设置为手动...

Try that and let us know what happens. :)

试试看,让我们知道会发生什么。 :)

-- EDIT #2 --

- 编辑#2 -

In your php.ini file, make sure that com.allow_dcom is set to "1".

在php.ini文件中,确保com.allow_dcom设置为“1”。

#2


0  

For me also doesn't work, but I managed it to work but have no idea when it is, I guess it has to do with that message that comes up from interactive Serivces Detection, if I click view message and do something in internet explorer screen it got once screenshot, all in all one big S***

对我来说也不起作用,但我设法让它工作,但不知道它是什么时候,我想它与交互式Serivces Detection产生的那条消息有关,如果我点击查看消息并在Internet Explorer中做一些事情屏幕它有一次截图,所有一个大S ***