python控制鼠标,如何在Mac中使用Python控制鼠标?
What would be the easiest way to move the mouse around (and possibly click) using Python on OS X?
This is just for rapid prototyping, it doesn't have to be elegant.
解決方案
I dug through the source code of Synergy to find the call that generates mouse events:
#include
int to(int x, int y)
{
CGPoint newloc;
CGEventRef eventRef;
newloc.x = x;
newloc.y = y;
eventRef = CGEventCreateMouseEvent(NULL, kCGEventMouseMoved, newloc,
kCGMouseButtonCenter);
//Apparently, a bug in xcode requires this next line
CGEventSetType(eventRef, kCGEventMouseMoved);
CGEventPost(kCGSessionEventTap, eventRef);
CFRelease(eventRef);
return 0;
}
Now to write Python bindings!
總結
以上是生活随笔為你收集整理的python控制鼠标,如何在Mac中使用Python控制鼠标?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 电动车电没用完就充电吗?
- 下一篇: websocket python爬虫_p