Monitor clipboard activity cocoa?
Is it possible to "watch" a users clipboard in cocoa?
For example if my app was 开发者_StackOverflow社区a system tray style app like the dropbox client could i subscribe to events raised when a user hits copy / paste in another app?
You could always check out Apple's sample code, ClipboardViewer. It does something sort of similar to what you're trying to do.
You can use File System Api to do this. please have look at File System Events Programming Guide you can do this by creating a deamon app at root level. Steps for creating a watcher deamon app.
1.Create a stream by calling FSEventStreamCreate or FSEventStreamCreateRelativeToDevice.
2.Schedule the stream on the run loop by calling FSEventStreamScheduleWithRunLoop.
3.Then your application should tell the file system events daemon to start sending events by calling FSEventStreamStart.
4.The application services events as they arrive. The API posts events by calling the callback function specified in step 1.
5.You can filter the events you want or files you want to watch.
精彩评论