It is possible. Like when you press F4 or F5 it selects a "dummy hero", but instantly it selects back the target you were currently having. Then it checks if the selected unit was P, F or G. If it's for example P, then it drinks a potion from a box.
But I prefer having only one dummy hero that have abilities that you can use quickly with hotkeys. You just need to select it by either pressing F4 or put it to a group and then select action.