Mouse tracking in entire desktop and image rendering the movements.
in
Programming Questions
•
1 year ago
hello everyone,
I'm new here, and comes with a few questions for my first project processing.
In short, I want to show graphically the movements of the mouse in the desktop, theclick, the scroll, etc..
full-screen Image shows every few minutes the mouse actions.
(for the moment there is also the processing window which follows the movement in real time, but it will be hidden later).
My project can approach this type of application: http://iographica.com/,
although different in functionality.
For now, I can follow the mouse and save the image.there is the code:
I tried with "open", with no success yet. Do you know if we can correctly do it with a pde file? Maybe there is an other way do display the result in a fullscreen image.
Do you know how to recognize the clicks and the scroll? I imagine I have to create a java MouseEvent, because I had no good result with mousePressed,mouseClicked.
Sorry for my English is not my native language. Thank you in advance for your interest and advice!
I'm new here, and comes with a few questions for my first project processing.
In short, I want to show graphically the movements of the mouse in the desktop, theclick, the scroll, etc..
full-screen Image shows every few minutes the mouse actions.
(for the moment there is also the processing window which follows the movement in real time, but it will be hidden later).
My project can approach this type of application: http://iographica.com/,
although different in functionality.
For now, I can follow the mouse and save the image.there is the code:
- import java.awt.*;
- PGraphics pg;
- Timer timer;
- //int num = 0;
- int mX, mY;
- void setup() {
- size(int(screenWidth/3), int(screenHeight/3));
- pg = createGraphics(screenWidth, screenHeight, P2D);
- pg.beginDraw();
- pg.background(0);
- pg.smooth();
- pg.endDraw();
- timer = new Timer(10000);
- timer.start();
- }
- void aaa() {
- pg = createGraphics(screenWidth, screenHeight, P2D);
- pg.beginDraw();
- pg.background(0);
- pg.smooth();
- pg.endDraw();
- }
- void setMouseXY() {
- Point mouse;
- mouse = MouseInfo.getPointerInfo().getLocation();
- mX = mouse.x;//winloc.x;
- mY = mouse.y;//winloc.y;
- }
- void draw() {
- setMouseXY();
- pg.beginDraw();
- pg.noStroke();
- pg.fill(random(230), 240, 400, 90);
- pg.ellipse(mX, mY, 12, 12);
- pg.endDraw();
- image(pg, 0, 0, int(screenWidth/3), int(screenHeight/3));
- //println( "mX is " + mX + " and mY is " + mY );
- if (timer.isFinished()) {
- //pg.save("image"+num +".png");
- pg.save("image.png");
- //open("/home/o/PROSS/lanceur/lanceur.pde");
- aaa();
- //num++;
- //setup();
- timer.start();
- }
- }
- class Timer {
- int savedTime; // When Timer started
- int totalTime; // How long Timer should last
- Timer(int tempTotalTime) {
- totalTime = tempTotalTime;
- }
- // Starting the timer
- void start() {
- // When the timer starts it stores the current time in milliseconds.
- savedTime = millis();
- }
- // The function isFinished() returns true if 5,000 ms have passed.
- // The work of the timer is farmed out to this method.
- boolean isFinished() {
- // Check how much time has passed
- int passedTime = millis()- savedTime;
- if (passedTime > totalTime) {
- return true;
- } else {
- return false;
- }
- }
- }
I tried with "open", with no success yet. Do you know if we can correctly do it with a pde file? Maybe there is an other way do display the result in a fullscreen image.
Do you know how to recognize the clicks and the scroll? I imagine I have to create a java MouseEvent, because I had no good result with mousePressed,mouseClicked.
Sorry for my English is not my native language. Thank you in advance for your interest and advice!
1