Add AnyTM from the "File-based translation memory" option

I often try to add a TM that doesn't exactly match the project's language pair by using the "Use - File-based translation memory" option. Of course, this results in a message saying the TM has the wrong language pair, which means closing the message and then restarting the process to add the TM as AnyTM. Since when this happens I really mean to add the TM to the project, I wrote this script to help bypass all the extra steps. If the error message pops up, the script will get the name of the TM from the error message, close the error message, then do the necessary steps to add the named TM as AnyTM.

This script uses no hotkeys, it runs in the background and watches for the appropriate windows to perform the necessary steps.

I hope others find it as useful as I do. 

 

;–––––––––––––––––––––––––––––––––––––––––––––––-

;Add AnyTM from the "File-based translation memory" option, by Nora Díaz

;–––––––––––––––––––––––––––––––––––––––––––––––-


#IfWinActive ahk_exe SDLTradosStudio.exe
#Persistent

SetTimer, MainProcess, 1000
SetTimer, CloseWindow, 1000
return

MainProcess:
IfWinExist, Information, The translation provider
{
WinGetText, text
Send {Esc}
RegExMatch(text,"(?<=').*?(?=')",TMname)
Send !u
Send {Down 6}{Enter}
Send %TMname%
Send {Enter}
}
return

CloseWindow:
IfWinExist, Add Supported Language Pairs
WinClose
return