I'm not familiar with a function that would get the id of the item that is on the cursor.
I've looked through it all before, but I don't see a reliable way of doing this because there are so methods or ways to get something on to the cursor.
I'd be interested to see if anyone comes up with, or knows of a sane solution.
In theory you can hook the pickup functions and find out what's about to be picked up. But since the pickup functions do so much it would probably need to be done carefully.