Solved

Mouse events and interrupts

Posted on 2003-11-12
11
364 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:frosty0457
ID: 9733484
How do I go about writing that dll? I've never dealt with dll files before.
0
 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

816 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

12 Experts available now in Live!

Get 1:1 Help Now