AHK to automate series of operations

Is it possible to write an AHK sequence to do the following tasks:

File -> Options

Options -> Auto-propagation

Auto-propagation: set or clear “Enable Auto-propagation” checkbox

 

Background: I frequently need to enable/disable auto-propagation

 

Unless, of course, there is a shortcut that performs this task

Parents
  • Hi Anthony,

    I was able to quickly put this together (on Studio 2017), you might need to tweak sleep times or replace keys sent if your Studio instance is not in English but another language:


    DetectHiddenText, On
    #SingleInstance
    #IfWinActive, ahk_exe SDLTradosStudio.exe

    ^!a::
    Send, {AltDown}ft{AltUp}
    WinWait, Options
    Send, editor
    Sleep, 500
    Send, auto-pro
    Sleep, 1000
    WinGetText, OptionsText, Options
    IfNotInString, OptionsText, &Enable Auto-propagation
    {
        Sleep, 1000
        WinGetText, OptionsText, Options
        IfNotInString, OptionsText, &Enable Auto-propagation
        {
            MsgBox, Something went wrong, please adjust setting manually.
            return
        }
    }
    Send, !e
    Sleep, 500
    Send, {Return}
    WinWaitClose, Options
    Return


    Hope this helps!

  • The hotkey that invokes (runs) the routine is at the beginning, followed by two colons:
    ^!a
    which stands for [CTRL]+[ALT]+[A]

    The line #IfWinActive, ahk_exe SDLTradosStudio.exe makes the hotkey context depend, i.e. it only triggers if Studio is the active window; if you press the key combination with another window active, nothing will happen, or better said, any native function linked to the same key combination will be triggered.

    You can of course change this hotkey to any combination you prefer, knowing that these are the common modifiers:

    • ^ = CTRL
    • + = SHIFT
    • # = WIN-key
    • ! = ALT
  • No question is dumb, I know when I was new to AutoHotkey I had the same question!

    , you probably already know this, but just in case it helps someone else who happens upon this thread, these are the basic steps you need to follow before running a script:

    First, download AutoHotkey (www.autohotkey.com) and install it. Once installed, you won't see anything open, that's normal. AutoHotkey runs in the background and allows you to run your own scripts (macros), which are created in plain text editors, such as Notepad or Notepad++.

    To create a new script:

    1. Go to a folder in Windows Explorer where you would like to save your script (I have a folder called AutoHotkey Scripts just to keep them all in one place). Right-click on an empty space in the folder and select New-AutoHotkey Script. Give a name to your script and save it.

    So far, you have the empty "skeleton" of a script. Now you need to enter the actions you want it to execute.

    2. Right-click on the script and select Open, then open it with a text editor, such as Notepad (I prefer Notepad++, available for free).

    3. Once the file is open, you will see that there's already some text in it. Paste the script code in a new line.

    4. Save the file. Now double-click the file, and this will load the script. Look for a green square with a white H in it in your system tray, which indicates that the script is active.

    5. Now that the script is active, press your hotkey (in this case, Ctrl+Alt+a) to trigger the actions in the script.

  • Thanks Nora for your excellent explanation

    This is a common problem I often encounter with “software” textbooks: they often assume “basic” knowledge, like here is a snippet – just include it in your program and it will do what you need to do – or call this command from this screen, but in both cases, you may not know how to get there. I can only hope that readers do not have the same problems with my textbooks!

Reply Children