For arrows you should use a generic damage system like the one Shadow wrote(can't remember where that can be found), Vex's system(found here), or my Generic Damage stuff(found in this tutorial).
With just a little thinking(conditions for the Arrows buff) you can make it do whatever you want.
Note: Arrows work flawlessly with Vex's/My methods, since an Arrow will override an Orb
You can detect the order that turns on autocast, that way begins casting an ability would be A unit Is attacked, and starts the effect would be Unit takes damage...