The Knoevenagel reaction of 2-acetyl-1,3-indandione, dehydroacetic acid, 3-acetyl-4-hydroxy-coumarin and acetyl-barbituric acid with pyrrol-2-carbaldehyde affords 2-(1-hydroxy-3-(1H-pyrrol-2-yl)allylidene)-1H-indene-1,3(2H)-dione 5, 3-(3-(1H-pyrrol-2-yl)acryloyl)-4-hydroxy-6-methyl-2H-pyran-2-one 6, 3-(3-(1H-pyrrol-2-yl)acryloyl)-4-hydroxy-2H-chromen-2-one 7 and 5-(1-hydroxy-3-(1H-pyrrol-2-yl)allylidene)-1,3-dimethylpyrimidine-2,4,6(1H,3H,5H)-trione 8. The UV-induced E→Z isomerization, intra and intermolecular H-bonding is studied by NMR, IR, UV spectroscopy and theoretical calculations. The driving force for the E→Z isomerization is the formation of a bifurcate O–H∙∙∙O∙∙∙H–N hydrogen bond in the latter. The position of the E⇆Z equilibrium strongly depends on the solvent (CH2Cl2, acetone, EtOH, DMSO). According to QTAIM analysis, the formed OH∙∙∙O bonds are strong or moderate in energy (from 7.6 to 10.2 kcal/mol), while the NH∙∙∙O bonds are weak (from 4.8 to 6.4 kcal/mol).