鼠标跟踪守护程序 [英] Mouse tracking daemon
本文介绍了鼠标跟踪守护程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要写一些东西使用Cocoa来表示原始鼠标移动数据。最好,应用程序只是一个运行的一个守护进程,将数据传递给另一个应用程序可以访问事件的套接字服务器。
I need to write something using Cocoa to surface raw mouse movement data. Optimally, the app would just be a little daemon that would run, passing the data to a socket server which another application could tap into to gain access to the events.
任何人都指出我在方法和工具方面的正确方向?我现在不知道从哪里开始。
Can anyone point me in the right direction with regard to approach and tools? I am not even sure where to begin with this right now.
推荐答案
另一个简单的方法是添加全局事件监视器(仅限10.6):
The other simple way to do this is to add a global event monitor (10.6 only, however):
id eventHandler = [NSEvent addGlobalMonitorForEventsMatchingMask:NSMouseMovedMask handler:^(NSEvent * mouseEvent) {
NSLog(@"Mouse moved: %@", NSStringFromPoint([mouseEvent locationInWindow]));
}];
然后当您完成跟踪时,您会:
Then when you're done tracking, you do:
[NSEvent removeMonitor:eventHandler];
这篇关于鼠标跟踪守护程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文