views:

337

answers:

3

Cloud App has this neat feature wherein it automatically uploads new screenshots as they are added to the Desktop. Any ideas how this is done?

A: 

I am not sure what you are asking for exactly. If you are asking for a way to take a screenshot programmatically in MacOSX, I suggest you have a look at the "screencapture" command (in the terminal, type "man screencapture" for doc).

If you want to do it the "hard" way, you should look at this.

Krumelur
That's not what the questioner is asking. The questioner is asking how to monitor the Desktop folder for screenshot files created in the normal way (⇧⌘4 and friends) and upload them to a server.
Peter Hosey
+4  A: 

You can do similar things yourself without much in the way of programming. In OSX, you can configure "Folder Actions" to run a script, for example, when a new item appears in a folder, including the Desktop. You can then use the script to do whatever you want with the new files.

This article at TUAW includes an example of uploading files to a web server when they hit a particular folder.

So, basically, the answer is "Folder Actions", or "something's keeping an eye on the folder and sending notifications", at some level. Whether Cloud App uses Folder Actions or watches the folder itself at a lower level, using FSEvents/NSWorkspace, or the kqueue mechanisms (for which there's a nice wrapper class called UKKQueue, if I remember correctly -- don't know how current my knowledge is on that one though!) is another matter...

You could implement this at several different levels, depending on the outcome you want, how you want to design whatever it is you're actually doing, and even what kind of filesystem you're targeting. Fundamentally, in Cocoa/Objective C, I think you probably want to start looking at FSEvents.

Once you've got notifications of the file changes, I'd probably use something like ConnectionKit to do the uploading -- any library at all, really, that means you don't have to bother with the sockets level yourself -- but again, there's a lot of different ways.

Depends, really, what level you're looking to solve the problem at, and whether you want to build something for other people or get something working for yourself. If I just wanted to bash something together for myself, I could probably have something cobbled together using Coda's Transmit app, and Folder Actions, or maybe Hazel, and a minimal bit of Applescript, in a half-hour at most, that would do the job well enough for me...

Matt Gibson
This seems great! Which is easier, FSEvents or NSWorkspace, and how do I do that... Sorry I'm such a noob.
Alexsander Akers
I believe FSEvents would be the normal way to go these days; if you have a look at http://stackoverflow.com/questions/913401/fsevents-weirdness-on-os-x-leopard <-- this earlier question, the posted answer links to a fairly small complete test project that monitors a folder for changes, here: http://bitbucket.org/boredzo/fs-notifier/src/5633027cded4
Matt Gibson
Using that, I can see when the Desktop folder is modified, but it won't tell me which file is modified. Or is there a screen shot notification center or something?
Alexsander Akers
I believe you'll just have to look at the files. Checking the Desktop files' name and modification times should (quickly, and quite inexpensively) let you know of new screenshots.The filename format for screenshots changed in Snow Leopard; for OS X 10.4 and 10.5, you should look for "Picture X.png", as opposed to the new "Screen shot..." format.I don't believe there's a way of hooking into OS X's actual screenshot event, i.e. a "screenshot notification center", but I'm happy to be corrected, if anyone knows?
Matt Gibson
A: 

You can try use ActyMac Screenshot Remote.It’s prog for helps you remote monitoring using iPod.You also can monitor screenshot capturing.Try it.

Julia