Skip to main content

If the screen is in insert mode, I would like paste to insert the text at the cursor. If the screen is *not* in insert mode, I would like paste to overwrite the text after the cursor. I.e. I want paste to behave like typing the pasted test would.

Is it possible to do get Rumba to this? I have tried combinations of the various edit options, but I can't get paste to work this way.

Thanks.


#Rumba

If the screen is in insert mode, I would like paste to insert the text at the cursor. If the screen is *not* in insert mode, I would like paste to overwrite the text after the cursor. I.e. I want paste to behave like typing the pasted test would.

Is it possible to do get Rumba to this? I have tried combinations of the various edit options, but I can't get paste to work this way.

Thanks.


#Rumba

Unfortunately from Rumba script there is no easy way to tell if the presentation space input mode is "Overwrite" or "Insert". If is possible however to read the contents of the clipboard and based upon that to use the SendKeys function to send keystrokes to the presentation space.

Here is some sample code.

Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)

Declare Function GetClipboardData Lib "User32" (Byval wFormat As Long) As Long 'Note: GetClipboardDataA as aliased in Win32api.txt did not work!

Declare Function OpenClipboard Lib "User32" Alias "OpenClipboard" (Byval hwnd As Long) As Long

Declare Function CloseClipboard Lib "User32" Alias "CloseClipboard" () As Long

'Predefined Clipboard Formats

Const CF_TEXT = 1

'Memory management functions

Declare Function GlobalLock Lib "kernel32" Alias "GlobalLock" (Byval hMem As Long) As Long

Declare Function GlobalUnlock Lib "kernel32" Alias "GlobalUnlock" (Byval hMem As Long) As Long

'String Copy function for each of its various parameter configurations lstrcpy(to_string, from_string)

Declare Function lstrcpyLP2Str Lib "kernel32" Alias "lstrcpyA" (Byval lpString1 As String, Byval lpString2 As Long) As Long

Declare Function lstrcpyStr2Str Lib "kernel32" Alias "lstrcpyA" (Byval lpString1 As String, Byval lpString2 As String) As Long

Declare Function lstrcpyStr2LP Lib "kernel32" Alias "lstrcpyA" (Byval lpString1 As Long, Byval lpString2 As String) As Long

'String Length function for each of its various parameter configurations

Declare Function lstrlenLP Lib "kernel32" Alias "lstrlenA" (Byval lpString As Long) As Long

Declare Function lstrlenStr Lib "kernel32" Alias "lstrlenA" (Byval lpString As String) As Long

'Keyboard input functions

Declare Function GetFocus Lib "User32" Alias "GetFocus" () As Long

Sub Main

Dim ClipboardHandlel As Long

Dim LpStrl As Long

Dim HWndl As Long

Dim Resultl As Long

Dim Clipboardstr As String

HWndl = GetFocus()

If (OpenClipboard(HWndl) <> 0) Then

ClipboardHandlel = GetClipboardData(CF_TEXT)

If (ClipboardHandlel <> 0) Then

LpStrl = GlobalLock(ClipboardHandlel)

Clipboardstr = Space$(lstrlenLP(LpStrl))

Resultl = lstrcpyLP2Str(Clipboardstr, LpStrl)

GlobalUnlock(ClipboardHandlel)

Else

Clipboardstr = "NULL"

End If

Resultl = CloseClipboard

Else

Print "Could not open Clipboard"

End If

Sendkeys Clipboardstr, 50

End Sub

Notes:

If you have multiple lines to insert then you will have to parse the clipboard string, to strip out the CRLF's and you will need add logic to the script to control how you send the data to the presentation space.

Once you have your script working as you wish, then you can map a key combination to execute the script.