Add tags with a single keystroke

Here's one  and I collaborated on. We've been meaning to write about it in our blogs, but here it is in the meantime. Further explanation to come in the blog article, but in a nutshell it allows you to insert tags sequentially by pressing a single key while ignoring placeables. As you can see, this script uses the Left Windows key.

The script assumes that the default Ctrl+Enter shortcut is used to confirm segments. If a different shortcut is used, it needs to be replaced accordingly on the last line of the script.

;Add tags with LWin key

n:=1
return

Lwin::
if (n = 1)
Send, ^!{Right}{Esc}{Right}
else
{
Send, {Ctrl Down}{Alt Down}{Right %n%}
Sleep 200
Send, {Ctrl Up}{Alt Up}{Esc}{Right}
}
n++ ; increment n
return

~^Enter::n := 1 ;script is reset with Confirm and Move to Next Segment shortcut, tilde is needed to pass through the original action for Ctrl+Enter

Parents
  • Dear @Nora Días,

    Your script is very helpful, but I wonder if there is a way to insert tags separately with a single keystroke, without having to select the text inside the tags. What I mean is that every time we press "LWin key" (or other key you choose) Studio inserts the next following partial tag (opening tag or closing tag) which are in source segment.

    For instance, if we have something like that:
    <tag1>Gracias</tag1> a la vida <tag2>que me</tag2> ha dado tanto.

    we could do this:
    press LWin key >> Studio inserts the first opening tag
    type Gracias
    press LWin key >> Studio inserts the first closing tag
    type a la vida
    press LWin key >> Studio inserts the second opening tag
    type que me 
    press LWin key >> Studio inserts the second closing tag
    type ha dado tanto.

    I think memoQ has something like that (with F9).

    If I do not made myself clear, please ask me.

    Un abrazo, 
    Silvia

  • Hi Silvia,

    Partial tags would require using Quickplace and that has two complications for a script like this: 1. Other non-tag placeables are included in the list and 2. The opening and closing partial tags do not appear sequentially in the Quickplace list.

    However, here's a variation of the script that may help a little. It places the cursor inside the tag pair, where you can then simply start typing. Would that help? Keep in mind that it will also move the cursor to the left of any placeholder tags inserted this way.

    #IfWinActive ahk_exe SDLTradosStudio.exe

    n:=1
    return

    Lwin::
    if (n = 1)
    Send, ^!{Right}{Esc}{Right}{Left}
    else
    {
    Send, {Ctrl Down}{Alt Down}{Right %n%}
    Sleep 200
    Send, {Ctrl Up}{Alt Up}{Esc}{Right}{Left}
    }
    n++ ; increment n
    return

    ~^Enter::n := 1 ;script is reset with Confirm and Move to Next Segment shortcut, tilde is needed to pass through the original action for Ctrl+Enter

Reply
  • Hi Silvia,

    Partial tags would require using Quickplace and that has two complications for a script like this: 1. Other non-tag placeables are included in the list and 2. The opening and closing partial tags do not appear sequentially in the Quickplace list.

    However, here's a variation of the script that may help a little. It places the cursor inside the tag pair, where you can then simply start typing. Would that help? Keep in mind that it will also move the cursor to the left of any placeholder tags inserted this way.

    #IfWinActive ahk_exe SDLTradosStudio.exe

    n:=1
    return

    Lwin::
    if (n = 1)
    Send, ^!{Right}{Esc}{Right}{Left}
    else
    {
    Send, {Ctrl Down}{Alt Down}{Right %n%}
    Sleep 200
    Send, {Ctrl Up}{Alt Up}{Esc}{Right}{Left}
    }
    n++ ; increment n
    return

    ~^Enter::n := 1 ;script is reset with Confirm and Move to Next Segment shortcut, tilde is needed to pass through the original action for Ctrl+Enter

Children