如何模仿[Ctrl+鼠标左键单击]在表单中心或打开另一个程序并输入一个单词?

发布于 2024-10-10 12:43:34 字数 649 浏览 10 评论 0原文

巴比伦词典和其他一些词典允许单击任何 Windows 程序中的任何单词 并自动识别光标下的单词,并在已安装的词典中搜索该单词时立即打开词典窗口。 另一方面,您可以打开词典,输入单词并按 Enter,结果将是相同的。

有一个 Delphi 表单,其中包含文本标签,例如单词“Automaton”。

我的问题是:

如何将一个单词从我的 Delphi 应用程序直接发送到字典窗口中,就像您手动键入并按 Enter 键一样?

最好的解决方案是通过 Windows 机制发送一些消息,但如果太复杂,还有另一种解决方案,所以第二个答案:正如我所描述的,我们需要模拟一个 [Ctrl+鼠标左键] 单击表单,其中这个词显示在一个表单上[我的 Delphi 应用程序屏幕上的可视标签],确切地说,显示在该标签的某个中心像素上。

您能否给一些如何在 Delphi 中做一件事或另一件事的建议?

** 编辑: AppActivate 的问题是这样的:Babylon dict 有一个位于托盘中的守护进程部分。 在任务管理器中,应输入文本的真实窗口也被命名为“Babylon”。 因此 AppActivate('Babylon') 尝试将应用程序的非可视部分置于前面。

您对如何确定窗口句柄或应用程序的真实视觉部分有什么建议吗?在任务管理器中,我重复将视觉和非视觉部分命名为“Babylon”。

Babylon dictionary and a couple of other dictionaries allow to click on any word in any windows program
and automatically recognize the word under the cursor, and at once open the dictionary window while searching for that word in installed dictionaries.
You can on the other hand open your dictionary, type in your word and press Enter, the result will be the same.

There's a Delphi form, containing a text label, for example with the word "Automaton".

My question is:

How to send a word from my Delphi application right into the dictionary window, as if you typed it manually and pressed Enter?

The best solution is to send some message through the Windows mechanism, but if it is too complicated, there's another solution, and so the second answer: as I described, we need to model a [Ctrl+left mouse] click on a form where this word is displayed on a form [ a visual label on the screen of my Delphi application], to be exact, on some central pixel of this label.

Could you kindly give an advice how to do one thing or another in Delphi ?

** edit:
The problem with AppActivate is this: Babylon dict has a daemon part that seats in the tray.
In the task manager a real window where the text should be input also is named 'Babylon'.
So AppActivate('Babylon') tries to bring to front the non-visual part of the application.

Do you have any suggestion how to determine the windows handle or something of a real visual part of the application? In the task manager, I repeat both visual and non-visual parts are named 'Babylon'.

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

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

发布评论

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

评论(1

飘逸的'云 2024-10-17 12:43:34

我无法提供答案,只能提供一些见解和建议......

有些应用程序会“拦截”键盘和鼠标指令,如果它们被软件模仿,则本质上会“无效”它们。一般来说,您只会在适当的防病毒软件(例如卡巴斯基)中看到这种设计......但是:

一些(不是很多,但有些)程序挂钩键盘和鼠标输入的方式,作为副作用,行为相同方式。如果您已尝试了上面评论中给出的所有建议,但无法让 Babylon 触发操作,则 Babylon 的行为很可能如我所描述的那样。

如果我的怀疑是真的,那么您尝试的方法根本不可能(至少,不使用任何简单的 Pascal 代码本身...... ASM 可能能够做到这一点,但这超出了我的知识范围)。

更好的解决方案可能是做一些研究,看看以下选项是否适合您:
1) Babylon 是否有可用于连接您的应用程序的 Pipeline 或 API?
2) 您需要的 Babylon 特定功能是否可以通过作为 Babylon 一部分分发的一个(或多个)DLL 文件来访问?
3) 除了使用 Babylon 之外,还有其他方法可以满足您的需求吗?

我知道这不是一个答案(当然不是您想听到的答案),但它可能会为您指明更好的方向。

I cannot offer an answer so much as some insight and advice...

There are certain applications which "intercept" keyboard and mouse instructions, and essentially "nullify" them if they are being immitated by software. Generally-speaking, you'd only see this in proper AntiVirus software such as Kaspersky by design... however:

The way some (not many, but some) programs hook keyboard and mouse inputs, as a side-effect, behave the same way. If you have attempted all of the advice given as comments above, and cannot get Babylon to trigger an action as a result, it is likely Babylon behaves as I have described.

If what I suspect is true, then the method you are attempting is simply not possible (at least, not using any simple Pascal code on its own... ASM might be able to do it but that's beyond my knowledge).

A better solution may be to do a little research to see if any of the following options are available to you:
1) Does Babylon have a Pipeline or API you can use to interface your application(s) with it?
2) Is the particular functionality you require of Babylon accessible through one (or more) DLL files distributed as part of Babylon?
3) Is there an alternative to using Babylon for your needs?

I know it's not an answer as such (certainly not one you'd want to hear), but it may point you in a better direction.

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