S
sy0116
Unregistered / Unconfirmed
GUEST, unregistred user!
用下面的代码实现在按下热键时把剪贴板里的内容换成“SSS”然后模拟按键Ctrl+V粘贴,最后再把剪贴板原来的内容还原,可是为什么每次按下热键时粘贴出来的都不是“SSS”而是剪贴板里原来的内容呢?而且经常出现“Cannot open clipboard”的错误提示。<br>procedure tform1.ONHotkey(var message:Tmessage);<br>begin<br>txt0:=Clipboard.AsText;<br>Clipboard.AsText:='sss';<br>keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL, 0), 0, 0);<br>keybd_event(Ord('V'), MapVirtualKey(Ord('V'), 0), 0, 0);<br>keybd_event(Ord('V'), MapVirtualKey(Ord('V'), 0), KEYEVENTF_KEYUP, 0);<br>keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL, 0), KEYEVENTF_KEYUP, 0);<br>Clipboard.AsText:=txt0;<br>end;<br>