Anyway to Get MousePos outside the Frame ?!

edited March 2014 in How To...

Hi , I'm trying to get absolute mouseX,Y of screen based on user's desktop Resolution . because mouseX,Y are limited to processing's output Frame . is there a way to get that absolute X,Y positions ?!

Answers

  • Answer ✓

    using the awt library it's possible:

    import java.awt.*;
    
    void setup () {
    
    }
    void draw () {
    PointerInfo a = MouseInfo.getPointerInfo();
    Point b  = a.getLocation();
    int x = (int)b.getX();
    int y = (int)b.getY();
    println(x + " : " + y);
    }
    

    hope this helps!

  • edited March 2014

    Fantastic @akiersky ! Just a slightly tweaked version of mine: :D

    /**
     * AbsoluteMousePointer (v2.0)
     * by  akiersky (2014/Mar)
     * mod GoToLoop
     *
     * forum.processing.org/two/discussion/3915/
     * anyway-to-get-mousepos-outside-the-frame-
     */
    
    import java.awt.MouseInfo;
    import java.awt.Point;
    
    void draw () {
      final Point m  = MouseInfo.getPointerInfo().getLocation();
      print(m.x + " : " + m.y + "\t");
    }
    
Sign In or Register to comment.