Windows下强大的截屏和模拟输入工具源码

WinRobot@github

要实现Windows的桌面截图功能,网上能找到很多源码,实现也不是很困难。但如果希望截图功能有很强的可用性,应付各种情况,却也不容易,有很多坑要填。

这里介绍的开源代码WinRobot@github,主要有以下优点:

  • 这些代码并不是为了展示而实现的简单demo,而是拥有良好设计和测试的可用于生产环境的代码

  • 能够截取Winlogon、UAC、屏保、DirectShowOverlay的图像

  • 高性能、使用进程间共享内存的方式尽量避免截图时数据的copy,在常规配置PC上能达到25fps

  • 支持java,且兼容java.awt.Robot接口

  • 支持Windows 2000及以上平台,支持32、64位系统

示例

C++

#ifdef _WIN64
#import "WinRobotCorex64.dll" raw_interfaces_only, raw_native_types,auto_search,no_namespace
#import "WinRobotHostx64.exe" auto_search,no_namespace
#else
#import "WinRobotCorex86.dll" raw_interfaces_only, raw_native_types,auto_search,no_namespace
#import "WinRobotHostx86.exe" auto_search,no_namespace
#endif

CComPtr pService;
hr = pService.CoCreateInstance(__uuidof(ServiceHost) );

//get active console session
CComPtr pUnk;
hr = pService->GetActiveConsoleSession(&pUnk);
CComQIPtr pSession = pUnk;

// capture screen
pUnk = 0;
hr = pSession->CreateScreenCapture(0,0,1024,768,&pUnk);

// get screen image data(with file mapping)
CComQIPtr pBuffer = pUnk;
CComBSTR name;
ULONG size = 0;
pBuffer->get_FileMappingName(&name);
pBuffer->get_Size(&size);
CFileMapping fm;
fm.Open(name,size,false);
// do something with fm...

JAVA

import com.caoym.WinRobot;
//...
WinRobot robot;
BufferedImage screen = robot.createScreenCapture(new Rectangle(0, 0, 1024, 768));

你可能感兴趣的:(c++,windows,远程控制,桌面截图,屏幕截图)