我正在 Snow Leopard 上编写 Mac OS X 应用程序。我有一个由 NSTimer 定期触发的步骤方法。在这种方法中,我想将鼠标移动到屏幕中央,不按下或释放任何按钮。这是我所拥有的:
-(void) step: (NSTimer *) timer
{
NSRect bounds = [self bounds];
CGPoint point = CGPointMake(bounds.origin.x + bounds.size.width / 2.0f, bounds.origin.y + bounds.size.height / 2.0f);
CGEventCreateMouseEvent(NULL, kCGEventLeftMouseDragged, point, 0);
}
这没有任何作用。有人能告诉我出了什么问题吗?
听起来 CGWarpMouseCursorPosition 正是您所追求的(它移动指针而不生成事件 - 请参阅石英显示服务参考 http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/Quartz_Services_Ref/Reference/reference.html了解更多信息)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)