# Is it posible to change z-index of floating menus on the fly?

**URL:** <https://community.folivora.ai/t/is-it-posible-to-change-z-index-of-floating-menus-on-the-fly/38231>\
**Category:** Configuration Help & General Discussion\
**Created:** [July 12, 2024, 6:38pm UTC](https://community.folivora.ai/t/is-it-posible-to-change-z-index-of-floating-menus-on-the-fly/38231 "2024-07-12T18:38:38Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jordikt](https://community.folivora.ai/user_avatar/community.folivora.ai/jordikt/32/26021_2.png) [@jordikt](https://community.folivora.ai/u/jordikt)\
**Post date:** [July 12, 2024, 6:38pm UTC](https://community.folivora.ai/t/is-it-posible-to-change-z-index-of-floating-menus-on-the-fly/38231/1 "2024-07-12T18:38:38Z")

</div>

I would like to change the z-index level of a floating menu via applescript.

Is it possible? How?

---

<div class="post-metadata">

**Author:** ![Max\_Megalon](https://community.folivora.ai/user_avatar/community.folivora.ai/max_megalon/32/23811_2.png) [@Max\_Megalon](https://community.folivora.ai/u/Max_Megalon)\
**Post date:** [July 12, 2024, 6:54pm UTC](https://community.folivora.ai/t/is-it-posible-to-change-z-index-of-floating-menus-on-the-fly/38231/2 "2024-07-12T18:54:45Z")

</div>

you could try the action: "Update Floating Menu Properties"...  
which can be triggered by Apple script ...

---

<div class="post-metadata">

**Author:** ![Andreas\_Hegenberg](https://community.folivora.ai/user_avatar/community.folivora.ai/andreas_hegenberg/32/39221_2.png) [@Andreas\_Hegenberg](https://community.folivora.ai/u/Andreas_Hegenberg)\
**Post date:** [July 12, 2024, 7:03pm UTC](https://community.folivora.ai/t/is-it-posible-to-change-z-index-of-floating-menus-on-the-fly/38231/3 "2024-07-12T19:03:25Z")

</div>

Easiest set the window level to "manual" and then update it via script like this:

```auto
tell application "BetterTouchTool"
	update_menu_item "472C606F-7D47-4173-98AF-53DAA6D48394" json "{BTTMenuWindowLevelManual: 0 }" with persist
end tell

```

(replace the UUID with the uuid of the menu, you can get that via right-click)

---

<div class="post-metadata">

**Author:** ![jordikt](https://community.folivora.ai/user_avatar/community.folivora.ai/jordikt/32/26021_2.png) [@jordikt](https://community.folivora.ai/u/jordikt)\
**Post date:** [July 12, 2024, 7:13pm UTC](https://community.folivora.ai/t/is-it-posible-to-change-z-index-of-floating-menus-on-the-fly/38231/4 "2024-07-12T19:13:19Z")

</div>

It works great, thanks!

I thought that "update\_menu\_item" was only for items inside main menus, so I was a little bit lost. Also I was trying to script "{BTTMenuCategoryZIndex: 0 }" that didn't work.

Is it possible also to script the "Window level on hover"??

---

<div class="post-metadata">

**Author:** ![Andreas\_Hegenberg](https://community.folivora.ai/user_avatar/community.folivora.ai/andreas_hegenberg/32/39221_2.png) [@Andreas\_Hegenberg](https://community.folivora.ai/u/Andreas_Hegenberg)\
**Post date:** [July 12, 2024, 7:16pm UTC](https://community.folivora.ai/t/is-it-posible-to-change-z-index-of-floating-menus-on-the-fly/38231/5 "2024-07-12T19:16:24Z")

</div>

Yes the property for "on hover" is called BTTMenuBringToFrontOnHover

(easiest way to figure out the variable name is to set some value, then copy it to a text editor and look for that value)

---

<div class="post-metadata">

**Author:** ![jordikt](https://community.folivora.ai/user_avatar/community.folivora.ai/jordikt/32/26021_2.png) [@jordikt](https://community.folivora.ai/u/jordikt)\
**Post date:** [July 12, 2024, 7:17pm UTC](https://community.folivora.ai/t/is-it-posible-to-change-z-index-of-floating-menus-on-the-fly/38231/6 "2024-07-12T19:17:37Z")

</div>

The action "Update Floating Menu Properties" works fine also!!

I wasn't aware of this action, thanks for your help @Max_Megalon

BTT grows up faster than me, there are a lot of triggers and actions that I am discovering this week.

BTT, what an amazing app!!!! 😀 😀 😀

---

<div class="post-metadata">

**Author:** ![jordikt](https://community.folivora.ai/user_avatar/community.folivora.ai/jordikt/32/26021_2.png) [@jordikt](https://community.folivora.ai/u/jordikt)\
**Post date:** [July 12, 2024, 7:21pm UTC](https://community.folivora.ai/t/is-it-posible-to-change-z-index-of-floating-menus-on-the-fly/38231/7 "2024-07-12T19:21:13Z")

</div>

> [@Andreas\_Hegenberg](#):
>
> (easiest way to figure out the variable name is to set some value, then copy it to a text editor and look for that value)

Thanks for the suggestion, Andreas.

I always do that process but searching the name of the labels, what result in more try and error.

It's definitively better to look for a aspecific value, of course. Well noted, thanks again!

---

<div class="post-metadata">

**Author:** ![jordikt](https://community.folivora.ai/user_avatar/community.folivora.ai/jordikt/32/26021_2.png) [@jordikt](https://community.folivora.ai/u/jordikt)\
**Post date:** [July 12, 2024, 8:58pm UTC](https://community.folivora.ai/t/is-it-posible-to-change-z-index-of-floating-menus-on-the-fly/38231/8 "2024-07-12T20:58:35Z")

</div>

I think there is a bug when "Window level on hover" is scripted.

I have a floating menu over the menubar. The menubar is configured to autohide. Running this applescript makes that this floating menu floats over the menubar when it's hovered, or to disappear below the menubar if it's not hovered:

```auto
	update_menu_item "4B9027EF-FCFD-48A5-ACD7-C616ABD59957" json "{BTTMenuWindowLevelManual: 24 }" with persist
	update_menu_item "4B9027EF-FCFD-48A5-ACD7-C616ABD59957" json "{BTTMenuBringToFrontOnHover: 25 }" with persist

```

The value 24 that I've set in the script for "Window Level \> Specify Level Manually" is correctly overwriting the values in BTT. So BTT shows 24.

"Window level on hover" has no option for "Specify level manually". The value 25 that I've set in the script makes that BTT sets the "Window level on hover" to "don't change". Obviously, don't change is wrong because the floating menu must change to 25 on hover.

After some tests, it seems to me that "Window level on hover" is scripted, but it doesn't "obey" the new scripted value and in some way remembers and reacts to the previous value before being scripted:

- If I set the "Window level on hover" to "menubar level (24)" and I run the script, the behaviour of the floating menu is level 24 for no hover and level 24 for hover (but copying/pasting the item shows "BTTMenuBringToFrontOnHover" : 25).

- If I set the "Window level on hover" to "normal window level (0)" and I run the script, the behaviour of the floating menu is level 24 for no hover and level 0 for hover (but copying/pasting the item shows "BTTMenuBringToFrontOnHover" : 25).

- If I set the "Window level on hover" to "maximum level" and I run the script, the behaviour of the floating menu is level 24 for no hover and level \>24 for hover (but copying/pasting the item shows "BTTMenuBringToFrontOnHover" : 25).

An additional problem happens after restarting BTT.  
Let's say I restart BTT after setting 2147483633 for hover (last example). The menu works as expected when it's not hovered. But when the menu is hovered, the floating menu leaves the menubar and it's moved to the desktop area. as its window level was \<24. Copying/pasting the item shows that "BTTMenuBringToFrontOnHover" is still 25, but the behaviour is like this:

---

<div class="post-metadata">

**Author:** ![jordikt](https://community.folivora.ai/user_avatar/community.folivora.ai/jordikt/32/26021_2.png) [@jordikt](https://community.folivora.ai/u/jordikt)\
**Post date:** [July 13, 2024, 8:40am UTC](https://community.folivora.ai/t/is-it-posible-to-change-z-index-of-floating-menus-on-the-fly/38231/9 "2024-07-13T08:40:05Z")

</div>

Hi @Andreas_Hegenberg

I have been doing more tests this morning and I have additional information regarding my previous post.

I can succesfully script the "Window level on hover" using the command "BTTMenuBringToFrontOnHover" if I use the exact values of the drop-down menu in BTT. While I was testing this, I found that some values are different from what BTT shows.

The following list shows the values that BTT has and the values that the item shows after copying/pasting the menu item in a text editor.

**MAXIMUM FLOAT ON TOP**  
BTT shows 2147483631  
Window level: 2147483633  
On hover: 2147483633

**SAME AS MOUSE CURSOR**  
BTT shows 2147483630  
Window level: 2147483630  
On hover: 2147483632

**ASSISTIVE TECH HIGH LEVEL**  
BTT shows 1500  
Window level: 1500  
On hover: 1502

**SAME AS MENUBAR**  
BTT shows 24  
Window level: 24  
On hover: 26

**LIKE A NORMAL WINDOW**  
BTT shows 0  
Window level: 0  
On hover: 2

I haven't tested the rest of options of the drop-down menu of the level windows.

So, the summary of this post and the previous one is:

- If "window level" is set to manually, the value can be updated via applescript to any value

- As "window level on hover" can't be set to manually, the value can be updated via applescript only to the specific values of the options of the drop-down menu

- Setting "window level on hover" to different values than the values of the drop-down menu, makes BTT to set "window level on hover" to "don't change". Furthermore, the "window level on hover" will have the behaviour of the last value of the drop-down menu. If BTT restart in this state, the behaviour of "window level on hover" will be as it's set to level 0.

- Some values shown in the drop-down menus are different from the values written in the menu items
