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 / August 2006

Tip: Looking for answers? Try searching our database.

Invoking KeyEvents to simulates keystrokes

Thread view: 
kaldrenon - 16 Aug 2006 04:44 GMT
Hey all.

I'm a gamer, and I can get absorbed by whatever game I'm playing fairly
easily. So I want to write a program that can take a given time and, at
that time, force the computer to Alt-Tab out of the program, or
simulate some other series of keystrokes. I can handle setting up the
multiple options on my own, but I want to know - can I simulate
keystrokes using calls to KeyEvent. If so, how, and if not, what should
I do instead?

Thanks in advance.
Thomas Weidenfeller - 16 Aug 2006 09:18 GMT
> If so, how, and if not, what should
> I do instead?

Consider using C instead of Java, since it gives you better access to
the system. And I would assume you have to do some type of system
programming to get it right.

Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/

Oliver Wong - 16 Aug 2006 22:10 GMT
> Hey all.
>
[quoted text clipped - 5 lines]
> keystrokes using calls to KeyEvent. If so, how, and if not, what should
> I do instead?

   Use a robot: http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Robot.html

   - Oliver
kaldrenon - 17 Aug 2006 00:56 GMT
> > Hey all.
> >
[quoted text clipped - 9 lines]
>
>     - Oliver

Thanks Oliver. The Robot works great, I used JButton with a RobotButton
subclass, gave it a Robot and an array of ints, and passed in an array
of KeyEvent.VK_** for the series of key presses I needed.


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.