Automating interaction with a closed-sourced Windows XP GUI-based Program - java

I've a closed-sourced Windows XP GUI-based that performs some measurements.
My current manual workflow is:
Start the data capture by clicking on the "Run" button on the GUI
Stop the data capture by pressing the "Stop" button on the GUI.
Read some value displayed on the screen.
Save the data for the session to a file.
There is no library or API to automate this whole interaction and therefore I've no option but to do it manually :( and I'm sick of it !
As you clearly see that this approach is not only time-consuming but also error prone because it is limited by my reaction time which varies with every run.
I was wondering if there is a way to automate this interaction? If yes, what are my options? I would prefer to implement something in Python or Java. But I'm open to other options as well.
My idea is to implement a server process that runs on the Windows XP machine. I can then remotely send requests to this server process which in turn will execute my workflow automatically.

There's an amazing windows GUI automation tool called autoit. http://www.autoitscript.com/site/autoit/

You asked about linking AutoIt with Java. For my purposes, I've done this using a ProcessBuilder to create a Process, then get the Processes InputStream and ErrorStream and be sure to handle these streams in a separate thread. I have AutoIt communicate with my Java program using the InputStream. A good article for this (though a little out of date) is this one: When Runtime.exec() won't. It is key to be sure that the process be run on a background thread and that the two streams be read in their own threads. If you're doing this in a Swing GUI, then extra care must be taken that all Swing calls be made on the main Swing event thread, the EDT.

Related

Two CLI for one process

Is it possible to create for only one process two different CLI (CommandLineInterface)?
I would like to have one CLI with my real program, and another CLI for a chat, so that i can send command to my program and send messages in the chat at the same time, and obviously have different views for the program and the chat.
(edit)
the program is a game and the chat is to make communication between all player, but when i start my program in eclipse, that program strat with only a console and here i would like to have two console in one there is the game with its action and state and in the other one i would like to have all the messages in the chat.
I know that i can build another process from zero and integrate it with process builder, but i would like to have all in one process.
If I assume that by CLI you mean the main terminal from where you execute your program, the answer is NO, regardless the OS.
There are couple of options to implement additional CLI interfaces in the same process:
listening on socket and waiting for client(s) to connect by e.g. telnet
opening a window that implements the CLI
under UNIX you can spawn e.g. a xterm and process its IO in your process
Under Linux or OSX, just open a new terminal window, and you will have an additional CLI to work with, and yes, you can try your program from those two different environments simultaneously and independently.
Under Windows, I couldn't say. You're probably using cygwin or something like that, so you should probably try to be a bit more specific in your question to get more attention.

Close Child Java windows using C#

I have a java application running on Windows (javaw.exe) and I would like to close the child windows through a C# application. I can see the child windows through task manager under the Applications tab but when I right-click on the child windows and click Go To Process, it takes me to the javaw.exe process running under the Processes tab.
I have tried iterating through active processes to close each window however, I am unable to find the child java windows and only can see the javaw process.
Process[] childProcesses = Process.GetProcessesByName("javaw");
I have searched the internet forums and have not been able to find a proper solution that deals with a java application running on windows to be be dealt with using C#. I'm sure there is an obvious solution so any help is much appreciated. Thanks.
If I understand correctly your problem, you want to close one or more window among many of a java application ?
You won't have child processes on javaw, you only have threads running inside the JVM. Maybe using the Threads property of the process object could help.
But even doing that, all graphic objects in a java application are rules by the AWT Thread. Killing it will mean closing all the windows.
So i don't think it's possible to do what you want to do :/
Could you try to get handle of the child window and send message to it using P\Invoke methods and calling win32 api?
Maybe this answer can cover this idea:Cannot use pinvoke to send WM_CLOSE to a Windows Explorer window

automate java desktop application actions

I developed a java desktop application where the user can manually load a file and press a button to start a simulation process. I want to automate the above two steps so that an external program can iteratively call this desktop application multiple times and run the simulation process without any human intervention every time. Any thoughts on how I can go about doing this?
It depends on which OS you do it.
If OS X, use automator, for Windows you can use winautomation and for Linux use google and search (for example) kde automation.
I know this is an old question. But there is a new solution now,
JAuto: a JVMTI agent that runs in Java VM and expose UI widget attributes such as class names, screen coordinates. You talk to JAuto by sending a command to a named pipe. It responds by writing a file. It lets you control a Java program via bash scripts.
Using an input simulator such as xdotool, you can achieve automation under the Linux X11 settings.
Disclaimer: I'm the author of JAuto.

SWT TextBox Write is much slower then C++ executable prints

I am creating a Java GUI which interacts with C++ executable using ProcessBuilder. All the InputStream, OutputStream, ErrorStream from the C++ executable are redirected to the GUI TextBox. The C++ executable is very fast and it outputs lots of messages. Now the problem is eventhough the C++ executable is completed execution, GUI is still printing those messages over TextBox (as I am creating Display thread to write into GUI TextBox) for another 5-6 Minutes. Is there any way I can sync GUI-TextBox write speed with that of C++ executable prints? Thanks in Advance.
One idea see if it works for you:
Don't try to refresh the gui with every messages coming from c++. Try to buffer them and minimize the number of callbacks you do for GUI refresh. You cannot decide upfront a good buffer size that you can flush to GUI. You may have to do this fine tuning by trying different buffer sizes and limiting the number of GUI refresh through callback.
Hope it helps!

How to Remotely Block and Unblock any application on Windows

I am creating a program using Java Sockets in which I capture the client desktop and send messaging to client. Its working properly but now I want to block Client applications like Notepad, MS-Word, etc.
How can I do this?
Thanks.
It is hard to do using pure java API.
I do not know what do you mean when you say "block". The easiest way is to check from time to time running processes and kill one named "notepad" by executing taskkill from java.
If you wish to achieve effect of inactivity of application, i.e. user sees the notepad but cannot type you can do the following.
You have to check which application is on front. There is no clean pure java solution for this but you can probably write VBScript or JScript that does this task and run it from java. Once you detected that notepad is on top create transparent window (or even probably half-transparent window) that occupies full screen. Bring it on top. User will not be able to type into notepad because your window is on top but will see it.
Here is reference how to create transparent windows: http://java.sun.com/developer/technicalArticles/GUI/translucent_shaped_windows/
Good luck.

Categories

Resources