One option is to have a secondary data source with a field in it that your rule updates if a certain condition is met. Then an OnAfterChange event handler for that field would run whatever script you need.
I'm sure there are other ways to do it, but this is one way.

Signature
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com
Can I see in a script if a rule condation is true?
or if rule is applied, not to perform script? Is it possible?