Hey all, is there a Linux API (preferably C++) to:
* Move the mouse to any coordinate on the screen.
* Get the position of the mouse on the screen.
* Get the colour value of a pixel on the screen at any given coordinate
?
Hey all, is there a Linux API (preferably C++) to:
* Move the mouse to any coordinate on the screen.
* Get the position of the mouse on the screen.
* Get the colour value of a pixel on the screen at any given coordinate
?
SDL maybe? I'm not 100% sure about setting the mouse co-ords but it does input so i imagine it should be able to do that.
Nah I don't think so. It will just set up a screen with double buffering to draw to, then you can get pixel values within it. Sorry, dident know that was what you were after.
well, for python, there's python-xlib (http://python-xlib.sourceforge.net/)
there's just plain xlib for c (http://tronche.com/gui/x/xlib/)
both will be capable of doing what you say you want to do.
Here, try this code. It uses python-xlib and does exactly what you want ! (taken from python-linux implementation of wiiwhiteboard: sourceforge.net/project/wiiwhiteboard)
import Xlib.display
import Xlib.ext.xtest
class MouseControl:
def __init__(self):
self.display = Xlib.display.Display()
self.screen = self.display.screen()
self.root = self.screen.root
def mouse_click(self, button):
self.mouse_down(button)
self.mouse_up(button)
def mouse_down(self, button): #button= 1 left, 2 middle, 3 right
Xlib.ext.xtest.fake_input(self.display,Xlib.X.Butt onPress, button)
self.display.sync()
def mouse_up(self, button):
Xlib.ext.xtest.fake_input(self.display,Xlib.X.Butt onRelease, button)
self.display.sync()
def mouse_warp(self, x,y):
self.root.warp_pointer(x,y)
self.display.sync()
def get_screen_resolution(self):
return self.screen['width_in_pixels'], self.screen['height_in_pixels']
hey wybiral, nice to see you again. want to show me the right way?
-------------
eh.
If you're good with java, then the Robot class is perfect for you.
Java Doc:
java.awt.Robot
I have used it to do just what you want.
Code:public class Robo {public static void main(String[] args) throws AWTException {}Robot robot = new Robot(); robot.mouseMove(100, 100); robot.getPixelColor(100, 100);}
If there's one thing worse than a program that doesn't work when it should, it's a program that does work when it shouldn't.
Bob Archer
Bookmarks