Go Back   Java Programming Forums > Java Standard Edition Programming Help > Java Native Interface


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 19-06-2009, 08:06 PM
Junior Member
 

Join Date: Jun 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
gen1mx6 is on a distinguished road
Default how to make your program listen for input when it isn't the main focus?

basically i'm making a program that listens for user input when it isn't the main focus and then outputs keyboard presses appropriately.

IE

i'm typing in notepad and push f5 lets say, the program realizes this and then mimics keyboard presses using Robot...



Reply With Quote Share this thread on Facebook
Sponsored Links
Java Training from DevelopIntelligence
  #2 (permalink)  
Old 19-06-2009, 08:07 PM
Junior Member
 

Join Date: Jun 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
gen1mx6 is on a distinguished road
Default Re: how to make your program listen for input when it isn't the main focus?

using windows vista
Reply With Quote
  #3 (permalink)  
Old 19-06-2009, 10:42 PM
Freaky Chris's Avatar
Senile Half-Wit
 

Join Date: Mar 2009
Location: UK
Posts: 621
Thanks: 2
Thanked 64 Times in 60 Posts
Freaky Chris will become famous soon enoughFreaky Chris will become famous soon enoughFreaky Chris will become famous soon enough

I'm feeling Cheerful
Default Re: how to make your program listen for input when it isn't the main focus?

This is not possible in Pure Java due to the fact it runs on a VM. What you are after is a keyboard hook. Which must be written externally (making it platform dependant) and linked in using the likes of JNI. As it happens I am in the middle of doing this, and it's not straight forward I have to say, but that might just be my lack of experience and I am after all just a novice programmer. But I'd take a look at this thread.

http://www.javaprogrammingforums.com...oard-hook.html

Regards,
Chris
__________________
chris[at]javaprogrammingforums[dot]com

University of Wales, Bangor
Reply With Quote
  #4 (permalink)  
Old 22-06-2009, 11:00 AM
Junior Member
 

Join Date: Jun 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
gen1mx6 is on a distinguished road
Default Re: how to make your program listen for input when it isn't the main focus?

thanks for your help i've realized c++ is the better way to go
Reply With Quote
  #5 (permalink)  
Old 22-06-2009, 01:45 PM
helloworld922's Avatar
Super Moderator
 

Join Date: Jun 2009
Posts: 1,215
Thanks: 5
Thanked 258 Times in 234 Posts
helloworld922 will become famous soon enoughhelloworld922 will become famous soon enoughhelloworld922 will become famous soon enough
Default Re: how to make your program listen for input when it isn't the main focus?

Are you writing your own notepad-like program? If so, check here.

If not, go with what the other people are saying.
Reply With Quote
  #6 (permalink)  
Old 22-06-2009, 04:28 PM
Junior Member
 

Join Date: Jun 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
gen1mx6 is on a distinguished road
Default Re: how to make your program listen for input when it isn't the main focus?

i'm actually trying to make program that listens for keyboard input while it is in the background

for instance i'm playing a game and i press f5, i want the program to realize this (while its in the background) and push certain key combinations for me
Reply With Quote
  #7 (permalink)  
Old 25-06-2009, 06:16 PM
Freaky Chris's Avatar
Senile Half-Wit
 

Join Date: Mar 2009
Location: UK
Posts: 621
Thanks: 2
Thanked 64 Times in 60 Posts
Freaky Chris will become famous soon enoughFreaky Chris will become famous soon enoughFreaky Chris will become famous soon enough

I'm feeling Cheerful
Default Re: how to make your program listen for input when it isn't the main focus?

So basically you are trying to write a game automation bot for something such as WoW...by the sounds of it.

Chris
__________________
chris[at]javaprogrammingforums[dot]com

University of Wales, Bangor
Reply With Quote
  #8 (permalink)  
Old 26-06-2009, 01:57 AM
Junior Member
 

Join Date: Jun 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
gen1mx6 is on a distinguished road
Default Re: how to make your program listen for input when it isn't the main focus?

yeah mainly for games but i dont play wow :p
Reply With Quote
  #9 (permalink)  
Old 26-06-2009, 09:26 AM
JavaPF's Avatar
mmm.. coffee
 
8 Highscores

Join Date: May 2008
Location: United Kingdom
Posts: 1,543
Thanks: 98
Thanked 92 Times in 85 Posts
JavaPF is someone you want to know!JavaPF is someone you want to know!JavaPF is someone you want to know!

I'm feeling Relaxed
Default Re: how to make your program listen for input when it isn't the main focus?

Quote:
Originally Posted by Freaky Chris View Post
So basically you are trying to write a game automation bot for something such as WoW...by the sounds of it.

Chris
This seems to be what most people want to do with this sort of application. I like the idea of being able to automate keystrokes in games. Programming magic...

Shame it's not so easy in Java!
__________________
Don't forget to add syntax highlighted code tags around your code: [highlight=Java] code here [/highlight]

Forum Tip: Add to peoples reputation () by clicking the button on their useful posts.
Reply With Quote
  #10 (permalink)  
Old 27-06-2009, 09:05 PM
Freaky Chris's Avatar
Senile Half-Wit
 

Join Date: Mar 2009
Location: UK
Posts: 621
Thanks: 2
Thanked 64 Times in 60 Posts
Freaky Chris will become famous soon enoughFreaky Chris will become famous soon enoughFreaky Chris will become famous soon enough

I'm feeling Cheerful
Default Re: how to make your program listen for input when it isn't the main focus?

Well you never know then, maybe my C++ hook, which might I add is coming along qute nicely now just need to get down and finish it and hope that it all works since function testing is quite hard / impossible lmao so its just do and pray it works first time xD

But ye It might be quite popular, be it for a good use or not hehe xD

Chris
__________________
chris[at]javaprogrammingforums[dot]com

University of Wales, Bangor
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Similar Threads
Thread Thread Starter Forum Replies Last Post
Exception in thread "main" java.util.IllegalFormatWidthException: 13 xtrive Exceptions 2 23-03-2010 05:38 AM
[SOLVED] Exception in thread "main" java.lang.NullPointerException oscardog Exceptions 14 11-01-2010 09:36 AM
How to Create a server socket to listen for incoming connections JavaPF Java Code Snippets and Tutorials 0 05-05-2009 01:02 PM
Looking for a programmer to make a simple program. GrosslyMisinformed Paid Java Projects 3 27-01-2009 07:33 PM
I need someone to help me make algorithms araujo3rd Algorithms & Recursion 1 10-12-2008 05:34 PM


100 most searched terms
Search Cloud
2 dimensional arraylist java 2d arraylist java actionlistener actionlistener in java addactionlistener addactionlistener java convert double to integer java double format java double to integer in java double to integer java drag en drop programmeren java eclipse shortcut keys exception in thread "awt-eventqueue-0" java.lang.outofmemoryerror: java heap space exception in thread "main" java.lang.nullpointerexception exception in thread "main" java.lang.outofmemoryerror: java heap space format double in java format double java get mouse position java java 2d arraylist java actionlistener java double format java double formatting java double to int java double to integer java format double java forum java forums java get mouse position java list to map java mouse position java programming forum java programming forums java programming practice problems java send keystrokes to another application java two dimensional arraylist java.io.ioexception: premature eof java.lang.classformaterror: truncated class file java.lang.outofmemoryerror: java heap space java.util.arraylist jbutton action jbutton actionlistener jtextarea font jtextfield font size jxl.read.biff.biffexception: unable to recognize ole stream programming mutators and generics smack api two dimensional arraylist two dimensional arraylist java unable to sendviapost to url what is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?

All times are GMT. The time now is 01:54 AM.
Powered by vBulletin® Copyright ©2000-2009, Jelsoft Enterprises Ltd.