Solved

Mouse events and interrupts

Posted on 2003-11-12
11
362 Views
Last Modified: 2010-03-31
How can I access the mouse memory address and get the mouse events directly? I want to be able to move the mouse and display its events to say, System.out. But, I don't want the mouse pointer to actually move on the screen. Can java access memory registers directly? Please include your knowledge about this subject.
I'm programming on a Sun running unix. I also use XWin32 on  windows 2000 to connect remotely.
0
Comment
Question by:frosty0457
11 Comments
 
LVL 2

Accepted Solution

by:
smitty22 earned 34 total points
ID: 9733383
>  Can java access memory registers directly?

I don't think so.  Java runs in a VM so it is "once-removed" from the memory.  It does not have direct access to memory locations as does C/C++.  This is a key component of "type-safe" languages such as Java, C#, and managed C++.
0
 
LVL 5

Expert Comment

by:lwinkenb
ID: 9733394
>>Can java access memory registers directly?

No, java doesnt have direct access to memory.  You need to use a language like C for this type of project.
0
 
LVL 5

Expert Comment

by:lwinkenb
ID: 9733412
You can always write a JNI dll to do what you want in C, and then call that dll from your java program.
0
 

Author Comment

by:frosty0457
ID: 9733484
How do I go about writing that dll? I've never dealt with dll files before.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:frosty0457
ID: 9733593
I know that this is the java section, but how would you write this in C.
I've increased the point amount.
0
 
LVL 5

Assisted Solution

by:lwinkenb
lwinkenb earned 33 total points
ID: 9733605
Well the main tutorial on JNI is located at:
http://java.sun.com/docs/books/tutorial/native1.1/

Basically you would figure out what exported methods you would want in your dll that java would have access to.  For instance, maybe you would have:

byte[] getRegisterContents();

Then you follow the directions in the link I posted to create a header file, and native code which does what you want.  Then you compile the native code into a shared library (since you are running unix, the library will be a .o or .so, not a .dll).

Good luck, this doesn't sound like an easy project :)
0
 
LVL 5

Expert Comment

by:lwinkenb
ID: 9733688
>>I know that this is the java section, but how would you write this in C.

Hrm, well Im not sure how you would do what you are trying to do (perform mouse events without actually moving the mouse), but to access registers, it would probably be easiest to include inline asm code.


void myfunc() {
__asm {
  // do your register access here
}
}
0
 
LVL 15

Assisted Solution

by:jimmack
jimmack earned 33 total points
ID: 9734015
>> I want to be able to move the mouse and display its events to say, System.out. But, I don't want the mouse pointer to actually move on the screen.

Capture the mouse movements with MouseListener or MouseMotionListener (depending upon exactly what you want to capture).

Keep a record of where the cursor is supposed to be.

Use java.awt.Robot to reset the location of the cursor after processing each mouse movement.  mouseMove().

0
 

Author Comment

by:frosty0457
ID: 9734347
Thanks to all who replied. I think I got it going now.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
The viewer will learn how to implement Singleton Design Pattern in Java.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now