These are omikuji (fortune) machines. You put in 100 yen and get a printed fortune. The Japanese ladies were all very surprised at this, none of them had ever seen a machine dispensing omikuji, usually there's some kind of big jug or something that you pick up and shake your omikuji out of.
This was my omikuji. "Kyo means if your are careful now your fortune will improve in the future." That sounded pretty decent to me, but Kaori said it wasn't.
If your omikuji is good you keep it, if its bad you tie it on one of these ropes so the gods can take it back.
Praying in the temple. You toss in your offering (coins), clap two times, bow and say your prayer. You can toss your coins or clap first which ever you prefer.