c语言如何编写截屏程序

Here's a screencast demoing writing Managed .NET Plugins for the Optimus Mini Three Keyboard.

这是一个截屏视频演示,为Optimus Mini三键盘编写了托管.NET插件

I'm a fan of the Optimus Mini-Three Keyboard for its potential. It's a harbinger of things to come, like someday a complete keyboard with screens for keys. Their hardware is wonderful. But, as a design shop with a specialization in hardware, not software, their software plugin model leaves much to be desired.

我喜欢Optimus迷你三键盘的潜力。 这是即将发生的事情的预兆,例如总有一天,一个带有按键屏幕的完整键盘。 他们的硬件很棒。 但是,作为一家专门从事硬件而非软件的设计商店,他们的软件插件模型还有很多不足之处。

When I did my video on an Optimus Mini Three post in managed code, I ended up P/Invoking into their library, bypassing their plugin model and opting instead for a command line experience. Bummer, right?

当我在托管代码的Optimus Mini Three帖子中制作视频时,我最终将P / Invoking到了他们的库中,绕过了他们的插件模型,而是选择了命令行体验。 兄弟,对吗?

The Optimus Configurator is pretty, to be sure, but it's programming model is obtuse and trapped in the C++ world. And not the nice OOP C++ world, the nasty part of that world.

可以肯定的是, Optimus Configurator很漂亮,但是它的编程模型是呆板的,被困在C ++世界中。 并不是很好的OOP C ++世界,而是那个世界的讨厌部分。

The "implement these dozen virtual methods that tunnel strings via magic indexes" world:

“实现通过魔术索引传送字符串的十几个虚拟方法”世界:

virtual BOOL Paint(int button, HDC hdc) = 0;// to collect INFO_* values from plugin
virtual LPARAM GetInfo(int index) = 0;
 virtual BOOL Paint( int button, HDC hdc) = 0;// to collect INFO_* values from plugin
virtual LPARAM GetInfo( int index) = 0;

.csharpcode, .csharpcode pre {font-size: small;color: black;font-family: consolas, "Courier New", courier, monospace;background-color: #ffffff;/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt {background-color: #f4f4f4;width: 100%;margin: 0em; } .csharpcode .lnum { color: #606060; }  Meh. When your unmanaged C++ plugin gets called, the configuration app will call your GetInfo at least 20 times, passing in different magic numbers to get information about your plugin like name, webpage, version, etc. Not only are there these internal semantics to grok, there's a whole get/setProperties state bag thing to manage as well.

.csharpcode, .csharpcode pre {font-size: small;color: black;font-family: consolas, "Courier New", courier, monospace;background-color: #ffffff;/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt {background-color: #f4f4f4;width: 100%;margin: 0em; } .csharpcode .lnum { color: #606060; } 嗯当您的非托管C ++插件被调用时,配置应用会调用您的GetInfo至少20次,并传递不同的幻数以获取有关您的插件的信息,例如名称,网页,版本等。不仅这些内部语义值得关注,还有一个完整的get / setProperties状态包要管理。

It's a common pattern for plugins though, especially when you as the host want to provide persistence to your plugins. The Windows Live Writer plugin model is similar...I had to maintain state for my Insert Amazon Links WLW Plugin via the same pattern.

但是,这是插件的常见模式,尤其是当您作为主机要为插件提供持久性时。 Windows Live Writer插件模型类似...我必须通过相同的模式来维护我的Insert Amazon Links WLW插件的状态。

On the other hand, the Paint stuff is very clever, actually. You get an HDC (handle to a device context) passed in, you paint to it, and they handle getting the resulting image over to the Optimus via their USB to Serial Bridge.

另一方面,Paint的东西实际上非常聪明。 您将传入一个HDC(到设备上下文的句柄),对其进行绘制,然后他们将生成的图像通过USB到串行桥传输到Optimus。

But, their plugins aren't managed code, and I believe that this more difficult model explains the fact that while the device is selling well, there are only (as of the writing of this post) three 3rd party plugins.

但是,他们的插件不是托管代码,我相信这个更困难的模型可以解释一个事实,即该设备销售情况良好,但截至本文撰写之时,只有三个第三方插件。

Harald Röxeisen went off (he says after reading my post...Cool!) and has released an alpha of a .NET library for Optimus Support. However, rather than supporting managed plugins in the Optimus Configurator, he's written his own configurator from scratch in .NET, and built a plugin model on top of that. It's basic, but a fantastic start. He proves my point about writing plugins, as even his alpha include THREE all new plugins written against his managed API. Excellent.

HaraldRöxeisen离开了(他读完我的文章……很酷!他说),并发布了Optimus支持的.NET库的alpha版本。 但是,他不是在Optimus Configurator中支持托管插件,而是在.NET中从头开始编写了自己的配置器,并在此基础上构建了一个插件模型。 这是基本的,但很棒的开始。 他证明了我关于编写插件的观点,因为即使他的Alpha也包括针对他的托管API编写的所有三个新插件。 优秀的。

For me, I've done the inverse of Harald, and got managed plugins to work inside the existing configurator. After my last post, I got great ideas from Matt Davis of DocumentCommand and Jason Copenhaver. Jason's was managed/unmanaged C++ that would provide a bridge, and Matt's used COM and the .NET COM Interop stuff as a middleman. For me, Matt's was faster as I know that stuff pretty well.

对我来说,我做过Harald的逆事,并获得了可管理的插件来在现有配置器中工作。 在上一篇文章发表之后,我从DocumentCommand的Matt Davis和Jason Copenhaver获得了很棒的想法。 杰森(Jason)的托管/非托管C ++提供了桥梁,马特(Matt)则使用COM和.NET COM Interop作为中间人。 对我来说,Matt的速度更快,因为我知道这些东西相当不错。

Here's the general idea...Matt's shim implements the C++ virtuals that the configurator expects and calls CoCreateInstance on a known ProgId, in my example it's "Optimus.Nothing." Could be whatever. You'll need one shim and one ProgId per managed plugin as far as I can see. That call to CoCreateInstance is actually activating a .NET assembly that is implementing Matt's COM interface (that we might want to make even more COMish) created via TlbImp. Since we're .NET, the runtime and we get loaded, and wackiness ensues.

这是一般的想法... Matt的填充程序实现了配置程序期望的C ++虚拟函数,并在已知的ProgId上调用CoCreateInstance,在我的示例中为“ Optimus.Nothing”。 可能是什么。 据我所知,每个托管插件将需要一个垫片和一个ProgId。 对CoCreateInstance的调用实际上是在激活.NET程序集,该程序集实现了通过TlbImp创建的Matt的COM接口(我们可能想制作更多COMish)。 由于我们是.NET,因此需要运行时和加载,随之而来的是古怪。

We're in a no-man's land between managed and unmanaged code (and I'm sure we're leaking like a sieve) but we do things like Marshal.StringToHGlobalAnsi(managedString).ToInt32(); and

我们处于托管和非托管代码之间的无人区(而且我敢肯定我们会像筛子一样泄漏),但我们会执行Marshal.StringToHGlobalAnsi(managedString).ToInt32();之类的事情

static int i = 0;
public int Paint( int button, IntPtr HDC)
{i++;DebugWrite(button);using (Graphics g = Graphics.FromHdc(HDC)){Brush b = ((i % 2 == 0) ? Brushes.Blue : Brushes.Red);g.FillRectangle(b, new Rectangle(0, 0, 96, 96));}if (i > 100) i = 0;return 1;
}

...for example. But, happily, we seem to not be noteworthy because the Mini Configurator loads us just fine.

...例如。 但是,令人高兴的是,我们似乎并不值得一提,因为Mini Configurator可以很好地加载我们。

I've approached Harald and perhaps we'll figure out a better bridge for .NET plugins where I could write a plugin that supports his managed API and use it in either his configurator, or the original configurator from Optimus. If I'm going to be promoting writing these plugins, we'll want the interface to hide a lot of the dispatchy stuff, more like the plugin model Bryan Batchelder and I did for the USB Security Key Fobs.

我接触过Harald,也许我们会为.NET插件找到一个更好的桥梁,我可以编写一个支持他的托管API的插件,并在他的配置器或Optimus的原始配置器中使用它。 如果我要促进编写这些插件的工作,我们将希望该界面隐藏很多派发性的东西,更像是插件模型Bryan Batchelder ,我为USB Security Key Fobs做过。

In Harald's .NET configurator, the abstract class you derive from to create a "Harald plugin" is very clean and includes new features like OnKeyHold and OnKeyDoublePress that the Optimus software doesn't make easy. He also, of course, uses BCL types like Bitmap over HDCs.

在Harald的.NET Configurator中,您从中创建“ Harald插件”的抽象类非常干净,并且包含了诸如OnKeyHold和OnKeyDoublePress之类的新功能,而Optimus软件并不容易。 当然,他还使用BCL类型,例如基于HDC的位图。

 public abstract class OptimusMiniPlugin
{protected OptimusMiniPlugin();public abstract void Initialize();public virtual void OnKeyDoublePress();public virtual void OnKeyDown();public virtual void OnKeyHold();public virtual void OnKeyPress();public virtual void OnKeyRelease();public virtual void OnKeyUp();public abstract void Repaint();public void RequestNextUpdate(TimeSpan interval);public abstract void Terminate();public abstract void Update();public void UpdateImage(Bitmap image);
}

I'm excited to see the possibilities for this little device. Perhaps between my stuff and Haralds (and someone elses?) we can get a Windows Vista Side Show driver working for this thing...probably time for YAGCP (Yet Another Google Code Project). For now, here's what I've got. I'll do a Coding4Fun article on this in much more detail this weekend perhaps, for now, it's just scribbles and it works on my system. ;)

我很高兴看到这种小型设备的可能性。 也许在我和Haralds(还有其他人?)之间,我们可以得到Windows Vista Side Show驱动程序来工作,这可能是YAGCP(另一个Google代码项目)的时间。 现在,这就是我所拥有的。 我可能会在本周末对此进行更详细的Coding4Fun文章,到目前为止,这只是涂鸦,并且可以在我的系统上使用。 ;)

I wonder if the Optimus Keyboard folks care...I hope so. I'm convinced that writing managed plugins is easier than unmanaged (on Windows or in Mono). Is this even worth debating?

我想知道擎天柱键盘的人是否在乎...我希望如此。 我坚信(在Windows或Mono中)编写托管插件要比非托管插件容易。 这甚至值得辩论吗?

翻译自: https://www.hanselman.com/blog/screencast-writing-managed-net-plugins-for-the-optimus-mini-three-keyboard

c语言如何编写截屏程序

c语言如何编写截屏程序_截屏视频:为Optimus Mini三键盘编写托管的.NET插件相关推荐

  1. 用Python编写录屏程序将播放的视频用截屏方法转换为多帧图像编辑后保存为GIF格式动图文件

    有时编写游戏后发博文,为使读者有一个直观的游戏效果,会把游戏运行动画转换GIF格式动图发到博文中.本文介绍如何用python PIL库ImageGrab.grab()函数截屏,编写录屏程序,将视频转换 ...

  2. 编写start脚本程序_使用可编写脚本的终结点遍历REST应用程序

    编写start脚本程序 我喜欢JDK附带ScriptEngine的事实. 当您要评估服务器环境中已经部署的应用程序并进行故障排除时,它非常灵活. 将此REST端点添加到Java EE应用程序中,它将使 ...

  3. mac os 录屏快捷键_录屏软件哪个好?赶紧收藏录屏好用方法

    录屏软件哪个好?你是否遇到过需要记录手机或者电脑屏幕的时候,就像是打着游戏.看着剧,突然想要记录此时屏幕上的内容.其实很多的场景都可以使用录屏软件来记录屏幕上的内容,像是工作.学习.娱乐上的内容.那有 ...

  4. android大屏适配_大屏开创者三星Note系列,也要被更大屏的折叠屏手机取代了

    临近年关,各个手机厂商们的旗舰产品也都发布的差不多了,发布会数量也在逐渐减少,紧随而来的就是一年一度的手机曝光大赛了,关于明年旗舰产品的信息也开始逐渐浮出水面. 其中一条关于三星旗舰的曝光信息则比较特 ...

  5. 安卓熄屏录像_锁屏摄像app下载-锁屏摄像 安卓版v5.1.0-PC6安卓网

    很多用户在寻找锁屏摄像的软件下载,锁屏摄像app就是这样一款锁屏摄影软件,下载锁屏摄像app并开启后,用户无需时刻开启手机屏幕也能帮你记录身边的美好生活. 软件介绍 锁屏摄像app是一款好用的摄影软件 ...

  6. uni-app技术分享| uni-app转小程序_实时音视频

    微信小程序 实现实时音视频与 uniapp 转码成微信小程序 实现实时音视频两者是一样的,区别仅仅是一个是原生小程序一个是 uniapp 转码成小程序 本文使用uniapp转码成小程序实现音视频通话 ...

  7. removelogo使用方法_怎么给视频去水印?这三种方法简单又高效

    不管是做新媒体工作,还是从事视频剪辑,都会跟视频打交道,需要下载和用到一些视频,很多时候也会遇到视频上有水印的情况,需要去除水印才能使用,下面就给大家带来三种去除视频水印的方法,下面一起来看吧. 1. ...

  8. python用一行代码编写一个回声程序_利用Python实现一个WC程序

    项目要求 wc.exe 是一个常见的工具,它能统计文本文件的字符数.单词数和行数.这个项目要求写一个命令行程序,模仿已有wc.exe 的功能,并加以扩充,给出某程序设计语言源文件的字符数.单词数和行数 ...

  9. java编写的王八程序_利用JAVA多线程技术模拟龟兔赛跑.doc

    利用JAVA多线程技术模拟龟兔赛跑 摘要:该文介绍了利用JAVA语言的多线程技术,对"龟兔赛跑"寓言故事的模拟.从模拟程序的具体设计思路,到详细的实现过程,将技术的应用融入到一个有 ...

最新文章

  1. mysql通过查看跟踪日志跟踪执行的sql语句
  2. 2018全球技术展望报告
  3. Ubuntu 安装 opencv-nonfree
  4. 转:Python: 什么是*args和**kwargs
  5. 基于鸿蒙Hi3861和华为云平台的烟雾报警器(附源码)
  6. oracle中master实例,Oracle10g/11g RAC数据库中的Master实例、Owner实例和Past Image的概念PART2...
  7. 【Elasticsearch】elasticsearch 索引 详解 index
  8. hdu-1711(hash)
  9. 性能测试--jmeter中XPath断言【10】
  10. 将rgba图片信息转换为bmp图片文件
  11. VCS仿真 Failed to obtain license...
  12. 实现自动化测试,首先不是一个技术问题
  13. 关于聊天室文字聊天(ListView 显示数据变化后滚动到最底部 )
  14. 使用Jcom组件操作Visio批量导出图片
  15. 除中国中医药数据库官网外-必备5个其它常用中国中医药数据库
  16. c语言字符串md5加密解密,.net core使用MD5加密解密字符串
  17. mysql is running but_MySQL: mysql is not running but lock exists 的解决方法
  18. C语言编程>第十一周 ⑤ 请编写一个函数,用来删除字符串中的所有空格。
  19. 美国专利法中方法权要(method)直接侵权的考量
  20. html div图片垂直居中,css如何让img垂直居中

热门文章

  1. 同样是站在互联网创业风尖浪口,为何马化腾成功了,而ofo却步履维艰
  2. 通过3D-MAX制作三维地图模型
  3. 迅为IMX8MM开发板Yocto系统使用Gstarwmra播放音频和视频
  4. 流程图制作用什么软件?这些软件值得你尝试一下
  5. Ubuntu16.04系统桌面定制
  6. Data Matrix码的使用
  7. Python 吃饭没人付钱??/ 怎么可能 一个小游戏决定 刺激开心
  8. 从日常开发说起,浅谈HTTP协议是做什么的。
  9. 远控木马中的VIP:盗刷网购账户购买虚拟礼品卡
  10. 记录一次体现前端工具仔综合实力的实际操作