Ahk 脚本和 C++沟通

发布于 2024-10-20 19:13:43 字数 365 浏览 2 评论 0原文

我希望在 C++ 程序中使用 autohotkey 的功能。 我当前正在运行由 c++ 程序触发的脚本 - 我只是将它们作为 .bat 文件运行。这很有效,但问题是我无法将值从脚本返回到 C++ 程序。

我希望能够从脚本中读取鼠标的位置,并在我的 C++ 程序中据此做出决策。我的脚本做了相当复杂的事情 - 所以在 autohotkey 中执行此操作对我来说是最好的解决方案 - 我了解 C,但对 C++ 知之甚少。

我已阅读有关 Autohotkey .DLL 的内容 - 我知道如何触发它,但不知道如何从中读取值。如果有人可以指导我,甚至发布正在加载的 .dll 的示例代码、发送到脚本的值以及返回的值 - 我将永远感激不已!

我花了几个小时在这上面,但毫无结果!

I wish to use the functions of autohotkey within a C++ program.
I am currently running my scripts triggered by the c++ program- I just run them as a .bat file. This works well but the problem is that I cannot return values from the script to the c++ program.

I wish to be able to read the position of the mouse from the script and make decisions based upon this in my C++ program. My scripts do quite complex things- so doing this in autohotkey is the best solution for me- I have knowledge of C, but little of C++.

I have read about the Autohotkey .DLL - I know how to trigger it but not how to read values from it. If anyone could instruct me or even post example code of a .dll being loaded and a value sent to a script and a value returned- I would be eternally grateful!!

I have spent hours on this and to no avail!

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

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

发布评论

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

评论(2

暮年慕年 2024-10-27 19:13:43

我不确定该 dll,但您可以在 Autohotkey 中编写自己的应用程序并将其与 C++ 一起打包。

通信通过带有编辑控件和按钮的隐藏窗口进行。您使用一个应用程序在编辑框中设置文本,然后单击提交按钮。拥有该窗口的另一个应用程序可以处理放入编辑控件中的任何内容 - 就像传递变量一样。基本上就是这样。

查看这个线程,我在其中更详细地解释了它: 如何通过命令行向正在运行的应用程序发送命令

现在,这并不完全是您想要的,但效果是相同的,并且您已经了解了所有 api。

I'm not sure about the dll, but you could just write your own application in Autohotkey and package it along with your C++.

The communication takes place over a hidden window with an edit control and a button. You use one application to set text in the edit box, and then to click the submit button. The other application owns the window can process whatever is put into the edit control - as if you were passing a variable. Basically, that's it.

Check out this thread where I've explained it in more detail: How to send a command to a running application via commandline

Now, that's not quite what you wanted, but the effect is the same, and you already know all the api.

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