

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
7 messages in net.java.dev.jna.usersRe: [jna-users] callback at mouse event| From | Sent On | Attachments |
|---|---|---|
| Michele Croci | Oct 23, 2007 1:45 am | |
| Timothy Wall | Oct 23, 2007 5:41 am | |
| Michele Croci | Oct 29, 2007 9:40 am | |
| Timothy Wall | Oct 29, 2007 12:01 pm | |
| Daniel Kaufmann | Oct 29, 2007 6:38 pm | |
| Timothy Wall | Oct 30, 2007 12:54 pm | |
| Daniel Kaufmann | Oct 30, 2007 6:16 pm |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | Re: [jna-users] callback at mouse event | Actions... |
|---|---|---|
| From: | Daniel Kaufmann (dani...@gmail.com) | |
| Date: | Oct 29, 2007 6:38:41 pm | |
| List: | net.java.dev.jna.users | |
You might have some aditional problems in doing it with jna than doing it with C, at least for Windows. In Windows, generally the way you get this mouse events is using hook. If you are able to get the desired events using the low level hooks (like WH_MOUSE_LL) you should be able to do it with JNA without issues, but if you need to use the WH_MOUSE hooks, it will be more difficult. For low level hooks windows just calls the callback function whenever the event occurres. However for other hooks you need a dll that is injected into the process getting the event. Since this process might or might not have a JVM started, and even if it has one it might not have the classes for your application in it, you might have a lot of problems. Even in C you might have some problems using WH_MOUSE, so you probably should use WH_MOUSE_LL, I am just pointing out that regurlar hooks are hard to implement with jna) (additionally there are remarks for what happens when you have 32 and 64 bits applications running, but that is both for C and java, not sure if they apply to both WH_MOUSE and WH_MOUSE_LL, or only to WH_MOUSE ) Thanks, Daniel
----- Original Message ----- From: "Timothy Wall" <twal...@dev.java.net> To: <use...@jna.dev.java.net> Sent: Monday, October 29, 2007 4:01 PM Subject: Re: [jna-users] callback at mouse event
It's certainly possible. There are probably several ways of doing it, but the most straightforward probably involves setting up a thread to process events (windows messages or X11 events).
Basically, if you can come up with plain C code that does it, you can replace the C code with Java code via JNA.
On Oct 29, 2007, at 12:40 PM, Michele Croci wrote:
Hi Timothy,
thx for your answer. I want to capture mouse events (also) outside a java window but I don't want to continuously poll the mouse asking if the user is doing something with it. I want do things in such a way that when there is one mouse event a Java-method is callled. Is this possible using JNA? I don't want to know how (event if I would like to know it ;) but only IF it is possible or not.
Thank you again.
-- Michele
2007/10/23, Timothy Wall < twal...@dev.java.net>:Is looking for mouse motion your high-level goal? If so, why? Are you really looking for something else, like user inactivity? Or do you need mouse motion in the absence of any Java windows? The answers to these questions will affect what bits of the native platform you need to hook into.
In general, when accessing native functionality, you need to do the following:
1) find an example written in C on the platform you want to make this work on 2) write JNA interfaces for the native bits you need to access 3) write client code and tests using a dummy implementation of the interface that behaves the way your tests expect it to behave 4) replace the dummy implementation with a Native.loadLibrary, and re- run your tests
On Oct 23, 2007, at 4:45 AM, Michele Croci wrote:
Hi all,
I have to write an application that uses jna and does a callback to a java-method when a mouse motion event happen. Is there a similar example? I have no idea how I can achieve my goal...
thx a lot!
Michele







