PostMessage to paste clipboard
Posted on 2005-05-06
I have a visual basic control that needs to send some text to another application. I have tried to do this with SendKeys, but it is too slow and forces the window to be on top. I thought maybe the best way would be to copy the text to the clipboard and then paste it to the application using postmessage. I tried to postmessage wm_paste, but even though I saw the message using spy++, it still did not paste to the app. So, I am now trying to send Ctl-V to the application in hopes that it will paste the text. I used spy++ to see what parameters I needed to pass wm_keydown and wm_keyup by manually entering ctl-v while spying on that window's messages. Unfortunately, my code is just causing 2 v's to be typed in the app like so: "vv".
If anyone could correct my code for me or suggest another way to send text to this application, I would greatly appreciate it.
res = PostMessage(handle, &H100, &H11, &H1D0001)
res = PostMessage(handle, &H100, &H56, &H2F0001)
res = PostMessage(handle, &H101, &H56, &HC02F0001)
res = PostMessage(handle, &H101, &H11, &HC01D0001)