Script for batch tasks

I've been trying to create a script to run batch tasks by emulating the keyboard shortcuts, but I'm getting nowhere. Can anyone point me in the right direction (whichever direction that is)? E.g. I'd like to run Analyse Files, auto-select 'Finish', then 'Close', then 'Yes' (to reopen the file) and then go to first untranslated segment. Maybe trying to reinvent a wheel here?

Thanks,

Olly

Parents Reply Children
  • Hi again Jesus,
    I hope you can help me again. I have tried a few things, and thought I had the monkey by the tail, but I can't get the 'Close' stage to process in the Batch processing 'Finish' window. When I manually click on Close or hit enter the script continues to run. My adaptation of your script looks like this, and everything else works fine:

    #IfWinActive ahk_exe SDLTradosStudio.exe
    ^F5::
    Sleep 600
    Send !h
    Sleep 600
    Send !b
    Sleep 600
    Send {down}
    Sleep 500
    Send {Enter}
    WinWaitActive, Batch Processing
    Send {Enter}
    Sleep 500
    Send {Enter}
    WinWaitActive, Batch Processing ; waiting for the analysis to finish. As this is also a batch processing window, I thought I could use it here too. Or maybe you didn't use it for a reason...
    Send {Enter} ; ... but now I have to do this manually by pressing Enter
    WinWaitActive, Question ; the script now continues successfully
    Send {Enter} ; YES button
    Sleep 5000
    Send ^{Enter}
    Return
    #IfWinActive

    Thanks,

    Olly
  • There is a problem with your second WinWaitActive, and is that the script doesn't wait because the window Batch tasks is already active. That's the reason you need to press manually the Enter key.

    So you need to add an extra requirement with another parameter of the WinWaitActive function. WinTitle parameter is fine, but you need to add something like Finish completed, whatever comes up in the window as soon the task is completed. The documentation of this WinWaitActive function should help you in both batch tasks.

  • You mean I should be able to add a parameter to winwaitactive to activate the Close button? I can't find what parameter this should be. Have for the meantime added a long sleep after winwaitactive which also works, but is there a way to trigger the window to close as soon as the batch processing task has been completed? Have read the documentation but it hasn't helped me...
  • I haven’t tried, but I mean the parameter WinText.

    The line should be something like:

    WinWaitActive, Batch Processing, Finish task completed

    Where Finish task completed should be whatever comes up when the Finish task is completed. If the script doesn’t work, please set the built-in variable A_DetectHiddenText to Off and try again.

  • Nothing comes up, the task is completed and then you need to click on the Close button. Is the problem that there is no WinText under the Close button that I want activated (clicked) after the batch task has completed (according to winspy)? Also tried with detecthiddentext, off (just inserted the line at the top of the script, right?). By the way, if this is dragging on too long for, please say so!

    Olly

  • I’ve checked a bit this.

    If you use Trados Studio 2019, there is not such Finish task completed text. The only text recognised by Spy tool is Restart Preparation and it only appears when the Finish task is done. So this is what you need.

    I don’t know what you’ve already tried. but I believe this should work:

    DetectHiddenText, Off

    WinWaitActive, Batch Processing, Restart Preparation

    (Not tested)

  • Hi Again,
    I'm afraid this doesn't work either. What is that 'Restart Preparation' button actually supposed to do? It and the 'Results' button next to it do not respond when I click on them...
  • I tested these 2 lines:

    DetectHiddenText, Off

    WinWaitActive, Batch Processing, Restart Preparation

    and they work for me.

    You need to check your previous lines of your script, as I've seen a Send {Enter} which is wrong (you need to get the focus on the green button before pressing ENTER). Also, because the Finish batch task doesn't ask the user to re-open the SDLXLIFF, you need to delete the last lines of your script.

    Before writing any script, I'd recommend going manually through the keys/clicks that needed to be pressed. Only then write a line per key/click. If it doesn't work, check the point where the script doesn't work redo the script and try again. Tip for preparing scripts: use the SoundBeep command to know that the script is running that line. If everything is fine, delete that line to get no more beeps.

    Before using the Results button you need to select any of the tasks below (like Update or Generate). Then, you'll view more information about warnings and errors if any.

    I've never used the Restart Preparation button, but I guess that it can be useful if there are any errors during the preparation process, otherwise it's disabled. Not sure about that…