跨平台的移动鼠标代码
[ 2006-05-17 09:16:37 | 作者: 痉挛的老鸨 ]
#include < stdio.h >
#include < stdlib.h >
#include < string.h >
#ifdef WIN32
#include < windows.h >
#else
#include < unistd.h >
#include < X11/X.h >
#include < X11/Xlib.h >
#endif
int main(int argc, char* argv[])
{
char sx[10], sy[10];
int x, y;
if ( argc < 3 ) return 0;
strcpy(sx, argv[1]);
strcpy(sy, argv[2]);
x = atoi(sx);
y = atoi(sy);
#ifdef WIN32
SetCursorPos(x, y);
#else
Display *dpy;
Window rootwindow;
dpy = XOpenDisplay(NULL);
if ( ! dpy ) {
printf("Couldn't open Xdisplay.\n");
exit(1);
}
rootwindow = DefaultRootWindow(dpy);
XWarpPointer(dpy, rootwindow, rootwindow, 0, 0, 0, 0, x, y);
XCloseDisplay(dpy);
#endif
return 0;
}
评论Feed: /feed.asp?q=comment&id=36
您可能感兴趣的文章:
Debian安装笔记 (蓝色的雨 at 2007-01-24)
相遇linux (痉挛的老鸨 at 2006-04-12)
DOM制作流程 (痉挛的老鸨 at 2006-04-16)
真正的双卡双待 (progame at 2007-10-21)
Thinkpad T60安装 Windows 2003 之完整篇 (progame at 2007-01-19)
从编译Linux kernel说开来 (痉挛的老鸨 at 2006-05-10)
跨平台的线程代码 (痉挛的老鸨 at 2006-05-16)
监控系统之硬盘录像机(DVR) (痉挛的老鸨 at 2006-07-29)
这篇日志没有评论.

