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

  • 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.

  • Hi Paul,

    Wouldn't it have been better if the shortcut did actually work as described?

    I have dowloaded AutoHotkey but could not make it work, unfortunately.

    Ribbon icons perform Ctrl+Down function, same as shortcut, but it does not work.

    I vaguely remember seeing it work once or twice, not sure how.

    Thank you
    Best