如何用c#制作一个类似谷歌音译桌面应用程序的应用程序

发布于 2024-09-05 01:37:06 字数 328 浏览 7 评论 0原文

只需要拦截键盘输入、转换它并将其发送回来的功能。例如,如果用户按 ai 会喜欢发送 e 等。

要使接受键盘输入的应用程序修改它并将其发送到活动窗口(可能是诸如 Word、Excel、记事本、Windows 屏幕等应用程序。 该功能就像 Windows 上的 google 音译应用程序一样。 我想用 c# 来做。 我认为这涉及挂钩键盘并将按键(如 vb 中的 sendkey)发送到当前窗口。 其工作原理与 Google 音译 类似。但是转换的逻辑却截然不同。

Just the functionality of intercepting the keyboard entry , transforming it and sending it back is required.eg if user press a i wold like to send e etc.

To make a application that accepts the entry from keyboard modify it and send it to the active window (may be application like word, excel,notepad windows screens ) etc.
The feature is just like google's transliteration application for windows .
I would like to do it in c# .
I think this involves hooking in the keyboard and sending keys (like sendkey in vb) to the current window.
The working is just like Google transliteration .However the logic for transformation is quite different.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

じ违心 2024-09-12 01:37:06

我不确定问题到底是什么,所以它可能会因为太模糊而被关闭。但是,听起来您必须缓冲所有击键,将单词或短语异步发送到某些服务进行音译,然后使用您提到的 sendkeys 之类的东西将它们推回键盘缓冲区。问题是,如果你的应用程序有焦点,我们不知道用户希望音译文本显示在哪里,而如果像 Word 这样的应用程序有焦点,它将同时接收到真实的击键和音译文本,这将导致然后混合在一起(一团糟)。似乎最好只是音译文本块而不是试图干扰键盘缓冲区 - 此外,退格键、撤消等几乎不可能实现。

I'm not sure what the question is exactly, so it may get closed for being too vague. However, it sounds like you'll have to buffer all of the keystrokes, send words or phrases to some service asynchronously to be transliterated and then push them back into keyboard buffer with something like sendkeys as you mentioned. The problem is that if your app has focus, we don't know where the user wants the transliterated text to show up, and if the app such as Word has focus, it will receive both the real keystrokes and the transliterated text, which will then be mixed together (a mess). Seems better just to transliterate chunks of text rather than trying to interfere with the keyboard buffer - besides, backspace, undo, etc. will be nearly impossible to honor.

孤芳又自赏 2024-09-12 01:37:06

您需要编写一个使用 Windows 文本服务框架或旧版 IME 框架的 dll。
当您激活它时,该 dll 将被加载到语言栏中;您的代码已经实现了 TSF 或 IME 框架所需的一组 API,将获取按键事件,然后您可以将其传递给您的代码,代码会对其进行翻译并将字符串传递回给您。然后您可以输入另一个实现的 API到 Windows 应用程序的当前文本编辑器。

You need to write a dll which uses Windows Text Service framework or legacy IME framework .
This dll will get loaded into langauge bar and when you will activate it ; your code , which has implemented a set of APIS required by TSF or IME framework , will get the key event , You can then pass it to your code which translates it and passes a string back to you.Another of your implemented API can then input to the Current text editor of the windows Application.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文