LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 07-05-2004, 07:39 PM   #1
chakkerz
Member
 
Registered: Dec 2002
Location: Brisbane, Australia
Distribution: Slackware Current, RedHat (RHEL, FC, CentOS), openSuSE, Mac OS X
Posts: 648

Rep: Reputation: 32
java keylogging


Hi

I'm writting a small program for my university research, and need to capture user keystrokes (already taking screen shots and tracking mouse location). I'm working in Java 1.5 Beta but any pointers would be appreachiated

OK, i need to capture user keystrokes, I was figuring something like System.in could be used but i don't know how to make it capture keystrokes outside of my program ... ie, which input stream to use. Also, i need to do this without interference to the user, so the keystrokes need to be passed forward (or not intercepted) to the program the user is passing them to.

While we are at it, i also need to capture mouse clicks (left/right/double) when they occur.

Any ideas or pointers would be appreachiated

Additional (edit)
i had been thinking that it's a simple matter of changing System.in to something more global, but that doesn't seem to be it.

I turned up something interesting though, Sockets.

Is it possible to connect a socket to the Xserver to monitor keystrokes.
Socket echoSocket = new Socket(InetAddress address, int port);
where the address is my local system/the local Xserver, and the port is the appropriate Xserver port ...

is that possible ?

Last edited by chakkerz; 07-06-2004 at 02:29 AM.
 
Old 07-06-2004, 11:33 AM   #2
aaa
Guru
 
Registered: Jul 2003
Location: VA
Distribution: Slack 10.1
Posts: 2,194

Rep: Reputation: 46
I don't think it is possible using the docuemented Java classes, you could look at the undocuemented classes in the sun.* packages. As for connecting with a socket, if possible, you would have to worry about implementing the X protocol and all, something Xlib already does (and Java probably uses it under the hood (sun.*)). Plus both of those options are not portable.

Last edited by aaa; 07-06-2004 at 01:56 PM.
 
Old 07-06-2004, 01:42 PM   #3
jbstew32
Member
 
Registered: Feb 2003
Location: Atlanta, GA
Distribution: Debian 3.1
Posts: 149

Rep: Reputation: 15
if im not mistaken, i believe you can create different listeners that will capture keyboard events. Given that say an "h" is pressed, you could store it in an ArrayList, where you can later display the entire arraylist to the screen or write it to a file. I also know there is a similar way of capturing which specific mouse buttons are clicked, or which direction the wheel is scrolled.

The only problem is I am not sure if you can do this without the java program being ran in the forground with the main focus to the user....

I know I am being broad, but it's the best I can do without spending sometime with the API
 
Old 07-06-2004, 08:41 PM   #4
chakkerz
Member
 
Registered: Dec 2002
Location: Brisbane, Australia
Distribution: Slackware Current, RedHat (RHEL, FC, CentOS), openSuSE, Mac OS X
Posts: 648

Original Poster
Rep: Reputation: 32
hmm sun* packages hey?

where do i find info on those?
 
Old 07-07-2004, 08:04 AM   #5
aaa
Guru
 
Registered: Jul 2003
Location: VA
Distribution: Slack 10.1
Posts: 2,194

Rep: Reputation: 46
Some googleing turned up this:
http://www.smotricz.com/kabutz/Issue007.html
 
Old 07-07-2004, 10:27 PM   #6
chakkerz
Member
 
Registered: Dec 2002
Location: Brisbane, Australia
Distribution: Slackware Current, RedHat (RHEL, FC, CentOS), openSuSE, Mac OS X
Posts: 648

Original Poster
Rep: Reputation: 32
interesting, thanks will need to try that one ...

PS i found the sun.* packages ... decompress the source code ... duh
 
Old 07-28-2004, 07:58 PM   #7
chakkerz
Member
 
Registered: Dec 2002
Location: Brisbane, Australia
Distribution: Slackware Current, RedHat (RHEL, FC, CentOS), openSuSE, Mac OS X
Posts: 648

Original Poster
Rep: Reputation: 32
Incidentally,

I fixed it like so:

I grabbed uberkey 1.2 and get it to pipe it's output to a file, i get my java program to observe the file, and as the file changes it extracts the data.

(i modified ueberkey a little so that my program can extract a little more meaningful data).

I checked the Global Hot Key Listerener, noted by aaa ... alas that only works if the program has focus. Never the less, its a very interesting and useful bit of code, so thanks for that.

Still can't capture the mouse clicks ... but there should be a way
 
Old 07-28-2004, 08:50 PM   #8
mhiggins
Member
 
Registered: Feb 2004
Posts: 140

Rep: Reputation: 15
Not sure how "Cross platform" you need this app to be but if you are running some *NIX you could parse the data comming from /dev/mouse, /dev/psaux or /dev/gpmdata .
 
Old 08-06-2004, 08:08 AM   #9
chakkerz
Member
 
Registered: Dec 2002
Location: Brisbane, Australia
Distribution: Slackware Current, RedHat (RHEL, FC, CentOS), openSuSE, Mac OS X
Posts: 648

Original Poster
Rep: Reputation: 32
Ahhh ... Interesting I had been considering it, but since no one mentioned that (anywhere), i figured that wasn't a possibility (should have just run cat /dev/psaux i guess ).

Well, it would certainly kill platform independence, but it would give valuable info, in particular mouse clicks ... (since i already jave mouse location).

hmm ... thanks for that, i might have to include that.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java plugin installed correctly for Firefox but not able to view any java applet tvn Linux - Software 10 04-15-2010 03:13 AM
Java Programming: Java Runtime Environment not found when trying to compile murbz Linux - Software 2 03-26-2009 04:04 AM
Web start java not working (java works fine) powadha Debian 5 06-05-2004 01:57 PM
2 Questions: java calling system commands? PERL vs Java? randomx Programming 28 11-28-2003 09:24 PM
Keylogging script/program TomG Programming 3 08-06-2002 04:13 PM


All times are GMT -5. The time now is 10:12 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration