Is this hotkey AHK's? Then, I'm afraid it won't work as planned. AHK uses LL hook, so the hook procedure is called when a key is about to be poseted to the target's message queue, not when it's retrieved from the target's message queue. Therefore, can't guarantee the chronological order of the two.Another thought: After sending Ctrl-V we could send also an invisible key to the same window, which is also defined as a hotkey. This hotkey is only activated, when ^v has already been read from the keyboard buffer, so we restore the original clipboard content in this hotkey subroutine.
If the hotkey is defined via RegisterHotkey, then almost guaranteed about the order of the posts to the message queues, however, as the targets are different, one for the active window and one for AHK, no guarantee about the order of their processing, I think.
It may be overcome now via the old global keyboard hook using ahkhook.dll (or maybe using AttachThreadInput, but not sure atm if it's possible with it).
I feel it's rather overkill for this job, however. And, it still doesn't 100% guarantee the latter (AHK's) hotkey is activated after the paste operation is completed.
So, the best way would be finding a synchronous mechanism to achieve it.
The one which hit me is Drag and Drop: if we could get IDropTarget interface of the target window, we would be able to simulate Drop operation as a substitute for the paste, in conjuction with Ole's Clipboard functions like OleGetClipboard etc. Unfortunately I'm not aware of any generic method to do it. But, there is one thing I have in mind to pursue. Alas, however, I'm feeling enervated recently, probably because it's summer.