I do this in my
Disenchant Predictor addon so I can make sure that the mats resulting from a disenchant match the predictions. You're welcome to check out the code there, but here's the gist of it:
1. Hook the OnClick handlers for both container buttons and inventory buttons so you can catch which item got clicked and remember it for the next step.
2. In UNIT_SPELLCAST_START, check to see if the spell being cast is Disenchant. (Note that you can do this in a locale-independent way if you start with the spellID for Disenchant and look up its name.) If it is, the item you clicked before is the one getting disenchanted.
This probably isn't the best way -- it doesn't catch disenchants that were set up by secure button attributes (as in mods like Breakables) or macros that "/cast disenchant" and then "/use" an item (by name or location). But it handles the most common case well.