Hi,
I'm trying to copy a selected text from another program running and paste it into a variable.
What I'm doing is the following
1) hide the VB.NET form
2) System.Windows.Forms.SendKeys.SendWait("^C") (send ctrl+C = the shortcut for the copy function in the other application)
3) show the VB.NET form again
4) paste the contents of the clipboard
* using the Application.DoEvents() doens't seem to make a difference
This works when I run the program for the first time. After that, it doesn't do anything anymore. When I close the form and open it again, the copy function works fine again for 1 copy / paste action.
I read on msdn that I should replace SendKeys with SendInput (for Win XP, vista, ...) , but I can't get this to work. Can anybody tell me if it's possible to work with SendKeys or someone has an example with the SendInput function?
I'm trying to copy a selected text from another program running and paste it into a variable.
What I'm doing is the following
1) hide the VB.NET form
2) System.Windows.Forms.SendKeys.SendWait("^C") (send ctrl+C = the shortcut for the copy function in the other application)
3) show the VB.NET form again
4) paste the contents of the clipboard
* using the Application.DoEvents() doens't seem to make a difference
VB.NET:
Dim info As String
Me.Hide()
Application.DoEvents()
System.Windows.Forms.SendKeys.SendWait("^c")
Application.DoEvents()
Me.Show()
Application.DoEvents()
info = Clipboard.GetText
This works when I run the program for the first time. After that, it doesn't do anything anymore. When I close the form and open it again, the copy function works fine again for 1 copy / paste action.
I read on msdn that I should replace SendKeys with SendInput (for Win XP, vista, ...) , but I can't get this to work. Can anybody tell me if it's possible to work with SendKeys or someone has an example with the SendInput function?