Results 1 to 4 of 4
- 02-01-2011, 02:11 PM #1
Member
- Join Date
- Feb 2011
- Posts
- 2
- Rep Power
- 0
Getting keyEvents even though the program is not in focus
So, I'm currently working on a nifty little tool for myself and the only thing from completing it is this little thing ;p
What I need it to do is that whenever I press a key, regardless if the program is in focus or not, it should do a certain thing. I've got all of the code done, working, but as of right now I'm using a button instead of this KeyListener.
I tried to do it by making the app go into the system tray but unfortunately I got an unexpected error and didnt really feel like sorting that out.
I've googled for an answer but couldnt find anything.
Could someone help me with this? or point out the general direction on how to do it? Is it even possible to do in Java?
thanks in advance.Last edited by Skurken; 02-01-2011 at 02:14 PM. Reason: fixing type-o's
-
You can't create a key logger with just Java and nothing else.
- 02-02-2011, 05:49 AM #3
Senior Member
- Join Date
- Jan 2009
- Posts
- 671
- Rep Power
- 5
The closest you can get with out of the box java is ToolKit.addAWTEventListener, and register to listen for all events.
Fubarable is correct that you can not capture the keystrokes system wide - only those associated with your application. Keystroke loggers must run with admin/superuser privileges for obvious reasons.
....That said, it might be possible to create an app that fools the user into thinking s/he is interacting with other apps when in reality your app has focus, by combining Robot screen captures with full screen mode. But this sounds too much like an attempt to hack passwords, so I'm not going to offer further advice.Last edited by toadaly; 02-02-2011 at 05:55 AM.
- 02-02-2011, 10:53 AM #4
Member
- Join Date
- Feb 2011
- Posts
- 2
- Rep Power
- 0
it's not a keylogger I'm making. Dunno where you got that idea from.
it's a screen saving app which I find very useful. it takes a screen shot and saves it to your directory of chose, and saves it as .jpg, .png, .bmp or .gif, depending on the saving options.
As I said it does all of this and it works great, but I'm using a button on the UI which kind of makes it useless (because the idea is to just press any key and then it captures the screen and saves it, without having to copy/paste into MS Paint or something)
thanks for the answers anyway, even if it's a bummer to find out you cant do it :/
Similar Threads
-
Automatic convert to uppercase in keyevents
By ashin in forum SWT / JFaceReplies: 4Last Post: 08-09-2010, 01:59 PM -
Question about java keyevents?
By Godsent in forum AWT / SwingReplies: 2Last Post: 10-26-2009, 09:38 PM -
key press triggering something when program isn't in focus
By infinity in forum AWT / SwingReplies: 0Last Post: 04-22-2009, 05:52 AM -
how to focus to another JTextfield?
By birdofprey in forum AWT / SwingReplies: 2Last Post: 04-09-2008, 01:08 PM -
Focus
By Marty in forum AWT / SwingReplies: 1Last Post: 05-31-2007, 02:16 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks