如何编写可以与其他程序交互的程序 [英] How to write a program that can interact with other programs

查看:144
本文介绍了如何编写可以与其他程序交互的程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写一个可以在Windows上播放纸牌的程序。用户将运行该程序并打开纸牌,并在卡片移动时观看。很容易为将要播放纸牌的程序编写AI(我显然没有Windows单人纸牌的源代码)。我可以想到这样做的一种方式是,如果我拍摄纸牌图像并对其进行分析以确定卡片的当前状态,那么我可以将卡片的当前状态传递给我的程序,这可以决定下一步行动。但是我将如何执行click命令。

I want to write a program that could play solitaire on windows. The user would run the program and open solitaire and watch as the cards move. Its easy to write the AI for the program that would play solitaire (I obviously don't have the source code for the Windows solitaire). One way I can think of doing this is if I took an image of the solitaire and analyzed it to determine the current state of the cards, then I could pass the current state of the cards to my program, which could determine the next move. But how would I execute the clicking command.

更一般地说,我想编写一个可以像用户那样与另一个程序交互的程序。
我有C,C ++,Java,Ruby方面的经验。但我不知道如何开始这个,或者是否可以这样做?

More generally, I want to write a program that can interact with another program like a user would. I have experience with C, C++, Java, Ruby. But I don't know how to even get started on this, or whether this can be even done?

推荐答案

Java不是这样做的语言。为了促进这样的功能,您需要严重依赖Windows API,尤其是那些允许您注入输入的API。作为一个起点,我建议您了解Windows应用程序实际处理输入的方式。 是一个关于这个问题的好文章。

Java is not the language to do this. In order to facilitate functionality like this you need to rely heavily on windows API, especially those that allow you to inject input. As a starting point I can suggest you get acquainted with how windows application actually process the input. This is a good article on the subject.

这篇关于如何编写可以与其他程序交互的程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆