One way is the following script. Run script, move the mouse pointer (during the delay) to see what happens. Although, I do not see any practical benefit in this.
use framework "AppKit"
use scripting additions
delay 5 -- This delay is for testing purposes. Use it to move (or not) mouse on top of screen
set |mouseLocation| to current application's NSEvent's mouseLocation()
tell application "Finder" to set theDesktopBounds to bounds of window of desktop
set |mouseLocation| to {|mouseLocation|'s x, (item 4 of theDesktopBounds) - (|mouseLocation|'s y)}
if (item 2 of |mouseLocation|) < 22 then
say "menu bar is visible" using "Alex"
else
say "menu bar is hidden" using "Alex"
end if
Thank you very much. It works very well. But it only works one moment in time. Is it possible to work always?
I have created a small application with Xcode - AppleScript. I would like that when the menu bar appears, the screen that I have created disappears. and when the menu bar is not visible, my window comes again.
In xCode, event-driven code building can have hundreds of ways to achieve the same. You will likely be helped if you submit your question to the xCode forum. But you should provide more information about what you do.