Deselecting pieces in an automated way

Hi,

After automated a few things, I end up with lots of pieces selected. Then, if the user is not aware of it, he will right click on one of these items and apply an action. Instead of being applied to one item, the action will be to all the selected ones!

Is there a way to programmatically deselect everything?

Regards.