Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Mouse events and interrupts

Posted on 2003-11-12
11
Medium Priority
?
369 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
9 Comments
 
LVL 2

Accepted Solution

by:
smitty22 earned 136 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 132 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 132 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

824 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