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.
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
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.”