Optics comprise a mechanoid's sense of sight, feeding video data to their other systems. However, many mechanoids enhance these structures by installing optional weapons systems. Common examples include beam or particle weaponry, especially lasers. In these cases a robot can quite literally shoot what it sees.
Generation One cartoon
Grimlock is equipped with eye beams in his beast mode.
Laserbeak contained optic lasers in his eyes, using them to both spy on the Autobots and rain death upon them. He used them to blast a window of Shawn Berger's office, allowing him to take the corpulent businessman to the Decepticons. Laserbeak also used them to open doors and potholes while in New York. Bear in mind that Laserbeak doesn't have fingers, so he can't ring the doorbell.
Dinobot's eye beams appeared to be tied to his own Energon supply, making them potentially risky to use for too long. Indeed, Dinobot exhausted the last of his energy to destroy the Golden Disk with his eye beams, sacrificing his life.
Robots In Disguise
Side Burn used an "optical laser strike!" attack to collapse a hill on which Predacons were standing. This was the only instance in which Side Burn used that skill--which is not surprising, since it was the result of a FoxKids edit to the series, in which the original footage (Optimus Prime shooting missiles at the Predacons) was deemed too potentially violent and was replaced with an out-of-context clip taken from Side Burn's stock footage transformation sequence.