Solved

Mouse events and interrupts

Posted on 2003-11-12
11
366 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

733 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