问题
How can I control other applications using Java ?
I'm using the Mary Speech Synthesizer(Open source, Java). It can synthesize speech well , but it requires the text to be in a textbox in the application window itself and then a button to be clicked . For this project of mine
the text that needs to be realized is gonna be inbound from another java application . I need to know how I can place the text in the textbox and send a click to one of the buttons in the application .
I'm hoping to figure out a way to synthesize speech from a buffer later on but till then this seems like it's a way to get things working . Also , I'm pretty sure I'll be able to find other applications for this later on and this seems like a very interesting problem ..
回答1:
Get the other application's API and call its methods accordingly.
回答2:
If an application does not offer an API to interact with it, there is no simple solution to make it.
However, since the application is open source you can verify what type of licensing it has, and include a part of its source code in your Java application and call it properly.
回答3:
I think your best option is to find a library that does the text synthesizing. Since controlling another java application required that java application to provide the necessary API for you to access it. As @Edmondo1984 told in his answer you can include the part of the code from the open source application(After checking the licence).
来源:https://stackoverflow.com/questions/11516905/control-other-applications-using-java