You can book your ferry tickets in advance - I used Alilauro but I think there are other ferry lines, too: http://www.alilauro.it/en/departures-and-rates It turned out it was not really necessary for me to book the trip out in advance, but my AirBnB host was telling me I might not be allowed to buy a ticket if I wasn't a resident and they were very busy. I think he was quite misinformed, or I misunderstood, though I was there in late April so high season could be different. I bought my Capri > Sorrento ticket from the booth when I was ready to leave Capri as I didn't want to be tied to a particular departure time.
I unfortunately did not have a chance to see the Blue Grotto due to choppy seas and no boats running. I purchased my circle the island tour ticket right when I arrived. Rick mentions two companies, Laser Capri and Motoscafisti Capri, in his RS Italy book, and you can buy tickets online if you wish. I honestly can't remember which tour I took (and it was only a month ago, oiy) - I just walked up to the first counter I saw after I got off the ferry and bought a ticket for the next trip.
One recommendation - try to arrive early. I had an 845 ferry from Sorrento and it was already busy. When I finished my circle the island tour at about 1030, the lines for the buses to Anacapri were incredibly long because the buses are very small because the roads are very narrow. You might buy a circle the island tour ticket for later in the afternoon and catch the bus to Anacapri first thing before all the groups arrive. Rick has a lot of good info on a Capri day trip in the Italy book.
Enjoy, and I hope the sea cooperates and you can see the Blue Grotto!