I like to set contingent spells to fire off by a deliberate act performed by the target, such as a command word like "Shazam." Assuming the target isn't flat-footed, unconscious, or silenced, speaking (in most cases) is a free action that can be performed even when it's not your turn (3.5 PHB pg. 144). In other words, an immediate action. This allows the target of any contingent spell to set off the contingent spell before an attack hits provided the target is aware of his/her surroundings. Otherwise, the target must be directly affected before contingency fires as per contingency’s spell description and the additional information in Complete Arcane.
Setting the contingent spell to fire “when I take hp damage” still requires that the target be affected directly, and some might rather not take damage at all. If the target of the contingent spell has a command word set as his/her trigger and is aware of the approaching enemy, he/she could speak “Shazam” as an immediate action, bringing up stoneskin before the assailant’s attack hits.
One might also try setting his/her contingent spell to fire by clicking the teeth together twice in rapid succession or by touching the left pinky to the left thumb to avoid any problems with silence. If bound and gagged, crossing the eyes or running the tongue along the roof of the mouth might also be clever triggers that can be attached to any number of spells.