Oops, I think it's good practice to release all keys, so change this line:
robot.keyPress(c[j]);
to:
robot.keyPress(c[j]);
robot.keyRelease(c[j]);
Main Topics
Browse All TopicsHello friends,
I am trying to develop a screen scraping program that will start a legacy emulator (which is using ALC protocol), run a few commands, and then return the result set (screen dump - in character format, like Ctrl-A / Ctrl-C in Notepad to copy all in the notepad) after each command execution. You might have figured out that the actual program is going to be very complicated, but I would like to concentrate on screenscraping so that I could get the so called easy part out. To start with I need to know if I can write the screen scraping program using Java? If so, I would appreciate any leads on the same. Will it be dependent on the protocol? I am assuming that since the execution would happen on windows based PC, and the emulator runs on the same PC, it should not matter which protocol the emulator actually uses to connect to the underlying legacy system. Please correct me if I am wrong.
If you guys have come across any source codes (or have any source codes) that can demonstrate the screen scraping, I would appreciate if you could share the same with me.
In the absence of any existing working demo/code, May be someone could write a simple screen scraping program that does the following:
1. Open 'calc.exe' - The inbuilt microsoft calculator.
2. Read a flat file from designated folder which has commands like:
3+4=
5*6=
8/2=
EOF
3. Execute all the commands from the above file, and save the output in a separate flat file with the original command with the result set, so the output file could look like:
3+4=7
5*6=30
8/2=4
EOF
4. Note that the calc supports Ctrl-C so the output could be captured using Ctrl-C. If you have not seen the 'help' of calc you may find the same interesting, especially the sections that talk about 'keyboard and keypad' -> Using Key Sequences as functions OR Using Keyboard equivalents of Calculator.
I would appreciate any help or guidance.
Thanks and Regards,
Pratik
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: InteractiveMindPosted on 2009-09-08 at 06:04:53ID: 25281402
Java is capable of typing keys and clicking the mouse: m/egs/java .awt/Simul ate.html
m/egs/java .awt/MoveM ouse.html
s/java.lan g/Exec.htm l?l=new
http://www.exampledepot.co
it can also move the mouse cursor on the screen:
http://www.exampledepot.co
and launch processes from the command line:
http://exampledepot.com/eg
However, it's generally difficult to retrieve data from applications. In the case of the calculator, using Ctrl+C is a relatively simple approach. I've coded an example program that performs the calculations (see below).
But if you had a window application which you wanted to read from, then Java is not really up to the task (unless you take a screen shot, then perform OCR - which is not worth the effort). However, a more platform dependent language such as C/C++/C# etc., would be capable of getting a reference to a given GUI component, and retrieving the text from it, which would be a better approach.
Regarding the below code: Ctrl+C takes a short period to place the content onto the clipboard. So I've added a pause of 200 ms (you could possibly do less) to give the system enough time to do this before reading the content off the clipboard.
Select allOpen in new window