When you are prescribed medicines, always check with your Doctor whether they will affect your ability to drive. This list from the Dirección General de Tráfico – España provides information for some of the most commonly used medicines in Spain.

http://revista.dgt.es/es/salud-vial/2016/1128-Salud-vial-como-afectan-los-medicamentos-mas-vendidos.shtml#.WdI_-GhSzcu