Hey @peternlewis, can you shed some light on why the MENUBARHEIGHT() calculaton returns a different number when it’s retrieved from Keyboard Maestro via AppleScript, as opposed to when it’s retrieved directly in the Keyboard Maestro Editor?
For instance, in the example screenshot below, the results shown in the KM Value Inspector is 24, but when that same calculation is retrieved via AppleScript, the result is 37.
FWIW, the results are the same no matter if I test on my MacBook screen or my external screen. Any insight is appreciated, thanks I advance!
AppleScript used to retrieve the calculation (click to expand/collapse)
tell application "Keyboard Maestro Engine" to set kmCalculation to calculate "MENUBARHEIGHT()"
That's an astounding question, which I cannot answer, but I will suspect that you can synchronize both if you return your display scaling to "Default." You probably moved the setting on your Mac to the left.
I ran the AppleScript on my M2 PowerBook with the notch in the menubar and got 37. I ran it on my 13-inch Intel PowerBook and got 0 (the menu bar is hidden). And I ran it on my 17-inch PowerBook and got 24.
I believe the notch results in a deeper menubar, which the AS correctly calculates. But the standard size has been 24 pixels up until the notch was introduced.
My question doesn’t pertain so much as to the menu bar’s actual height, but rather, why does the MENUBARHEIGHT() calculation report different results when it’s called directly from Keyboard Maestro, as opposed to when AppleScript calls for it via Keyboard Maestro. It’s still Keyboard Maestro that is performing the calculation, and simply passing it to the AppleScript... so the value should not change. Unless there is some underlying voodoo that I just don’t understand which is a very real possibility.
EDIT: Digging a littler deeper, there appears to be something else at play here. Note the discrepancies in the following test macro.
It appears the Value Inspector and real-time results shown in actions display 24, whereas the calculation does indeed calculate 37.
For example, in the screenshot, the variable action indicates that the variable will be set to 24, but in reality, it’s set to 37. The Value Inspector as well shows 24 as the menu bar height, but when it’s actually used in a macro (or passed to AppleScript), the result ends up being 37.