Floating Window: what am I missing?

It seems that I can’t even cut-and-paste right, despite the fact that others have asked the exact questions I have. I want to make a window that floats above all others, so I searched and found this thread: http://bbs.applescript.net/viewtopic.php?id=14481.

Inside there is this this code example:

--> alpha-ize
tell window "whatever"
   set opaque to false
   set alpha value to 0.7
end

--> floating-ize
call method "setWindowLevel:useLevel:" of class "methods" with parameters {window "whatever", "NSFloatingWindowLevel"}
--> use "NSNormalWindowLevel" to restore

(*

Credits go to Jonathan Nathan for the "setWindowLevel:useLevel:" method knowledge

*)

So I try to implement this in my project:

on will open theObject
	if the name of theObject is "mainwindow" then
		tell theObject
			set enabled of matrix "beforeAfter" to false
			
			set opaque to false
			set alpha value to 0.85
			
		end tell
		call method "setWindowLevel:useLevel:" of class "methods" with parameters {window "mainWindow", "NSFloatingWindowLevel"}
		
		--> use "NSNormalWindowLevel" to restore
		
	end if
end will open

the transparency works fine, but the window won’t stay on top. I’ve tried both with the “call method” in the tell block and outside.
Also I couldn’t find any mention of a setWindowLevel method, just a setLevel method.

Again, thanks for your help and advice.

Take a look to the new project by Jon: http://homepage.mac.com/jonn8/as/dist/titlelessWindows.zip

I just use:

set level of window x to 3
set hides when deactivated of window x to false

jj
So the setWindowLevel is a method that Jon implemented in a custom window controller and not a Cocoa framework method?

Vincent:
Thanks for that summary of the level constants. I got it to work with the simple “set” you recommend.

Yes, sorry. It was a class file called “methods.m” (not a custom window implementation). It included some more sounds and whistles to build titleless anchored windows…

The “call method” equivalent for Vincent’s code would be:

call method "setLevel:" of window "blah" with parameter 3

But it’s not needed at all :confused:

At the risk of asking a dumb question, where in your script do you use this code?

set level of window x to 3
set hides when deactivated of window x to false

Thanks
-r

Never mind, I figured it out.
Thanks anyway.
-r

Hi folks,
I tried the set level approach to set whatever is the current foreground window to be always on top. However it errors:

global frontApp, frontAppName, windowTitle
delay 3
set windowTitle to ""
tell application "System Events"
    set frontApp to first application process whose frontmost is true
    set frontAppName to name of frontApp
    tell process frontAppName
        set level of window 1 to 3
        tell window 1
            set windowTitle to value of attribute "AXTitle"
        end tell
    end tell
end tell

return {frontAppName, windowTitle}

The error I get is “System Events got an error: Can’t make level of window 1 of process “firefox” into type specifier.”

May you please advise.