AutoHotKey script for choosing translaton suggestion from AI Assistant

Hei,

I have tried to write an AutoHotKey script for automatically replacing suggestions from OpenAi provider with suggestion from AI Assistant (keyboard shortcut Alt+W), confirm and go to the next segment. I wanted to automatize this process by pressing F9 key. It seems though that my script has some error, because what happens after applying F9 is that the translation from Open Ai is chosen anyway, not the suggestion from AI Assistant.

Do you have any suggestions what should be replaced in my script?

Thank you so much for your help in advance.

Screenshot of a translation software interface with two segments of text. The left side shows text in Norwegian, and the right side shows the Polish translation. A red arrow points to the Polish translation.

; AutoHotkey script to apply translation suggestion from AI Assistant,
; confirm the current segment, and move to the next segment in SDL Trados Studio

; Set a hotkey (e.g., F9) to trigger the commands
F9::
; Activate SDL Trados Studio window
WinActivate, ahk_exe TradosStudio2024_18.0.0.1013.exe ; Adjust the executable name if necessary

; Send the command to apply translation suggestion
; Replace with the actual shortcut you use to apply AI suggestion if needed
Send, ^a ; Assuming Alt+W applies the suggestion

; Confirm the current segment
Send, ^{Enter} ; Assuming Ctrl+Enter confirms the segment


return

   



Generated Image Alt-Text
[edited by: RWS Community AI at 4:42 PM (GMT 1) on 5 Oct 2024]
emoji
Parents
  •   

    Looking at the text in the comments it looks as though you may have copied this from somewhere else and tried to adapt.  I think the simplest approach is to simply write out what you need to happen... and in this case it appears to be this:

    1. insert the AI Assistant result - Alt+W according to your comment
    2. Switch focus back to the Editor ; F6 (I didn't set a shortcut for this it just worked)
    3. Confirm the segment - Ctrl+Enter

    That's it. Check these keystrokes work when you do it manually and if they do just string them together with a script to map them to your F9 key.

    I did this:

    ;------------------------------------------------------------------------------
    ; Insert the AI Assistant Translation Result and Confirm it
    ;------------------------------------------------------------------------------
    
    #Requires AutoHotkey v2.0
    
    F9::
    {
        ; Check if SDL Trados Studio is the active window
        if WinActive("ahk_exe SDLTradosStudio.exe") {
            ; Send Alt+W to apply translation suggestion
            Send("!w")
            
            ; Small delay to ensure the first command is processed
            Sleep(200)
            
            ; Send F6 to switch focus back to the Editor
            Send("F6")
            
            ; Another short delay to ensure focus change is applied
            Sleep(200)
            
            ; Send Ctrl+Enter to confirm translation
            Send("^Enter")
        }
    }

    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

    emoji
  • Hi Paul,

    Thank you so much for your kind reply. Yes, I have asked ChatGPT to write this command, but it seemingly was wrong. Thank you so much. I will try this one. Is there any way one can learn this on ones own?

    emoji
Reply Children
No Data