Paste text from another program into Studio, one sentence per segment

For this script to work, the block of text needs to be pasted into the first segment before activating the script. Furthermore, the "Use Regular Expressions" checkbox in the Find dialog in Studio must be unchecked before running the script, as the script checks and then unchecks the box each time the sequence is run. The script assumes that there's a hard return between each new sentence/segment. See a short demo video of the script in action here: 

 

 

#IfWinActive ahk_exe SDLTradosStudio.exe
;––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-
; Cuts text AFTER the Regex pattern, then pastes it into the next segment. The regex pattern is new line \n.
; After pasting the text into the first segment, press Windows+V to activate
;––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––-

#v::
InputBox,Var,Paste one sentence per segment (by Nora Díaz), How many times do you want to run the sequence?
loop, % Var
{
Send ^{PgUp}
Sleep 100
Send, ^f
Sleep 200
Send, \n
Sleep 200
Send !t
Sleep 200
Send !u
Sleep 200
Send !n
Sleep 200
Send !u
Sleep 200
Send {Esc}{Right}
Sleep 100
Send ^+{PgDn}
Sleep 100
Send ^x{Delete}{Backspace}
Sleep 100
Send {Down}^v
Sleep 200
}
Return

Parents Reply
  • Yes, I could repo it.

    The reason is that SendRaw command is really reall slow and I think the script was “fighting” with Studio whith the 100% matches.

    Anyway, I created the following script which works fine for me:

    #v::
        target := Object()
        Loop, parse, clipboard, `n, `r
            target[A_Index] := A_LoopField


        nmax := target.MaxIndex()
        Loop %nmax%    
        {
            clipboard := target[A_Index]
            SendInput {control down}v{control up} ; paste from clipboard
            SendInput {Down}
        }
    return

    In case you want to edit the script:

    • The 1st loop populates the array target with each line of the Clipboard.
    • The 2nd loop copies each element of the array in the Clipboard, pastes it (much faster than Send comands) and goes down 1 line in Studio.
    • I’ve tested it with a 100-line Clipboard and no problem (as long as Trados Studio keeps the focus).
    • I’ve tested with just plain text. To get also the tags, we'd need a different script. I didn’t try…

    Does it work for you?

Children
  • Hi Jesus,

    I've just tried it and it doesn't work for me. The script will sometimes paste the second or third segment into the first one, and then will only go down without pasting anything else.