摘要:本文主要向大家介绍了Windows运维之Windows下强大的截屏和模拟输入工具源码,通过具体的内容向大家展现,希望对大家学习Windows运维有所帮助。
本文主要向大家介绍了Windows运维之Windows下强大的截屏和模拟输入工具源码,通过具体的内容向大家展现,希望对大家学习Windows运维有所帮助。
要实现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<IWinRobotService> pService;
hr = pService.CoCreateInstance(__uuidof(ServiceHost) );
//get active console session
CComPtr<IUnknown> pUnk;
hr = pService->GetActiveConsoleSession(&pUnk);
CComQIPtr<IWinRobotSession> pSession = pUnk;
// capture screen
pUnk = 0;
hr = pSession->CreateScreenCapture(0,0,1024,768,&pUnk);
// get screen image data(with file mapping)
CComQIPtr<IScreenBufferStream> 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));
本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注系统运维windows频道!
您输入的评论内容中包含违禁敏感词
我知道了
请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号