日期:2014-05-20 浏览次数:20745 次
public class RobotTest {
public static void main(String[] args){
test();
}
public static void test(){
User32Ext USER32EXT = (User32Ext) Native.loadLibrary("user32", User32Ext.class, W32APIOptions.DEFAULT_OPTIONS);
MousePointer ptr = new MousePointer();
USER32EXT.GetCursorPos(ptr);
System.out.println(ptr.getX()+" : "+ptr.getY());//此处打印0:0
}
}
public interface User32Ext extends User32 {
void GetCursorPos(MousePointer ptr);
}
public class MousePointer extends Structure {
public long x;
public long y;
public Pointer pointer;
public long getX() {
return x;
}
public void setX(long x) {
this.x = x;
}
public long getY() {
return y;
}
public void setY(long y) {
this.y = y;
}
public Pointer getPointer() {
return pointer;
}
public void setPointer(Pointer pointer) {
this.pointer = pointer;
}
/* (non-Javadoc)
* @see com.sun.jna.Structure#getFieldOrder()
*/
@Override
protected List getFieldOrder() {
List a = new ArrayList();
a.add("x");
a.add("y");
a.add("pointer");
return a;
}
}