AutoHotKey not working

Hi, I use Studio 2019 and have just installed the AutoHotKey Manager plugin (and also the Microsoft program mentioned here: community.sdl.com/.../3171.ahk-plugin), but I cannot get it to work. I have added 2 scripts which I found on other Studio support pages:

#IfWinActive ahk_exe SDLTradosStudio.exe
;------------------------------------------------------------------------------
;Go to next segment
;------------------------------------------------------------------------------
^{Down}::
Send ^{PgDn}
Send {Down}
Send ^{PgUp}
return

and

#IfWinActive ahk_exe SDLTradosStudio.exe
;------------------------------------------------------------------------------
;Go to previous segment
;------------------------------------------------------------------------------
^{Up}::
Send ^{PgUp}
Send {Up}
Send ^{PgDn}
return

Their effect should be to enable Ctrl+Up/Down to move one segment up or down in a text (regardless of whether or not the segment is confirmed or not - for some reason, the default Ctrl+Up/Down keyboard shortcuts in Studio jumps to next/previous unconfirmed segment even though this does not seem to be the intended behaviour), but they do not work. I even disabled the default Ctrl+Up/Down shortcuts in Studio's settings in order to avoid conflicts, but this did not change anything. Can anyone help with this, please? Of course, if anyone can tell me how to get the "normal" Studio shortcuts for "Move to Next/Previous Segment" to do exactly this rather than moving to next/previous unconfirmed segment, that would be great, although I would also like to get AutoHotKey Manager to work!

Thanks a lot in advance.

Best regards,
Dennis

Parents
  • Hi
    Actually, I cannot remember when Ctrl+Up/Down behaved in any way other than jumping to next/previous unconfirmed segment. It is normal behavior since SDL Trados Studio 2014 as a minimum.
    What regards your script, most probably it 'does not work' because you expect a different effect. This script is for Page Up and Page Down buttons, not for Ctrl+Up/Ctrl+Down.
    I borrowed this script from Nora Diaz (2 lines look different from yours, but your script mentions PgUp and PgDn too, then why do you expect any effect from pressing Ctrl+Up/Down?):

    #IfWinActive ahk_exe SDLTradosStudio.exe
    ;------------------------------------------------------------------------------
    ;Go to next segment
    ;------------------------------------------------------------------------------
    PgDn::
    Send ^{PgDn}
    Send {Down}
    Send ^{PgUp}
    return

    #IfWinActive ahk_exe SDLTradosStudio.exe
    ;------------------------------------------------------------------------------
    ;Go to previous segment
    ;------------------------------------------------------------------------------
    PgUp::
    Send ^{PgUp}
    Send {Up}
    Send ^{PgDn}
    return

     

    It works fine. With Page Up / Page Down buttons

  • Hi Stepan Konev,

    I agree that Ctrl+Up/Down have always jumped to next/previous unconfirmed segment, but since the description in Options does not mention "unconfirmed", either the description or the function seems to be wrong. When the descriptions of these hotkeys say that they should cause a jump to "next segment", I expect that - not a jump to next unconfirmed segment. This should be looked at by SDL.

    Yes, I copied the script from Nora Diaz' post on proz.com, but I then changed it in the way I thought would cause the hotkeys Ctrl+Up/Down to work in the same way that PgUp/PgDn worked in Nora Diaz' original script, because I prefer keeping the original functioning of PgUp/PgDn. It was because of these changes that I was expecting a different result from the original script. I guess this is the meaning of scripts - that you can program them the way you want. And since that did not work, I asked for help here.

    I tried the original scripts too. They do not work, either (when pressing PgUp/PgDn). Still hoping for help!
  • Wait a minute... If so, then you have one line for Ctrl+Up key (^{Up}::)
    and another line for Page Up key (Send ^{PgUp}) right? You mix different keys within the same script. Do you think it's ok?
    Maybe it is worthy of sticking to a "single style"?

  • As I understand it, the line with two colons after it tells the script which hotkey activates the script. This can be PgUp, Ctrl+Up or whatever you want. This has nothing to do with what the script actually does. The Send commands then tells the script which "virtual key presses" to execute. It is these commands that actually causes the script to do what it is supposed to. There is no need for the hotkey (in the :: line) to be identical to the commands in the Send lines. In this case, you can use Ctrl+Up to cause a script to execute PgUp commands. Again, as I understand it - if I am wrong, someone please let me know. Either way, I also tried Nora Diaz' original scripts, and they also do not work. Neither do Paul's.
  • Ok, just open an empty Notepad file, paste this and then save with ahk extension:

    #IfWinActive ahk_exe SDLTradosStudio.exe
    ;------------------------------------------------------------------------------
    ;Go to next segment with Ctrl+Down
    ;------------------------------------------------------------------------------
    ^Down::
    Send ^{PgDn}
    Send {Down}
    Send ^{PgUp}
    return

    #IfWinActive ahk_exe SDLTradosStudio.exe
    ;------------------------------------------------------------------------------
    ;Go to previous segment with Ctrl+Up
    ;------------------------------------------------------------------------------
    ^Up::
    Send ^{PgUp}
    Send {Up}
    Send ^{PgDn}
    return

    Just tried it myself. Works

    P.S. Check if the resulting Notepad file icon turns to a green square with letter H inside, and if it appears in your tray in the right lower corner after your launching it by double clicking.

  • You're right, this method actually worked! I can now use Ctrl+Up/Down in Studio to move up or down one segment. I am not sure if this method makes the hotkeys global on my computer, because eg. webpages now also move when I use the hotkeys in my browser, but that is not a big problem. However, if you, Paul, are able to understand why this did not work when I used the AutoHotKey Manager plugin in Studio, but it does work when I use Stepan's method, I'd like to know, just so that I might be able to limit this hotkey to Studio.
    Anyway, thanks, both of you!
  • Hi Dennis,

    It sounds like there may be a misunderstanding about how AHK scripts work. I see that both Paul and Stepan have posted the steps you need to follow to make it work, so I'll just summarize them below. I apologize if any of this is too obvious, but this was the hardest part for me to understand when I was first learning AutoHotkey. Once I understood this, then it was easy to start creating and running scripts.

    To create/run AHK scripts:

    1. Download and install AutoHotkey (www.autohotkey.com/.../). Don't expect to see anything happen after you've installed the program. It runs in the background and simply allows you to run scripts, but it doesn't have an interface per se.

    2. Go to a folder in Windows Explorer where you want to save your scripts. Right-click on an empty space and select New - AutoHotkey script, give your script a name. This will create a file with the ahk extension, which will be empty, except for a few lines that are standard to any AutoHotkey script.

    3. Open the file you've just created in a simple text editor, such as Notepad or Notepad++.

    4. Paste Stepan's code below the last line in the file.

    5. Save and close the file.

    6. Find the file again in Windows Explorer and double-click it. This is the key step to actually launch the script so it will work.

    7. Check in your system tray to see that the script is active by looking for a green square icon with a white H in it. From this icon you can also reload or exit the script by right-clicking it and choosing the appropriate action.

    Once you've done this, use the hotkey combination to execute the action.The script remains active until either you exit it or you restart your computer, in which case you have to double-click the file again to launch the script once more.
  • Hi

    I think the reason it didn't work for you in Studio is because you don't understand how it's working. All the AHK manager does is provide a controlled way for adding new scripts and sharing scripts with others. But it still requires AHK to be installed first, and you have to have an ahk file available as the plugin writes to it. There's nothing more complicated to it than that.

    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

  • Nora and Paul, thanks for your explanations - you're right, Paul, I probably did not understand how AHK worked to begin with. I was expecting a function to program hotkeys in Studio - it was not clear to me that the AutoHotKey program and the Studio plugin were separate things, and that AutoHotKey was a Windows program/feature, not a Studio one. In my defence, I don't feel that the webpages I have found about the plugin make this very clear! Anyway, am I correct in assuming that:

    1) AutoHotKey is a general Windows function/program which can be used in Studio? Which also means that scrips are global (works in any program in Windows, whether intentional or not)?
    2) The AHK plugin in Studio is just an easy way to edit scripts, and I might just as well create scripts by creating .ahk files and double-clicking them? In order to activate scripts made with the plugin, I would need to go to the (rather inconveniently placed) folder where the plugin places the scrips and double-click the scripts file?
    3) No matter how I create the scripts, I will have to double-click the script files again after rebooting Windows (the plugin does not automatically enable them)? Might it be possible to somehow add scripts files to the Windows startup procedure so that they get activated automatically?
    4) Can I run several .ahk files one after another to enable several hotkeys, or would they have to be added to one .ahk file?

    Thanks for all your help!
  • A couple quick answers as I'm waiting to go into a meeting:

    1) AutoHotKey is a general Windows function/program which can be used in Studio? Which also means that scrips are global (works in any program in Windows, whether intentional or not)?

    Exactly. But the line #IfWinActive ahk_exe SDLTradosStudio.exe limits the script's functionality to Studio (or to the appropriate program when you indicate the program's names). Not sure why the hotkey was working in your browser, it should have been limited to Studio.


    3) No matter how I create the scripts, I will have to double-click the script files again after rebooting Windows (the plugin does not automatically enable them)? Might it be possible to somehow add scripts files to the Windows startup procedure so that they get activated automatically?

    Yes, there is. Go to autohotkey.com/.../FAQ.htm and then the section called "How do I put my hotkeys and hotstrings into effect automatically every time I start my PC?"

    4) Can I run several .ahk files one after another to enable several hotkeys, or would they have to be added to one .ahk file?

    Either way works. For instance, I have a single file with dozens of scripts that is called AHK Scripts for Studio that I keep running all the time, but I also have many other smaller script files that do different things and I launch them when needed.
  • Hi Nora,
    Thanks so much for taking the time to explain all this. Everything seems to work now, and I'm sure that many other users will benefit from your explanations.

    Would you happen to have some scripts you would like to share? Perhaps you have some nifty scripts for functions that I and others haven't even thought of!

    For anyone else reading this, I would like to recommend this script:
    community.sdl.com/.../72411
    which is a very practical workaround for the problem with SDL's poor integration of the Word spellchecker into Studio that causes faulty and overlapping red lines indicating (non-existent) spelling errors to appear in Studio. This problem has existed at least since Studio 2011, and please allow me to remark in passing that I honestly feel that it's a scandal that SDL have issued numerous new versions/updates that they charge a lot of money for without fixing this very basic problem.
    BR,
    Dennis
  • Hi Dennis,

    I usually share my favorite scripts here on the SDL AuthoHotkey forum and on my blog (e.g. Adding Terms to a Secondary Termbase).

    This forum is a great repository to get you started, and you can always come here to post your own scripts or ask for help when you have an idea for a script.

Reply Children
No Data