3
votes

I'm looking to use a command "rwn" with AutoHotKey to select all and copy existing text from a text box - insert a predefined script - then insert the copied text midway into the predefined script.

This is what I have so far - I've tried it in a few different variations but none seem to work.

::rwn::
{
Send ^a
Sleep 30
Send ^c
}
1 - Validated Customer Details:`n     Building: `n     Level & room: `n     Contact Office: x`n     Contact Mobile: 04`n`n2 - Original request information:`n     
{
Send ^v
} 
`n`n3 - New Restoration OR Existing Problem:`n     `n`n4 - Work Details:`n     `n`n5 - Remote Access:`n     Attempted (SCCM) Successful (SCCM) Not Available`n`n6 - Can be Resolved 

directly by me?`n     YES NO`n`n7 - Capture User Interaction`n     `n`n8 - Customer's understanding of resolution:`n     `n`n9 - KM Record potential:`n     Yes No`n  
return 
1
Still not quite clear. You want to 1. Select all text, 2. Copy text to clipboard, 3. with the highlighted text send one or more predefined text lines (replacing the original text), 4. Paste the original text from your clipboard under the previously added text, 5. Append the pasted text with some predefined finishing text lines. Is this correct? - Robert Ilbrink

1 Answers

3
votes

Ruberto,

I tested this in Notepad, so I changed the Carriage Return/New Line to work properly in Notepad. Instead of sending the text character by character, which is slow, I stored everything in variables, You could also store them directly in ClipBoard if you wanted to. Give this a try and tell me the results. On a personal level, how well is the KM process working with this approach?

:*:rwn:: ; Added * so you don't have to press Enter after rwn
Send ^a ; Select All
Sleep 30 ; Wait 30 ms.
Send ^c ; Copy incident text to clipBoard
ClipWait ; Wait for clipboard to fill
; Define 3 variables with text, pasting text from the clipboard is much faster than sending text. Since I tested it in Notpad, I had to use `r`n Carriage Return, New Line
Text1 = 1 - Validated Customer Details:`r`n     Building: `r`n     Level & room: `r`n     Contact Office: x`r`n     Contact Mobile: 04`r`n`r`n2 - Original request information:`r`n`r`n
Text2 = %ClipBoard%
Text3 = `r`n`r`n3 - New Restoration OR Existing Problem:`r`n`r`n`r`n4 - Work Details:`r`n`r`n`r`n5 - Remote Access:`r`n`r`n`r`nAttempted (SCCM) Successful (SCCM) Not Available`r`n`r`n6 - Can be Resolved directly by me?`r`n     YES NO`r`n`r`n7 - Capture User Interaction`r`n     `r`n`r`n8 - Customer's understanding of resolution:`r`n     `r`n`r`n9 - KM Record potential:`r`n     Yes No`r`n
ClipBoard = %Text1% ; Store fixed text 1 in clipboard
Send, ^v ; Paste clipboard content
ClipBoard = %Text2% ; Store incident text 2 in clipboard
Send, ^v ; Paste clipboard content
ClipBoard = %Text3% ; Store fixed text 1 in clipboard
Send, ^v ; Paste clipboard content
return

Oh b.t.w. I tested this with AutoHotKey_L, but it should also work with the regular AutoHotKey.