Fixing the XP/2K3 calculator paste delay

The paste functionality in the classic windows calculator is implemented by generating button presses, as defined by the paste text. In windows 2000 and before these button presses can be seen. In XP this visual feedback was removed, the corresponding delay however, remains. This delay can be aggravating, especially when doing heavy calculations, after years of suffering this inconvenience I finally snapped and resolved to do something about it.

Fixing: To locate the relevant code I first located calls to GetClipboardData, of which there was one. The nearby loop which parsed the clipboard string contained no delays and simply forwarded the characters elsewhere by sending WM_COMMAND to some other window. With that avenue failing to bare fruit I instead located calls to the Sleep function, I found a single call which happened to be the offending code. The call to sleep was a fixed 20ms sandwiched in-between two calls to SendMessageW with BM_SETSTATE. I changed the delay to 0ms and the horrible delay was gone.

the code of interest

Patched calc.exe for windows 2003 x64:

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *