Hi,
I’ve been fiddling around quite some time now in order to get it working without triggering errors in Trados Studio (beginning and end of line and first or last line, aso.) but now this gives custom quotation marks just like in Word. They are placed according to their relative position to the text (opening vs. closing) and not depending on if you already typed a quotation mark or not (existing script from Jesus Prieto (if I remember correctly)). It even works if you place the caret anywhere in your segment and type a ".
#IfWinActive, Trados Studio ":: OldClipboard := % Clipboard Clipboard := "" Caretx := A_CaretX Carety := A_Carety MouseGetPos, Mousex, Mousey Send ^a Send ^c ClipWait 1 if (ErrorLevel) { send „ ;open } else { MouseMove, % Caretx, % Carety Click, Left MouseMove, % Mousex, % Mousey Send, {shift down}{left} Send, {shift up} Send, ^c Send, {right} ClipWait, 2 mycheck := Clipboard if (RegexMatch(mycheck,"[^\s]")) { send “ ;close } else { send „ ;open } Clipboard := % OldClipboard } return #IfWinActive
Notes:
I set it with code to only work in Trados Studio, if you want to use it anywhere just remove the first and the last line of the above code.
It is triggered if " (straight quotation marks (Shift +2 on German keyboard)) is typed, if you want another character as trigger, just replace the " in line ":: with the character you want.
This one uses German curly quotation marks but you can just replace the quotation marks with the ones you would like to by replacing the characters before the seceral ;open or ;close parts respectively. It could also be used for Spanish exclamation and question marks as they follow the same behaviour.
You might see your mouse cursor jump around, that’s intended, so no need to worry about it.
Best regards,
Pascal
Edit: added code to keep mouse at initial position and to preserve clipboard text
[edited by: Pascal Zotto at 4:47 PM (GMT 0) on 21 Nov 2022]