I would like to change the z-index level of a floating menu via applescript.
Is it possible? How?
I would like to change the z-index level of a floating menu via applescript.
Is it possible? How?
you could try the action: "Update Floating Menu Properties"...
which can be triggered by Apple script ...
Easiest set the window level to "manual" and then update it via script like this:
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)
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"??
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)
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!!!!
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!
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:
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:
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