Window style on El Capitan

I would like to make a window of this kind:

capture 001

I tried the following but NSWindowStyleMask is only compatible with 10.12+

set theWindow to current application's NSWindow's new()
tell theWindow
	its setDelegate:me
	its setStyleMask:(current application's NSWindowStyleMaskHUDWindow)
	its setLevel:(current application's NSModalPanelWindowLevel)
	its setContentView:(containerView)
	its setContentSize:{460, 240}
	its |center|()
end tell

Subsidiary question:
Is it possible, with the use AppleScript version statement, to make a differrence between El Capitan and Sierra?
(If I’m right, they both are 2.5.)

No, it’s been around forever. And NSWindowStyleMaskHUDWindow was introduced in 10.6 — although it’s only for panels, so you might want to do the setLevel: line first to be safe. Having said that, it’s behavior might have changed.

No. But you can tell them apart using:

current application's NSProcessInfo's processInfo()'s operatingSystemVersion()'s minorVersion

Just don’t try that code before 10.11.

Is it an error on Apple’s page?

Even if I place the line setStyleMask before setLevel, the method returns an error saying “could not be coerced to type Q”
I tried also to pass the numeric value of the constant (8192).
In this case, the window looses its title bar but stays light gray.

Yes and no.

As I’ve mentioned elsewhere, with the introduction of Swift, Apple has been renaming some of its enums using a more consistent style. These enums are such a case.

So yes, the enums on that page are only available in 10.12+. But the NSWindowStyleMask enums they replaced have been around a lot longer, and importantly they still work in 10.12+. So NSWindowStyleMaskHUDWindow is the new name for NSHUDWindowMask. Try the old name.

As an aside, this is where using Script Debugger’s code-completion option to insert Cocoa terms as properties is so useful. If you use that, the fact that you might use a new name doesn’t matter, because the numeric value is put in the property, so it works just the same under older versions of the OS.

OK, that doesn’t sound promising. But as I said above, the HUD mask only works for panels. So try changing NSWindow to NSPanel. You can probably ignore the level then, too.

I’ve changed NSWindow to NSPanel.
But even if the window has the right aspect, it won’t accept the mask for close button neither for title.
I also tried with the initWithContentRect: method:

set theWindow to current application's NSPanel's alloc()'s initWithContentRect:(current application's NSMakeRect(0, 0, 460, 100)) styleMask:(8194) backing:2 defer:true

All I can get is a rectangular black window.

Yes, I don’t think you can achieve what you want without recourse to a third-party framework. When I run this:

set theWindow to current application's NSPanel's alloc()'s initWithContentRect:(current application's NSMakeRect(0, 0, 460, 100)) styleMask:((current application's NSWindowStyleMaskHUDWindow) + (get current application's NSWindowStyleMaskTitled)) backing:2 defer:false

I get:

error "Window styleMask 0x2001 is not supported for a HUD window" number -10000