How to check if a window is already centered

Hi all,

we have a trigger that centers the active window. As also a HUD is involved we want to check if the window is already centered and in this case avoid the resizing and more important the HUD action.

In theory it should be a simple piece of javascript math inside the “If Javascript Returns True” action… But we do not get values for the active window coordinates accessed from this script. Any ideas?

With best regards

You can query the focused_window_* and focused_screen_* variables in your javascript:

let windowWidth = await get_number_variable("focused_window_width");

However checking whether a window is centered can be tricky depending on what your definition of centered is :slight_smile:

I will try to duplicate the definition of BTT’s “Center Window”.