Hello my fellow programmers,
excuse my lame English...
I've been searching for months for someone to help me on this,
I'm a Java programmer, but there some things that java just can't handle...
I need to get the mouse coordinates on windows.
herer the deal:
I program in Java, so i need someone to write me a tiny bit of code in C++ to help me complete a project I'm working on.
[Clerification: The mouse coordinates needed are the screen ones, NOT the application ones. Moreover, the mouse should be free to work on WIN, untill the mouse middle button is clicked and from there on untill it is released, coordinates needs to be captured]
contact me on my ICQ# 196601267
(please! its my 12G project...)
Programmers unite!...
Hack the planet...
blah blah blah...
Thank you for your time, I really apreciate it.
It really sould not take a long time after we'll understend each other.
What is needed is integration of Java and C++,
a known interface which binds the two is JNI.
You should build a DLL file according to the JNI coding conventions (as they are stated below in the file) and then Java could call native functions declared on your DLL.
first we need to agree on what functions should be declared on the dll and then u could write them.
My idea is that I will call a function from ur dll which we'll call accept(), and then at ur side, the function waits for a middle mouse dragging action, which while at it, the function shall save the coordinates of the mouse, and when the middle mouse button is relased the function should return the coordinates.
(first u need to install java toolkit from sun.com so u'll have "jni.h" libary)
An unlimited array, called "Vector" in java, is spose to be returned from ur function.
the only thing I'm worried about is how will u create a java Object such as Vector, maybe in C++ u have ur own array type but u cant just send it back I guess...
here is the interface declared on "Test.h":
/* it is machine generated */
#include <jni.h>
/* Header for class Test */
In case the Vector thing wont work, a plan B is needed: just implement the next functions that
a. checks is the middle mouse is down.
b. returns the mouse x
c. returns the mouse y
(probebly sums in slower actions)
thank u again for helping me, and dedicating ur time,
I've been searching for months for somebody...
I tried the first DLL and got the next response for the following main func.:
public static void main(String ar[])
{
System.out.println("Hello world from Java");
Test test = new Test();
test.accept();
}
output:
Hello world from Java
Exception in thread "main" java.lang.NullPointerException
at Test.accept(Native Method)
at Test.main(Test.java:13)
Hello Form C++ Dll
^^^^^^^^^^^^
meaning, ur function was called succesfully. we can say that for sure by the output. but an exception followed the input, sont know why. i guess its because of the "return" or Vector...
the second DLL output:
Hello world from Java
Exception in thread "main" java.lang.UnsatisfiedLinkError: accept
at Test.accept(Native Method)
at Test.main(Test.java:13)
I dont know what u wrote into both of the dll's, so send me the source so i could too understend what was intended to happen, what succesfuly happend or didn't happen. so we could discuss further tries.
for now, lets try the simple interface stated below which allows me to get the mouse x coord - this will be a good "return" try app:
[special attention to the return type called "jint" (java int i spose), do u know how to return that kind of type?]
/* machine generated */
#include <jni.h>
/* Header for class Test */
good to know what first example at least called the function..
I have other commitments today however i have installed ICQ (324054990) and i should be able to spend some time on it tonight (in about 6-7 hours time).
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.