aero wrote:
What error is being displayed ?
Is the error displayed in the Script Editor’s log ?
Or is there an error Alert dialog box being displayed ?
Setting the “statusItemWithLength:” to a negative value of “-1.0” will make the Status Bar Item invisible, which is not an error.
you would need to set the “statusItemWithLength:” to a positive value, in order to make it visible.
Or allow it to be automatically adjusted to the assigned title or image width like this.
set statusItem to statusBar's statusItemWithLength:(current application's NSVariableStatusItemLength)
Secondly the NSStatusItem’s title() function is marked as deprecated in Apple’s documentation, although it is still available in “Mojave”, it may not still be available in “Monterey”.
So it would be better to use the NSStatusItem’s button()'s title() instead, like this.
set statusBarTitle to "Status Bar Title"
set statusItem to statusBar's statusItemWithLength:(current application's NSVariableStatusItemLength)
statusItem's button's setTitle:statusBarTitle
I don’t have access to “Monterey” for testing, so there could be differences on the later OS, but the online Apple Developer Documentation still lists these functions as valid.
Your script currently does nothing other than try to display the status bar item, and then removes this item after 5 seconds, so no one can help much without knowing what your trying to achieve.
So give more info on what your trying to do with this status bar script.
Also your giving a description for an Error with an NSWindow, but you posted code has no code relevant to an NSWindow class object, so you should post that code as well If someone is going to be able to help you.
But for the record, if your trying to run code associated with windows and other UI elements, that code has to be run on the main thread, and not in a background thread, as that’s against the operating system law.
Regards Mark