Help with script - Copy clipboard content into custom field in Project Settings

Hi everyone!

I need some help with perfecting a script. I used Nora’s script as a starting point. My script works… sometimes. There are some problems with the sleep delays, as my computer can be slow to open the project settings, but that I can adjust.

What happens often is that the CTRL + V step is sent too soon/late (not quite sure), so I can see the script play out, but nothing is copied into the custom field. 

I tried using super long sleep times to see if it was just a matter of speed, but it didn’t seem to prevent the problem.

Any idea? Maybe using Clipboard commands instead of the ctrl + v one? I’m an (enthusiastic) ahk beginner so I’m not yet familiar with the Clipboard commands! 

Here’s a Screenshot of the custom field and my current script:



Trados Studio Project Settings window with a custom field open for text entry, but no text is pasted into the field.


^+t::
Send ^+p ;custom Studio Shortcut to open the Project settings
Sleep 999
Send Proj
Sleep 999
Send Lang
Sleep 999
Send All
Sleep 999
Send TR
Sleep 999
Send U
Sleep 999
Send {Tab 2}
Sleep 999
Send {F2}
Sleep 999
Send ^v
Sleep 999
Send {F2}
Sleep 999
Send {Enter}

When in the Project screen with a project selected, the hotkey should open Project settings, navigate to the Update screen, open the custom field and copy the content of the clipboard, then close the text box and move selection to the OK button without clicking it, allowing me to double check the copied text before clicking ok.

Thanks in advance! 



Generated Image Alt-Text
[edited by: Trados AI at 4:24 AM (GMT 0) on 5 Mar 2024]
emoji
Parents
  • Hi ,

    I haven't tried your script, so sorry if I can't help.

    On the other hand, I've used some scripts to open the Project Settings dialog box and I always noticed the the first time this dialog box is open it takes quite a long time. More than one second, if I recall correctly.

    If I'm right, you'd need to increase the first Sleep to something like this:

    Sleep 2000 ; wait for 2 seconds

    And see if it works.

    Otherwise I'd recommend to debug your script. To do so, you can comment some lines (inserting a semicolon character [;] at the beginning of the line), save it, reload it, and check that the script works as expected until your commented lines. If it works, uncomment a few lines more and re-check. Otherwise you know that there is something you need to change in your uncommented lines.

    ☛ Probably you should be able to decrease all the timers of your script, but the first one, that I recommend to increase it as mentioned above.

    I hope it helps,

Reply
  • Hi ,

    I haven't tried your script, so sorry if I can't help.

    On the other hand, I've used some scripts to open the Project Settings dialog box and I always noticed the the first time this dialog box is open it takes quite a long time. More than one second, if I recall correctly.

    If I'm right, you'd need to increase the first Sleep to something like this:

    Sleep 2000 ; wait for 2 seconds

    And see if it works.

    Otherwise I'd recommend to debug your script. To do so, you can comment some lines (inserting a semicolon character [;] at the beginning of the line), save it, reload it, and check that the script works as expected until your commented lines. If it works, uncomment a few lines more and re-check. Otherwise you know that there is something you need to change in your uncommented lines.

    ☛ Probably you should be able to decrease all the timers of your script, but the first one, that I recommend to increase it as mentioned above.

    I hope it helps,

Children