Como solución alternativa, puede escribir una herramienta de línea de comandos para mover el cursor del mouse y luego usar las opciones de enlace de teclas programables de su shell para ejecutar esta herramienta de línea de comandos cuando se ingresa una secuencia de teclas especificada.
/*
File:
mvright.m
Compile with:
gcc -Wall -Wextra -framework ApplicationServices -framework Foundation -o mvright mvright.m
Successfully compiled on:
Mac OS X 10.6.8
Usage:
./mvright
# in .bashrc; press ctrl-h keys to move mouse cursor to the right
bind -x '"\C-h": /usr/local/bin/mvright'
References:
- "Controlling the mouse from Python in OS X",
http://stackoverflow.com/questions/281133/controlling-the-mouse-from-python-in-os-x,
http://synergy-foss.org
- "Move and click the mouse via code",
http://hints.macworld.com/article.php?story=2008051406323031
*/
#import <Foundation/Foundation.h>
#import <ApplicationServices/ApplicationServices.h>
int main(void) {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// Get the current mouse location
CGEventRef ourEvent = CGEventCreate(NULL);
CGPoint ourLoc = CGEventGetLocation(ourEvent);
//NSLog(@"Location? x= %f, y = %f", (float)ourLoc.x, (float)ourLoc.y);
// The data structure CGPoint represents a point in a two-dimensional
// coordinate system. Here, X and Y distance from upper left, in pixels.
CGPoint pt;
pt.x = (float)ourLoc.x + 10.0;
pt.y = (float)ourLoc.y;
//NSLog(@"Location? x= %f, y = %f", (float)pt.x, (float)pt.y);
CGEventRef eventRef;
eventRef = CGEventCreateMouseEvent(NULL, kCGEventMouseMoved, pt, kCGMouseButtonCenter);
//Apparently, a bug in xcode requires this next line
//CGEventSetType(eventRef, kCGEventMouseMoved);
CGEventPost(kCGSessionEventTap, eventRef);
//CGEventPost(kCGHIDEventTap, eventRef);
CFRelease(eventRef);
CFRelease(ourEvent);
[pool release];
return 0;
}