4 Replies - 313 Views - Last Post: 27 May 2011 - 03:17 PM Rate Topic: -----

#1 Codebug  Icon User is offline

  • D.I.C Head

Reputation: 31
  • View blog
  • Posts: 244
  • Joined: 11-October 09

registering mouse clicks and keypresses outside a GUI window

Posted 27 May 2011 - 07:07 AM

First of all, I'm not quite sure if java is even the right tool for this job, but I thought I'd give it a shot. Basically, I'm wanting to write a program that will keep up with the number of mouse clicks and keypresses that occur during the execution of the program. I would like the program to "run in the background". The problem I am running into is I'm not exactly sure how to register the events outside of a GUI window. I've handled events before, but all were contained inside a GUI window I wrote. I want this program to be able to register events anywhere on the screen, not just in a java GUI window so that during the course of the day, any mouse clicks and keystrokes anywhere will be recorded.

I haven't started writing the program yet, but I have been doing some brainstorming. I have thought of a potential solution, but if it works at all, I only think it will work for the mouse and not the keyboard. I thought about just making a blank, invisible JFrame, that will fill the entire screen(i.e. pass my screen resolution to the JFrame).
But, even if that registers the mouse clicks, and even if I can "see through" the JFrame, I don't think I will be able to click on anything else(icons, folders, files, etc.) because the invisible JFrame will be overlayed on top of everything.

Does anyone have any advice as to what tools I should use or how I should approach this problem? I hope I've been able to clearly articulate my question.

Thanks for all the help :D

Is This A Good Question/Topic? 0
  • +

Replies To: registering mouse clicks and keypresses outside a GUI window

#2 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2717
  • View blog
  • Posts: 11,427
  • Joined: 20-September 08

Re: registering mouse clicks and keypresses outside a GUI window

Posted 27 May 2011 - 07:11 AM

You need to install a mouse hook. See

http://stackoverflow...-jna-mouse-hook
Was This Post Helpful? 2
  • +
  • -

#3 Codebug  Icon User is offline

  • D.I.C Head

Reputation: 31
  • View blog
  • Posts: 244
  • Joined: 11-October 09

Re: registering mouse clicks and keypresses outside a GUI window

Posted 27 May 2011 - 07:22 AM

Thanks g00se! Thats what I was looking for, although it appears quite a bit more complicated than I had anticipated. Is there something similar that will also register keypresses? I guess a keyboard hook?
Was This Post Helpful? 0
  • +
  • -

#4 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2717
  • View blog
  • Posts: 11,427
  • Joined: 20-September 08

Re: registering mouse clicks and keypresses outside a GUI window

Posted 27 May 2011 - 07:36 AM

Quote

I guess a keyboard hook?


You guess right ;)
Was This Post Helpful? 0
  • +
  • -

#5 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10559
  • View blog
  • Posts: 39,069
  • Joined: 27-December 08

Re: registering mouse clicks and keypresses outside a GUI window

Posted 27 May 2011 - 03:17 PM

While Keyloggers are not always malicious, this falls under the umbrella of spyware, which Dream.in.Code does not support. Therefore, I am closing this thread.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1