简体   繁体   English

如何在不破坏死键支持的情况下使用ToUnicode?

[英]How can I use ToUnicode without breaking dead key support?

A similar question has already been asked, so I'm not going to waste time re-explaining it, an existing discussion can be found here: ToAscii/ToUnicode in a keyboard hook destroys dead keys 类似的问题已经被提出,所以我不打算浪费时间重新解释它,现在的讨论可以在这里找到: 键盘钩子中的ToAscii / ToUnicode破坏死键

The reason I'm posting a new question however is that I seem to have come across a 'solution', but I'm not quite sure how to implement it. 我发布一个新问题的原因是我似乎遇到了一个“解决方案”,但我不太确定如何实现它。

This blog post seems to propose a solution to the problem of ToUnicode killing dead-key support: http://www.siao2.com/2005/01/19/355870.aspx 这篇博文似乎提出了ToUnicode杀死死键支持问题的解决方案: http//www.siao2.com/2005/01/19/355870.aspx

However I'm not sure how to implement the suggested solution. 但是,我不确定如何实施建议的解决方案。 A push in the right direction would be greatly appreciated. 推动正确的方向将非常感激。

To be clear, the part I'm referring to is this: 需要说明的是,我指的是这个:

There are two ways to work around this: 有两种方法可以解决这个问题:

1) You can keep calling ToUnicode with the same info until it is cleared out and then call it one more time to put the state back where it was if you had never typed anything, or 1)您可以继续使用相同的信息调用ToUnicode,直到它被清除,然后再次调用它以将状态恢复到原来的状态,如果您从未输入任何内容,或者

2) You can load all of the keyboard info ahead of time and then when they type information you can look up in your own info cache what the keystrokes mean, without having to call APIs later. 2)您可以提前加载所有键盘信息,然后当他们键入信息时,您可以在自己的信息缓存中查找击键的含义,而无需稍后调用API。

I'm not quite sure how to do either of those things (keyboards and internationalization are far from my strong point), so any help would be greatly appreciated. 我不太确定如何做这些事情(键盘和国际化远非我的强项),所以任何帮助将不胜感激。

Thanks 谢谢

The first part of the answer is entirely information-free. 答案的第一部分完全没有信息。 However, the second part does make sense. 但是,第二部分确实有意义。 ToUnicode() should have been a pure function, which merely acts as a lookup. ToUnicode() 应该是一个纯函数,它只是作为一个查找。 However, it isn't. 但事实并非如此。 But you can call it repeatedly for all expected inputs, store those in your own lookup table and access that. 但是您可以针对所有预期的输入重复调用它,将它们存储在您自己的查找表中并访问它。

I'd recommend that Microsoft adds a lookDontTouch flag to the wFlags parameter; 我建议Microsoft在wFlags参数中添加一个lookDontTouch标志; that would be a trivial non-breaking API fix. 这将是一个简单的非破坏API修复。

If you broaden your search to include key logging , you might get some answers. 如果您扩大搜索范围以包含密钥记录 ,则可能会得到一些答案。 The method presented in the link is extremely cumbersome compared to ToUnicode , but it works. ToUnicode相比,链接中显示的方法非常麻烦,但它有效。 It evolves around finding the current active keyboard layout from the registry and then manually load and parse the proper DLL. 它围绕从注册表中查找当前活动的键盘布局,然后手动加载和解析正确的DLL。

As a note of warning, I've seen the loading part fail miserably on 64-bit Windows. 作为一个警告,我已经看到加载部分在64位Windows上失败了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在不读取/写入密钥文件的情况下使用crypto ++? - How can I use crypto++ without read/write a key file? 我如何在C ++控制台中编写文本而又不中断行 - How can i write text in c++ console without breaking the lines 如何在不破坏现有代码的情况下向函数添加输出参数? - How can I add an output parameter to a function without breaking existing code? (C++) 如何在控制台行的末尾打印一条长消息而不破坏单词? - (C++) How can I print a long message without breaking words at the end of a console line? VS2017:如何在不破坏我设置的过滤器的情况下在.vcxproj中编写每个文件选项? - VS2017: How can I write per-file options in .vcxproj, without breaking the filters I've set up? 我应该使用 Boost.GIL 还是它已经死了? - Should I use Boost.GIL or is it dead? 如何在 std::map 中使用结构作为键? - How can I use a struct as key in a std::map? 如何在 C++ 中使用自定义类型作为映射的键? - How can I use a custom type as key for a map in C++? 我如何使用cryptimportkey函数导入私钥来加密数据相同的结果使用导入的密钥 - how can i use cryptimportkey function import a private key to encrypt data same result use imported key 如何在没有竞争条件的情况下将QFutureWatcher与QtConcurrent :: run()一起使用 - How can I use a QFutureWatcher with QtConcurrent::run() without a race condition
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM