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
  • Great idea, Nora! Your script works for me.
    Jesús: in your script, I get the same glitch with empty segments that Nora mentions.

    I often copy text from a paragraph (without hard returns between sentences). So to use your scripts, I'd first have to add the hard returns.
    Am I right in thinking that Studio F&R doesn't allow regex in the "replace with" box? I'm trying to replace periods followed by a space
    \.\s
    with a period and hard return:
    \.\r
  • Working with Nora, we think that adding some Sleep commands make the script work (although the exact delay dependes on the PC):
    #v::
    target := Object()
    Loop, parse, clipboard, `n, `r
    target[A_Index] := A_LoopField

    nmax := target.MaxIndex()
    Loop %nmax%
    {
    clipboard := target[A_Index]
    Sleep 200 ; maybe Sleep 500
    SendInput {control down}v{control up} ; paste from clipboard
    Sleep 200
    SendInput {Down}
    }
    return
Reply
  • Working with Nora, we think that adding some Sleep commands make the script work (although the exact delay dependes on the PC):
    #v::
    target := Object()
    Loop, parse, clipboard, `n, `r
    target[A_Index] := A_LoopField

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