Double Movable Sentence Highlighters

Hi all,

A problem I had with comparing source and target sentences, especially for longer sentences, was losing my place in the sentence as I switched between looking at the two.

So, I created this script to make two "highlight bars" that you can place over the source and target sentences and move as you gradually work through the sentence.

I am finding it very useful so I wanted to share it.

This is the script

#i::
file1 = C:\Users\james\Desktop\Work\yellow-bar.jpg ; insert your filepath here
file2 = C:\Users\james\Desktop\Work\pink-bar.jpg ; insert your filepath here
Gui, New
Gui, Add, Picture,, %file1%
Gui, +LastFound +AlwaysOnTop -border -caption
WinSet, Transparent, 100
Gui, Show
Gui, New
Gui, Add, Picture,, %file2%
Gui, +LastFound +AlwaysOnTop -border -caption
WinSet, Transparent, 100
Gui, Show

These are the images I use but you could use any image at all:

A plain yellow rectangular image used as a highlight bar in Trados Studio.

A plain pink rectangular image used as a highlight bar in Trados Studio.

To use this script you will need to also use this additional script:

GitHub - Hurstwood/Linux-style-mouse: An AHK (AutoHotKey) script that allows the user to move a window by grabbing it anywhere within the window.

With this, you can move the two highlight bars by holding down Alt and dragging.

Example of use:

Screenshot of Trados Studio interface showing source and target text comparison with yellow and pink highlight bars over the text.

To get rid of the highlight boxes, just reload the script.



Generated Image Alt-Text
[edited by: Trados AI at 4:26 AM (GMT 0) on 5 Mar 2024]
emoji
Parents
  • Nice one!

    A couple of enhancements:

    - No need of JPG's

    - Width, height, and colours are customisable

    - Yellow transparent window is placed at the cursor position

    - Pink window is placed close to the yellow one

    - No icons in the task bar re. the 2 transparent windows

    #i::
        CoordMode, Mouse, Screen
        MouseGetPos, x0, y0
        
        Gui, New
        Gui, +LastFound +AlwaysOnTop +Owner
        WinSet, Transparent, 50
        Gui, +LastFound -Caption
        Gui, Color, FFFF00 ; yellow
        Gui, Show, W250 H30 X%x0% Y%y0%
        
        Gui, New
        Gui, +LastFound +AlwaysOnTop +Owner
        WinSet, Transparent, 50
        Gui, +LastFound -Caption
        Gui, Color, FF00FF ; pink
        x0+= 100
        y0+= 10
        Gui, Show, W250 H30 X%x0% Y%y0%
    return

  • I added "+Resize" so that you adjust the size of the box to match the length of the sentence clause you are looking at

    #i::
    CoordMode, Mouse, Screen
    MouseGetPos, x0, y0

    Gui, New
    Gui, +LastFound +AlwaysOnTop +Owner
    WinSet, Transparent, 75
    Gui, +LastFound -Caption +Resize
    Gui, Color, FFFF00 ; yellow
    Gui, Show, W250 H30 X%x0% Y%y0%

    Gui, New
    Gui, +LastFound +AlwaysOnTop +Owner
    WinSet, Transparent, 75
    Gui, +LastFound -Caption +Resize
    Gui, Color, FF00FF ; pink
    x0+= 100
    y0+= 10
    Gui, Show, W250 H30 X%x0% Y%y0%
    return

  • Yeah, but there is visible little title bar on the top of each window. I’m sure it can be removed, but no time to check now.

  • This is a way to make variable length highlights without any border.

    With this, you can make as many boxes as you like so it essentially gives you a highlighter pen you can use anywhere on the screen. 

    Additional highlighter colours could be done with additional hotkeys as required.

    There is probably a way to "toggle" the code so that one hotkey could be used for both the start and end points but I am not smart enough to figure it out.

    CoordMode, Mouse, Screen

    F5::
    global startxpos
    global startypos
    MouseGetPos, startxpos, startypos
    return


    F6::
    MouseGetPos, endxpos, endypos
    boxw:=endxpos-startxpos
    boxh:=20
    boxy:=startypos-10
    Gui, New
    Gui, +LastFound +AlwaysOnTop +Owner
    WinSet, Transparent, 75
    Gui, +LastFound -Caption -Border ToolWindow
    Gui, Color, FF00FF
    Gui, Show, W%boxw% H%boxh% X%startxpos% Y%boxy%
    return


    F4::reload

  • Good!

    I think that dragging the window border seems more natural to me, but I give you and idea re. using only 1 hotkey:

    There is a message box with a 4-seconds timer. That's the time you can use to move the mouse to the second point of the highlighter. When timer triggers, actual mouse position is saved as the second point.

    If you press ENTER with your keyboard, the script works as well.

    If you press CANCEL key or Cancel button, the script is cancelled and no highlighter is drawn.

    If you press OK button with the mouse, the result probably won't be the desired one...

    CoordMode, Mouse, Screen
    F6::
        MouseGetPos, startxpos, startypos
        MsgBox, 33, Set the 2nd point of the highlighter window,Now move horizontally the mouse to the 2nd point of the highlighter window.,4
        
        IfMsgBox, Cancel
            return
        
        MouseGetPos, endxpos, endypos
        boxw:=endxpos-startxpos
        boxh:=20
        boxy:=startypos-10
        Gui, New
        Gui, +LastFound +AlwaysOnTop +Owner
        WinSet, Transparent, 75
        Gui, +LastFound -Caption -Border ToolWindow
        Gui, Color, FF00FF
        Gui, Show, W%boxw% H%boxh% X%startxpos% Y%boxy%
    return

Reply
  • Good!

    I think that dragging the window border seems more natural to me, but I give you and idea re. using only 1 hotkey:

    There is a message box with a 4-seconds timer. That's the time you can use to move the mouse to the second point of the highlighter. When timer triggers, actual mouse position is saved as the second point.

    If you press ENTER with your keyboard, the script works as well.

    If you press CANCEL key or Cancel button, the script is cancelled and no highlighter is drawn.

    If you press OK button with the mouse, the result probably won't be the desired one...

    CoordMode, Mouse, Screen
    F6::
        MouseGetPos, startxpos, startypos
        MsgBox, 33, Set the 2nd point of the highlighter window,Now move horizontally the mouse to the 2nd point of the highlighter window.,4
        
        IfMsgBox, Cancel
            return
        
        MouseGetPos, endxpos, endypos
        boxw:=endxpos-startxpos
        boxh:=20
        boxy:=startypos-10
        Gui, New
        Gui, +LastFound +AlwaysOnTop +Owner
        WinSet, Transparent, 75
        Gui, +LastFound -Caption -Border ToolWindow
        Gui, Color, FF00FF
        Gui, Show, W%boxw% H%boxh% X%startxpos% Y%boxy%
    return

Children