Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / June 2005

Tip: Looking for answers? Try searching our database.

Handling "Press any key to continue..."?

Thread view: 
Izak van Langevelde - 30 Jun 2005 00:43 GMT
My java program executes an old DOS program for file conversion, which
is called by something like Runtime().getRuntime().exe("convert infile
outfile").

However, the 'convert' program asks its user to 'Press any key to
continue..." My first guess was to just write any character to the
process' InputStream, but this doesn't work; this is not specific for
java, as something like "convert infile outfile < anyKeyFile" doesn't
work from a DOS box either. Any clue how to simulate the pressing of any
key here?

Signature

Grinnikend door het leven...

Remi Arntzen - 30 Jun 2005 05:26 GMT
quote from class Process documentation (1.5 doc)
"The methods that create processes may not work well for special
processes on certain native platforms, such as native windowing
processes, daemon processes, Win16/DOS processes on Microsoft Windows,
or shell scripts."

A good example is a windows '.bat' file with only "pause" as a command.
The InputStream only shows the "pause" command echoed by the process,
but not the "Press any Key" statement.

If the "press any key" thing is at the end of the program it might just
be best to ignore it and call Process.destroy().  If pressing a key is
truly necessary "to continue..." then that won't be any help.

Good luck.
 Remi Arntzen
Remi Arntzen - 30 Jun 2005 05:35 GMT
I thought I was on to something...

java.awt.Robot r = new java.awt.Robot();
r.keyPress(71);
Thread.sleep(1000);
r.keyRelease(71);

But it doesn't work, because there is no console displayed on screen.
Bent C Dalager - 30 Jun 2005 10:13 GMT
>However, the 'convert' program asks its user to 'Press any key to
>continue..." My first guess was to just write any character to the
>process' InputStream, but this doesn't work

Did you flush the stream?

Cheers
    Bent D
Signature

Bent Dalager - bcd@pvv.org - http://www.pvv.org/~bcd
                                   powered by emacs

Izak van Langevelde - 30 Jun 2005 20:38 GMT
> >However, the 'convert' program asks its user to 'Press any key to
> >continue..." My first guess was to just write any character to the
> >process' InputStream, but this doesn't work
>
> Did you flush the stream?

The problem is the convert program wants a keystroke instead of input...

Signature

Grinnikend door het leven...



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.