Set a window Always On Top

This AutoHotkey script is related to this post:

https://community.sdl.com/product-groups/translationproductivity/f/studio/35337/why-is-the-find-and-replace-window-is-not-always-on-top

where the poster asked to set the Find and Replace window on top of the Editor.

The following script will set any window Always On Top. It works with any window, not only the Find and Replace dialog box.

I use the Application key plus the V keys as a hotkey, but you can change it to your convenience.

☛ The Application Key is also called the Menu Key and when pressed it opens a contextual menu: Screenshot of an AutoHotkey script to set the Find and Replace window in Trados Studio always on top using the Application key and V.

AppsKey & v::
        while GetKeyState("AppsKey", "P")
                Sleep, 20
        Winset, Alwaysontop, Toggle, A
return

Add these lines to your script file and when the Find and Replace window (or any window) is open and active, press the hotkey. From now on the window will be on top on any window, not that just the Editor. And it'll be on top until you close the Find and Replace dialog box or until you press again the same hotkey.

  • If you close the Find and Replace dialog box, and re-open it later, you will need to press your hotkey again to set it always on top.
  • If you use another hotkey, you might need to edit the GetKeyState parameter accordingly.

I hope it helps!



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

    The above code works works, but I've confirmed that it doesn't work if I run it in a second AutoHotkey script and I try to set a window on top with both scripts. If I reload the 2nd script, then the 1st one doesn't work. Weird…

    Have you got 2 AutoHotkey scripts running?

    BTW: This is the code I use nowadays:

    AppsKey & v::
        WinGet, ExStyle, ExStyle, A
        if (ExStyle & 0x8)  ; 0x8 is WS_EX_TOPMOST
            ; ToolTip to show alwaysON enabled
        else
            ; ToolTip to show alwaysON disabled
        Winset, Alwaysontop, Toggle, A

    return

    emoji
  • Hi

    I am trying to set and run only one script at the time.

    Could you please confirm the below steps of mine or give your step by step manual as how to set it up

    1. Home tab => Ahk => AutoHotKey scripts

    Trados Studio AutoHotKey Manager window showing no scripts listed and a path to the master script file.

    2. Copy-pasting your script text to the Scrip Content field and saving it

    AutoHotKey Manager script editing window with 'always on top' script for Find and Replace window, including script content.

    3. Closing the AutoHotKey manager window and starting a file for translation in Editor

    4. While translating, pressing Ctrl+А (to Ctrl+H) to get Find and Replace window opened (at this moment the window goes behind if clicking somewhere else in the editor)

    5. Pressing Context Menu key?

    Here is the outcome

    Find and Replace window in Trados Studio with a context menu open, showing options in a non-English language.

    Kindly clarify what I need to fix in my steps

    emoji


    Generated Image Alt-Text
    [edited by: Trados AI at 4:31 AM (GMT 0) on 5 Mar 2024]
  • just press "Ctrl f" or "Ctrl h" that is good enough.

    Screenshot of Trados Studio script editor showing code for keyboard shortcuts 'Ctrl f' and 'Ctrl h' with commands such as SendInput, Sleep, IfWinExist, WinActivate, WinSet, and Return.

    emoji


    Generated Image Alt-Text
    [edited by: Trados AI at 4:31 AM (GMT 0) on 5 Mar 2024]
  • in case you need above two hotkeys work ONLY for Trados Studio then you add this "context" (they call it this style of coding..a  "Kon Takst"...)

    Screenshot of a script for Trados Studio with hotkeys for 'Find and Replace' function. No visible errors or warnings.

    considered Trados Studio version2021 too.

    emoji


    Generated Image Alt-Text
    [edited by: Trados AI at 4:31 AM (GMT 0) on 5 Mar 2024]
  • hmmm..

    My comment stems from this post of crying for Help, Happen to be the same guy..... with the same pain in the neck.

    community.rws.com/.../search-window-hides-to-the-background

    emoji
  • Does anyone know how to solve the opposite problem? In Studio 2022, the Find and Replace window stays on top of everything even OUTSIDE Studio, which is not desirable. Is there any setting where I can choose to leave it in the background when I am not in Studio?

    emoji
  •  

    I managed to create an AHK version 2 script to solve this which I added to the original post here:

     RE: Studio 2022 Find/Replace dialog box is always displayed on top 

    All you need to do is install AutoHotkey and add this script to a file called "whateveryoulike.ahk".  Then Set this script to run whenever you start your computer.  So you have this sort of thing:

    You can get AutoHotKey from here... it's free:

    https://www.autohotkey.com/

    Make sure you Download and install v 2.0 for the script I provided to work.

    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

    emoji
  • Oh I see this too, I have no words to say how much I appreciate your help and I really apologize for "panicking" about this and posting too many questions... so now I also have instructions on AutoHotkey, I will try them as soon as I deliver my nth urgent job! Be sure that your helpfulness will return on you under many positive forms! :-))

    emoji
  • Hi Paul,
    I am writing now but do not feel urged to reply during the weekend if you are not working, answer when you can, ok?

    I started doing what you instructed me to do here above, but - to begin with - in the Programs folder I do not have the Startup folder where to put the AHK file I created...

    Screenshot of a Windows file explorer window showing the contents of the Start Menu Programs folder with various folders and shortcuts listed, such as Accessibility Windows, Windows Accessories, and OneDrive.

    emoji


    Generated Image Alt-Text
    [edited by: RWS Community AI at 5:02 PM (GMT 1) on 22 Jun 2024]
  •  

    That's odd... I would have expected to see it here:

    C:\Utenti\[NomeUtente]\AppData\Roaming\Microsoft\Windows\Menu Start\Programmi\Avvio

    Your path is slightly different, but I'm not sure about the way it would look on your system

    Perhaps try typing this in the File Explorer address bar, which should take you directly to the correct folder regardless of your language settings.

    %APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup

    If that still doesn't work for you another place you can place this file is here:

    C:\ProgramData\Microsoft\Windows\Menu Start\Programmi\Avvio

    ProgramData is a folder for all users on the computer.  Any programs or scripts placed in this folder will run for every user who logs into the system as opposed to the one in appdata which will only run for the specified logged in user ([NomeUtente]).

    See if that's any better.

    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

    emoji