Hi,
I'm writing a custom clipboard application in VB .NET 2008 similar to
Ditto (http://ditto-cp.sourceforge.net/).
I have tried targeting .NET Frameworks 2.0, 3.0, and 3.5 with the same
results.
I have also tried targeting x86 and x64 CPUs. I am developing on
Windows Vista SP 1 x64.
My problem is that when pasting to IE forms, nothing is pasted! It
pastes to all other tested applications as expected.
Basically, I set the text to the clipboard and use SendKeys.Send("^V")
to send Control-V to foreground window. I am using Interop with
user32.dll's SetForegroundWindow (ByVal hwnd As IntPtr) As Long
function.
When I use SendKeys.Send() and pass the actual text as oppoesed to
Control-V, IE accepts the input as received BUT all CR's in text are
sent as {ENTER} and Posts the form. This causes undesirable results
in the form of a comment with the entire paste building at each CR. I
have been testing with a Comment field.
-------------------------------------------------
ie, trying to paste "Hello,
World"
results in two comments;
1st comment: Hello,
2nd comment: Hello,
World
Suggestions for resolving either of these issues is greatly
appreciated. Code below;
'Dim wsh As New WshShell
' Set last active window to foreground
Form1.SetForegroundWindow(awh)
' send clipped item to application in foreground
Clipboard.SetData(DataFormats.StringFormat,
lvClipped.SelectedItems(0).Text)
'Sleeping as a workaround does not fix IE paste to form
'Threading.Thread.CurrentThread.Sleep(4000)
' Using Windows Shell doesn't help IE paste to form
'wsh.SendKeys("^V")
' dispose of my COM object
'wsh = Nothing
SendKeys.SendWait("^V")
' Flushing doesn't help IE send to form
'SendKeys.Flush()