issues with remapping with Ctrl

Hi,

I have set up quite a lot of key remappings via AHK and in Trados Studio I see a strange behaviour that as soon as such a remapped key script is used that uses this format: ^(somekey):: the letter "n" is blocked for about 2 seconds after the script is executed. It does not happen with any other letter or remapping using another trigger as ^ and only in Trados Studio.

Anyone got an idea what in Trados could interfere here?

regards,

Pascal

  • If you share your full script, I can have a look at it.

    Or you can debug it and find out the culprit line. To do so, comment 50% of your script, save it, reload it, and see if it the letter N still gets blocked... Narrow down your script and in less than 10 minutes you should know what's happening.

  • Hi Jésus,

    I tried removing most of the lines before and after the mappings but to no avail.

    This is my code in the file:

    ;------------------------------------------------------------------------------
    ; CHANGELOG:
    ;
    ; CONTENTS
    ;
    ;   Settings
    ;   AUto-COrrect TWo COnsecutive CApitals (commented out by default)
    ;   Win+H code
    ;   Fix for -ign instead of -ing
    ;   Word endings
    ;   Word beginnings
    ;   Accented English words
    ;   Common Misspellings - the main list
    ;   Ambiguous entries - commented out
    ;------------------------------------------------------------------------------

    ;------------------------------------------------------------------------------
    ; Settings
    ;------------------------------------------------------------------------------
    #NoEnv ; For security
    #SingleInstance force

    ;------------------------------------------------------------------------------
    ; AUto-COrrect TWo COnsecutive CApitals.
    ; Disabled by default to prevent unwanted corrections such as IfEqual->Ifequal.
    ; To enable it, remove the /*..*/ symbols around it.
    ; From Laszlo's script at http://www.autohotkey.com/forum/topic9689.html
    ;------------------------------------------------------------------------------
    /*
    ; The first line of code below is the set of letters, digits, and/or symbols
    ; that are eligible for this type of correction.  Customize if you wish:
    keys = abcdefghijklmnopqrstuvwxyz
    Loop Parse, keys
        HotKey ~+%A_LoopField%, Hoty
    Hoty:
        CapCount := SubStr(A_PriorHotKey,2,1)="+" && A_TimeSincePriorHotkey<999 ? CapCount+1 : 1
        if CapCount = 2
            SendInput % "{BS}" . SubStr(A_ThisHotKey,3,1)
        else if CapCount = 3
            SendInput % "{Left}{BS}+" . SubStr(A_PriorHotKey,3,1) . "{Right}"
    Return
    */


    ;------------------------------------------------------------------------------
    ; Win+H to enter misspelling correction.  It will be added to this script.
    ;------------------------------------------------------------------------------
    #h::
    ; Get the selected text. The clipboard is used instead of "ControlGet Selected"
    ; as it works in more editors and word processors, java apps, etc. Save the
    ; current clipboard contents to be restored later.
    AutoTrim Off  ; Retain any leading and trailing whitespace on the clipboard.
    ClipboardOld = %ClipboardAll%
    Clipboard =  ; Must start off blank for detection to work.
    Send ^c
    ClipWait 1
    if ErrorLevel  ; ClipWait timed out.
        return
    ; Replace CRLF and/or LF with `n for use in a "send-raw" hotstring:
    ; The same is done for any other characters that might otherwise
    ; be a problem in raw mode:
    StringReplace, Hotstring, Clipboard, ``, ````, All  ; Do this replacement first to avoid interfering with the others below.
    StringReplace, Hotstring, Hotstring, `r`n, ``r, All  ; Using `r works better than `n in MS Word, etc.
    StringReplace, Hotstring, Hotstring, `n, ``r, All
    StringReplace, Hotstring, Hotstring, %A_Tab%, ``t, All
    StringReplace, Hotstring, Hotstring, `;, ```;, All
    Clipboard = %ClipboardOld%  ; Restore previous contents of clipboard.
    ; This will move the InputBox's caret to a more friendly position:
    SetTimer, MoveCaret, 10
    ; Show the InputBox, providing the default hotstring:
    InputBox, Hotstring, New Hotstring, Provide the corrected word on the right side. You can also edit the left side if you wish.`n`nExample entry:`n::teh::the,,,,,,,, ::%Hotstring%::%Hotstring%

    if ErrorLevel <> 0  ; The user pressed Cancel.
        return
    ; Otherwise, add the hotstring and reload the script:
    FileAppend, `n%Hotstring%, %A_ScriptFullPath%  ; Put a `n at the beginning in case file lacks a blank line at its end.
    Reload
    Sleep 200 ; If successful, the reload will close this instance during the Sleep, so the line below will never be reached.
    MsgBox, 4,, The hotstring just added appears to be improperly formatted.  Would you like to open the script for editing? Note that the bad hotstring is at the bottom of the script.
    IfMsgBox, Yes, Edit
    return

    MoveCaret:
    IfWinNotActive, New Hotstring
        return
    ; Otherwise, move the InputBox's insertion point to where the user will type the abbreviation.
    Send {HOME}
    Loop % StrLen(Hotstring) + 4
        SendInput {Right}
    SetTimer, MoveCaret, Off
    return

    ; ^Enter::
    ;     IfWinNotExist, Readnotify Plugin ahk_class HTML Application Host Window Class ahk_exe mshta.exe
    ;         {
    ;             Run, %A_ProgramFiles%\ActiveTracker\rn5.exe
    ;             msgbox, Hi
    ;         }
    ;     IfWinExist, Readnotify Plugin ahk_class HTML Application Host Window Class ahk_exe mshta.exe
    ;         {
    ;             msgbox, Is running
    ;         }
    ;     Return

    #c::
    InputBox,Var,Split segment AFTER the regex pattern, How many times do you want to run the split sequence?
    loop, % Var
    {
    Send {F6}
    Send, ^f ;open find menu
    Sleep 200
    Send, ^v ;paste from clipboard
    Sleep 200
    Send !a ;switch to source
    Sleep 200
    Send !v ;activate use
    Sleep 200
    Send !w ;Find Next
    Sleep 200
    Send !v ;deactivate use
    Sleep 200
    Send {Esc} ;quit find window
    Sleep 100
    Send {Right} ;a
    Sleep 200
    Send {Left} ;a
    Sleep 500
    Send !+t ;apply segmentation
    Sleep 500
    }
    Return

    ;; Split BEFORE the Regex pattern. The regex pattern will first need to be copied to the clipboard
    ;#v::
    ;InputBox,Var,Split segment BEFORE the regex pattern, How many times do you want to run the split sequence?
    ;loop, % Var
    ;{
    ;Send {F6}
    ;Send, ^f
    ;Sleep 200
    ;Send, ^v
    ;Sleep 200
    ;Send !a
    ;Sleep 200
    ;Send !v
    ;Sleep 200
    ;Send !w
    ;Sleep 200
    ;Send !v
    ;Sleep 200
    ;Send {Esc}
    ;Sleep 100
    ;Send {Left}
    ;Sleep 200
    ;Send {Right}
    ;Sleep 500
    ;Send !+t
    ;Sleep 500
    ;}
    ;Return

    ^1::  ; when press CTRL+ALT+SHIFT will output "?"
    {
    Send {U+2032} ;Minute
    }
    return

    ^2::  ; when press CTRL+ALT+SHIFT will output "?"
    {
    Send {U+2033} ;Zoll
    }
    return

    RWin:: ;the hotkey
    out:="" ;blank the variable
    While GetkeyState("RWin","p") { ;while Right Windows key is held
     Input, Var, L1 t0.1 ;record single input keys
     out.=Var ;add them to a variable
    } ;end while
    Send {asc %out%} ;send those keys as alt held numpad keys
    Return

    ^l::
    {
    SendInput {£}
    }
    return

    !n::
    {
    SendInput {ñ}
    }
    return

    ^e::Send ë

    ^+e::
    {
    SendInput {Ë}
    }
    return

    !c::
    {
    SendInput {ç}
    }
    return

    !+c::
    {
    SendInput {Ç}
    }
    return

    !o::
    {
    SendInput {ô}
    }
    return

    !+o::
    {
    SendInput {Ô}
    }
    return

    !i::
    {
    SendInput {î}
    }
    return

    !+i::
    {
    SendInput {Î}
    }
    return

    !^o::
    {
    SendInput {œ}
    }
    return

    !^+o::
    {
    SendInput {Œ}
    }
    return

    $Insert::
    {
    SendInput {Enter}
    }
    return

    ^Insert::
    {
    SendInput {Insert}
    }
    return

    ^SC034::
    {
    SendInput {…}
    }
    return

    ^+space::
    {
    Send {U+00A0} ;geschütztes Leerzeichen
    }
    return

    ^space::
    {
    Send {U+202F} ; schmales geschütztes Leerzeichen
    }
    return

    ^ü::
    {
    SendInput {é}
    }
    return

    ^+ü::
    {
    SendInput {É}
    }
    return

    ^ä::
    {
    SendInput {à}
    }
    return

    ^+ä::
    {
    SendInput {À}
    }
    return

    ^ö::
    {
    SendInput {è}
    }
    return

    ^+ö::
    {
    SendInput {È}
    }
    return

    ^5::
    {
    SendInput {‰} ;Promille
    }
    return

    ^+::
    {
    SendInput {±} ;Plusminus
    }
    return

    ^-::
    {
    Send {U+2011} ;geschützter Bindestrich
    }
    return

    !#::
    {
    Send {U+2019} ;Apostroph
    }
    return

    ^0::
    {
    Send {U+2260} ;Nicht-Gleich-Zeichen
    }
    return

    ^o::
    {
    Send {U+2300} ;Durchmesser-Zeichen
    }
    return

    ^<::
    Send, ^a
    Send, +{F3}
    Return

    +^c::
    Send, {F6}
    Send, !{F2}
    Send, ^a
    Send, ^c
    Send, {Up Down}
    Send, {Up Up}
    Send, {F6}
    Return

    ^+!c::
    Send, {F6}
    Send, !{F2}
    Send, ^a
    Send, {F6}
    Send, ^a
    Send, ^{NumpadAdd}
    Send, {F6}
    Return

    ^!Down::
    Send ^{PgDn}
    Send {Down}
    Send ^{PgUp}
    Return

    ;^y::  Winset, Alwaysontop, , A

    ^+TAB::
    Send, {F6}
    Send, {TAB}
    Send, {TAB}
    Return

    ~RButton & LButton::send ^w ;^{TAB}
    return

    ^!b::
        Text := ComObjCreate("Scripting.Dictionary")

        Text.item("z.B.") := "z. B."
        Text.item("z.b.") := "z. B."
        Text.item("z. B.") := "z. B."
        Text.item("z. b.") := "z. B."
        Text.item("zb") := "z. B."
        Text.item("zB") := "z. B."

        oCB := ClipboardAll
        Send ^c
        if Text.item(Clipboard)
        {
            Clipboard := Text.item(Clipboard)
            Send ^v
        }
        Clipboard := oCB
    return

    ^!v::
        oCB := ClipboardAll
        Send ^c
        StringReplace, OutputVar, Clipboard, %A_SPACE%,  , 1
        Clipboard := OutputVar
        Send ^v
        Clipboard := oCB
    return

    #Hotstring R  ; Set the default to be "raw mode" (might not actually be relied upon by anything yet).

    #^!Shift::
    #^+Alt::
    #!+Ctrl::
    ^!+LWin::
    ^!+RWin::
    Send {Blind}{vk07}
    return

    ^+!#d::
    Send {blind}{vk07}
    Run, "X:\Drucken"
    return

    ^+!#t::
    Send {blind}{vk07}
    Run, "C:\Z\Phase5\Pet-Needs\pet-needs.de\htdocs\Admin\Rechnungen"
    return

    ;------------------------------------------------------------------------------
    ; Fix for -ign instead of -ing.
    ; Words to exclude: (could probably do this by return without rewrite)
    ; From: http://www.morewords.com/e nds-with/gn/
    ;------------------------------------------------------------------------------
    #Hotstring B0  ; Turns off automatic backspacing for the following hotstrings.
    ;::verisign::
    return  ; This makes the above hotstrings do nothing so that they override the ign->ing rule below.

    #Hotstring B  ; Turn back on automatic backspacing for all subsequent hotstrings.
    ;:?:ign::ing


    ;------------------------------------------------------------------------------
    ; Word endings
    ;------------------------------------------------------------------------------
    ;:?:bilites::bilities


    ;------------------------------------------------------------------------------
    ; Word beginnings
    ;------------------------------------------------------------------------------
    ;:*:abondon::abandon



    ;------------------------------------------------------------------------------
    ; Word middles
    ;------------------------------------------------------------------------------
    ;:?*:compatab::compatib  ; Covers incompat* and compat*


    ;------------------------------------------------------------------------------
    ; Accented English words, from, amongst others,
    ; http://en.wikipedia.org/wiki/List_of_English_words_with_diacritics
    ; I have included all the ones compatible with reasonable codepages, and placed
    ; those that may often not be accented either from a clash with an unaccented
    ; word (resume), or because the unaccented version is now common (cafe).
    ;------------------------------------------------------------------------------
    ;::aesop::Æsop
    ::...:: …
    ::düi::déi
    ::wüi::wéi
    ::imap@::imap@translating-it.com
    ::pz@::pz@translating-it.eu
    ;------------------------------------------------------------------------------
    ; Common Misspellings - the main list
    ;------------------------------------------------------------------------------
    ;::htp:::http:
    ;::http:\\::http://
    ;::httpL::http:
    ;::herf::href

    */

    ;-------------------------------------------------------------------------------
    ;  Capitalise dates
    ;-------------------------------------------------------------------------------
    ;::monday::Monday


    #IfWinActive, ahk_class OpusApp
    NumpadSub::
    {
    Send {U+2212} ;Minuszeichen
    }
    return

    #IfWinActive, SDL Trados Studio
    NumpadSub::
    {
    Send {U+2212} ;Minuszeichen
    }
    return

    ;SetTitleMatchMode, regex
    ;SetTitleMatchMode, Slow

    ;#IfWinActive, ersetzen
    ;^Enter::
    ;{
    ;send, {TAB}
    ;send, {Enter}
    ;}
    ;return


    ;-------------------------------------------------------------------------------
    ; Anything below this point was added to the script by the user via the Win+H hotkey.
    ;-------------------------------------------------------------------------------
    #n::
    AutoTrim Off  ; Retain any leading and trailing whitespace on the clipboard.
    ClipboardOld = %ClipboardAll%
    Clipboard =  ; Must start off blank for detection to work.
    Send ^a
    Send ^c
    ClipWait 1
    if ErrorLevel  ; ClipWait timed out.
    return

    replace :=   {"\bGerätemodusanzeigen\b":"Apparatmodusindikatoren","\bModusanzeigen\b":"Modusindikatoren","\bTabelle\b":"Tabell","\bBildschirm\b":"Bildschierm","\Informationen\b":"Informatiounen"}

    haystack := Clipboard

    For what, with in replace
       result := RegExReplace(haystack,what,with)

    Clipboard =
    Clipboard := result
    ClipWait
    Send ^v

    ^!r::
    Reload, C:\Z\autohotkey\AutoHotkey.ahk

  • Thanks,

    Which hotkey do I need press to repro the behavior you mentioned in Studio?

    For example, CTRL+L just works fine.

  • any hotkey with only CTRL as trigger and right afterwards the letter "n" as plain letter. First I thought it was only for CTRL+e which should give "ë" but yesterday it turned out it happened for all other CTRL hotkeys too. I only realilzed it for "ë" as I have to use it quite a lot followed by the letter "n". Strange thing is that all other letters work fine right after pressing a CTRL hotkey and it happens on other PCs too and only in Trados Studio.

  • Ok, I've been able to repro it exactly as you said (it happens only in Studio, only after writing N) with this single line instead of your whole script:

    ^l::SendInput £

    I don't know the reason behind, but I give you 2 workarounds:

    1.- Use a hotkey that doesn't involve the CTRL key. For example, this works for me:

    #!l::SendInput £ ; WIN+ALT+L (hotkey WIN+CTRL+L wouldn't work)

    2.- Use a hotstring instead, like:

    :*:<bp::£ ; less than + B + P

  • Hi Jesus,

    the problem is that for some remapped keys, which I have to use very often, a hotstring would considerably reduce workflow and for some keys I have several other hotkeys set. So I can't replace them that easily.

    On the other side, this rather sounds like a Trados issue, so maybe devs should take a look at this?

    Maybe SDL can find out what causes this strange behaviour.

  • I'm afraid I won't be able to get any dev time to investigate this.  If you were using the APIs which we support I would be able to do this, but using AHK it won't happen.  I'd like to, but might as well be up front with you now so you know that you're on your own (and with expert users in here who may be able to help) with AHK.

    Paul Filkin | RWS Group

    ________________________
    Design your own training!

    You've done the courses and still need to go a little further, or still not clear? 
    Tell us what you need in our Community Solutions Hub

  • Hi Jesus,

    I solved this with a hotstring using + as trigger:

    e.g.

    :*:+l::
    {
    SendInput {£}
    }
    return

    at least it works fine for all letter based remappings I have and is easy to use as I hardly ever use the key +. But I'll still have to find a new trigger for my hotkeys using CTRL+number.

    EDIT: ok, works everywhere but not in Trados, at least not everytime. Disappointed

  • Good!

    The script re-maps PLUS + L to the pound sterling symbol.

    Now the cumbersome part is creating a whole mnemonic system useful for you.

    Your script works fine for me in Studio. I've tried 40 times and always worked as supposed…

  • I found the error, I must use:

    :*?:+e::
    {
    SendInput {ë}
    }
    return

    The first version works fine at the beginning of a word but I need the diacritic letters within words and that was when it did not work anymore e.g. type n and then the hotstring should not trigger. The ? prevents this behaviour within words.

    For remapping using numbers I use ! instead of ^, from what I saw there is no interference with any existing native mapping.

    !1::  ; when press CTRL+ALT+SHIFT will output "?"
    {
    Send {U+2032} ;Minute
    }
    return