Saturday, November 18, 2017

#1 2006-01-08 03:30:05 am

BMEguy
Member
Registered: 2005-09-04
Posts: 8

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:

Applescript:

--> 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:

Applescript:

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.

Offline

 

#2 2006-01-08 06:30:41 am

julifos
Administrator
From:: Malasaña, Madrid
Registered: 2002-11-20
Posts: 2014

Re: Floating Window: what am I missing?

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

Offline

 

#3 2006-01-08 08:14:31 am

Vincent
Member
From:: Germany
Registered: 2004-04-06
Posts: 205

Re: Floating Window: what am I missing?

I just use:

Applescript:

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

Window-Level constant         Value
NSNormalWindowLevel          0
NSFloatingWindowLevel         3
NSSubmenuWindowLevel        3
NSTornOffMenuWindowLevel    3
NSModalPanelWindowLevel      8
NSDockWindowLevel              20
NSMainMenuWindowLevel        24
NSPopUpMenuWindowLevel     101
NSScreenSaverWindowLevel    1001

Offline

 

#4 2006-01-08 01:20:36 pm

BMEguy
Member
Registered: 2005-09-04
Posts: 8

Re: Floating Window: what am I missing?

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.

Last edited by BMEguy (2006-01-08 01:21:02 pm)

Offline

 

#5 2006-01-08 04:10:03 pm

julifos
Administrator
From:: Malasaña, Madrid
Registered: 2002-11-20
Posts: 2014

Re: Floating Window: what am I missing?

BMEguy wrote:

jj
So the setWindowLevel is a method that Jon implemented in a custom window controller and not a Cocoa framework 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:

Applescript:

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

But it's not needed at all hmm

Offline

 

#6 2006-01-12 09:51:13 pm

mktrca
Member
Registered: 2005-07-22
Posts: 48

Re: Floating Window: what am I missing?

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

Offline

 

#7 2006-01-12 10:59:23 pm

mktrca
Member
Registered: 2005-07-22
Posts: 48

Re: Floating Window: what am I missing?

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

Offline

 

#8 2016-09-03 06:28:19 pm

noitidart
Member
Registered: 2016-09-03
Posts: 3

Re: Floating Window: what am I missing?

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

Applescript:

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.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)