プログラムでマウスカーソルを移動するときは、250ミリ秒の遅延ではなく、リアルタイムでイベントが発生するように設定CGSetLocalEventsSuppressionInterval
する必要があります。0
残念ながら、SnowLeopardではCGSetLocalEventsSuppressionInterval
非推奨としてマークされています。
別の方法はCGEventSourceSetLocalEventsSuppressionInterval(CGEventSourceRef source, CFTimeInterval seconds);
https://developer.apple.com/library/mac/#documentation/Carbon/Reference/QuartzEventServicesRef/Reference/reference.html#//apple_ref/c/func/CGEventSourceSetLocalEventsSuppressionIntervalです。
-(void) mouseMovement:(CGEventRef) newUserMouseMovement
{
//Move cursor to new position
CGSetLocalEventsSuppressionInterval(0.0); //Deprecated in OS X 10.6
CGWarpMouseCursorPosition(NSPointToCGPoint(newMousePosition));
CGSetLocalEventsSuppressionInterval(0.25); //Deprecated in OS X 10.6
//--OR--//
CGEventSourceRef source = ???;
CGEventSourceSetLocalEventsSuppressionInterval(source, 0.0);
CGWarpMouseCursorPosition(NSPointToCGPoint(newMousePosition));
CGEventSourceSetLocalEventsSuppressionInterval(source, 0.25);
}
後者の方法を機能させることができません。
だから私の質問は、どうすればCGEventSourceRef
その機能に必要なものを手に入れることができるかということだと思います。
これは、ユーザーの通常のマウスの動きのイベントソースですか?または、カーソルを手動でワープする場合はどうなりますか?