How to paste text from the clipboard to the cursor position?
I need code for automatic paste from clipboard, thanks.
btw I've tried fx.clipboard.getstring but that didn't work in notepad!!
Sub Button1_Action
If fx.Clipboard.HasString Then
Dim i As Int = TextArea1.SelectionStart
Dim s As String = fx.Clipboard.GetString
TextArea1.Text = TextArea1.Text.SubString2(0, TextArea1.SelectionStart) & s & _
TextArea1.Text.SubString(TextArea1.SelectionEnd)
TextArea1.SetSelection(i + s.Length, i + s.Length)
TextArea1.RequestFocus
End If
End Sub
Hi Erel, I am using fx.clipboard with the contextmenu example provided by Steve05, so when selecting an item from the menu a string should be pasted at the cursor.
It's outside the form, in any application. So far I can set a string in the clipboard but not paste it automatically at the cursor.
I know this is possible in C sharp but not in B4J. Please help me again!!
fx.clipboard.GetString() returns the String contents of the clipboard (if there are any). It doesn't paste anything. If you want to programmatically paste something, you need to invoke the "ctrl_v" or the OS-specific equivalent key combo. The jAWTRobot library can do this for you.