问题描述
我正在使用下面的JAVA代码捕获远程计算机的桌面
I am using the below JAVA code to capture the desktop of a remote machine
Robot robot = new Robot();
BufferedImage screenShot = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
ByteArrayOutputStream imageBytes = new ByteArrayOutputStream();
ImageIO.write(screenShot, "PNG", imageBytes);
return imageBytes.toByteArray();
但是,当最小化或断开与远程计算机的终端会话时,捕获的图像为空白.感谢您在解决问题方面的帮助,至少在最小化的情况下.
However the captured image is blank, when the terminal session to the remote machine is either minimized or disconnected. I appreciate your help in resolving the issue, at the very least the minimized scenario.
配置:运行Windows 7的物理机和运行Windows Server 2008 R2的虚拟机存在相同的问题.
Configuration:I have the same issues with a physical machine running windows 7 and a virtual machine running windows server 2008 R2.
来自MSDN的更多见解:
More insights from MSDN:
与RDP断开连接时为什么会出现黑屏? http://msdn.microsoft.com/en-us/library/aa383015%28VS.85%29.aspx
这是我尝试使事情正常进行的尝试,但以下方法均无济于事:
当RDP窗口最小化时如何获取数据?您可以强制RDP显示驱动程序在最小化时发送数据,请尝试以下步骤,让我知道它的运行方式:1)添加以下密钥HKEY_LOCAL_MACHINE \ Software \ Microsoft \ Terminal Server Client \创建了一个新的DWORD值,并将其命名为RemoteDesktop_SuppressWhenMinimized.指定2作为值数据.
How to get data when RDP window minimized ? You can force the RDP display driver to send data when minized, try these steps and let me know how it goes: 1) Add the following keyHKEY_LOCAL_MACHINE\Software\Microsoft\Terminal Server Client\ Created a new DWORD value and named it RemoteDesktop_SuppressWhenMinimized. Specified 2 as the value data.
注意:还尝试将注册表项添加到HKEY_LOCAL_MACHINE \ Software \ Wow6432Node \ Microsoft \ Terminal Server Client \2)禁用位图缓存( http://technet.microsoft. com/en-us/library/cc737325(WS.10).aspx )在远程桌面连接"窗口中,单击选项".
Note: Also tried adding the registry key to HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Terminal Server Client\ 2) Disable bitmap caching (http://technet.microsoft.com/en-us/library/cc737325(WS.10).aspx)In the Remote Desktop Connection window, click Options.
在体验"选项卡上,确认已选中位图缓存"复选框.或者,要禁用位图缓存,请清除位图缓存"复选框
On the Experience tab, verify that the Bitmap caching check box is selected. Or, to disable bitmap caching, clear theBitmap caching check box
推荐答案
如果最小化远程桌面"窗口,则Windows会将远程会话切换到无GUI模式,并且不显示窗口和控件.结果,TestComplete(或TestExecute)将无法与被测应用程序的GUI进行交互,因为它不存在,并且您的自动GUI测试将失败.要变通解决此问题,您可以在本地计算机(启动远程桌面的位置)上更改远程桌面的注册表设置:在本地计算机上,关闭所有打开的远程桌面会话.启动注册表编辑器(regedit.exe).导航到以下注册表项之一,具体取决于您是希望仅针对当前用户还是针对计算机上的所有用户修改远程桌面设置:
If you minimize the Remote Desktop window, Windows switches the remote session to the GUI-less mode and does not display windows and controls. As a result, TestComplete (or TestExecute) will be unable to interact with the tested application’s GUI, as it does not exist and your automated GUI test will fail.To work around the issue, you can change the Remote Desktop’s registry settings on your local computer (where you launch the Remote Desktop):On your local computer, close all open Remote Desktop sessions.Launch the Registry editor (regedit.exe).Navigate to one of the following Registry keys, depending on whether you wish to modify the Remote Desktop settings only for the current user or for all users on the computer:
HKEY_CURRENT_USER \ Software \ Microsoft \ Terminal Server客户端HKEY_LOCAL_MACHINE \ Software \ Microsoft \ Terminal Server客户端创建一个名为RemoteDesktop_SuppressWhenMinimized的DWORD值并将其设置为2.
HKEY_CURRENT_USER\Software\Microsoft\Terminal Server ClientHKEY_LOCAL_MACHINE\Software\Microsoft\Terminal Server ClientCreate a DWORD value named RemoteDesktop_SuppressWhenMinimized and set it to 2.
或者您可以通过以下步骤以编程方式进行操作:
Or you can do it programmatically by following steps:
- 透明窗口
- 还原窗口
- 捕获
- 再次将其最小化
- 删除透明度
这篇关于最小化/断开连接时的终端会话在捕获桌面快照时返回黑屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!