Solved

Mouse events and interrupts

Posted on 2003-11-12
11
361 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

743 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