You are able to do this by calculating the difference between before and after cast.
What you have to do is start a timer that expires in 0 seconds on the event "A unit starts the effect of an ability".
When that timer expires, the mana has been taken, when you start that timer, the mana is not yet taken.
So you will store the mana amount when the timer starts and calculate the difference when it expires.
JASS is much more powerfull with timers than GUI can in its current state.
Do you have any experience with JASS?