Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Transparent windows in any Cocoa program System
Making terminal windows transparent seems to be a popular item, and someone asked if it would work in other apps. Well, it won't work out of the box, but there's a cool little hack that will make it work, at least for Cocoa applications.

This isn't quite perfect, as it will change the transparency of the title bar, scroll bars, etc. as well as the content, but it does make them transparent.

Read the rest of this article for the step by step instructions.

[Editor's note: I have not tried this on my machine yet. You should probably back up any file you are going to modify before you start. Sounds really cool, though!]

Here are the setup instructions:

1. Open up the file:
/System/Library/Frameworks/Foundation.framework/Contents/Resources/NSCoreSuite.scriptSuite
in PropertyListEditor, which is installed with the Developer Tools. Note that in order to save changes to this file, you'll need to open it with root access. You can do this by launching PropertyListEditor from the command line with the command "sudo open -a PropertyListEditor", which will prompt you for an admin password. When PropertyListEditor launches, you'll be able to open and save files from it as if you were root.

2. In the script suite property list, go under Classes, then NSWindow, then Attributes. In Attributes, add a new child node named "alphaValue". The values in this new node should be set as follows:

AppleEventCode: alph (actually, this can be just about any four character code, as long as it's different from the other codes used for other attributes, but it does need to be changed from its default)
ReadOnly: NO
Type: NSNumber

3. Open up the NSCoreSuite.scriptTerminology file in the English.lproj folder. Go down the same path as before and create a new node called "alphaValue". The values for this node should be:

Description: "The alpha value of the window"
Name: "alpha value"
Sex: None

Or, if your machine is set to use a different language, open up the terminology in the corresponding lproj folder for your language instead.

4. Save the changes to these two files.

Now, you should be able to write an Applescript that changes the transparency of a window of any Applescript-able Cocoa application. For example:

tell application "TextEdit"
set alpha value of front window to 0.75
end tell

A 1.0 value makes the window opaque, and a 0.0 will make it completely invisible, although it will still be on the screen (for instance, you can still minimize it). If you want to do this with a Cocoa application that doesn't have Applescript capabilities, you can do this by opening up the Info.plist in the app's bundle and adding a key named "NSAppleScriptEnabled" with the value "YES". If the app you want to script is already open, you will need to relaunch it for the changes to be usable. I don't know of any way to make windows in an app be transparent by default.
    •    
  • Currently 2.80 / 5
  You rated: 2 / 5 (5 votes cast)
 
[22,639 views]  

Transparent windows in any Cocoa program | 6 comments | Create New Account
Click here to return to the 'Transparent windows in any Cocoa program' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
didn't work (10.0.4)
Authored by: beef on Jul 29, '01 10:33:36AM

I just tried this as instructed... but didn't work...

the directory where the files were located was a bit different... but I think I was using the right files... (there was no ....../contents/... or something like that.... maybe it's a bit different in 10.0.4)

did anyone actually get this to work?



[ Reply to This | # ]
didn't work (10.0.4)
Authored by: beishmael on Aug 29, '01 05:54:23PM

I got it to work, but it didn't modify the application that I was most interested in changing (Internet Explorer namely).

The main trick I found was to make sure that alphaValue does not have a space in it (the directions look like they have a space), and make sure the capitalization is the same everywhere.

I successfully wrote a applescript to modify the Text Editor's transparency level.



[ Reply to This | # ]
didn't work (10.0.4)
Authored by: oem on Sep 23, '01 09:31:20PM

It doens't work for me neither :

I've got this message : Can't get window 1 of "textEdit".

if anyone know where I'm wrong??
hope it's in my applescript syntaxe, but the syntaxe looks ok.
never mind.



[ Reply to This | # ]
didn't work (10.2.4)
Authored by: DCohen on Feb 22, '03 05:47:10PM

Yeah, I think this hint is out dated and does not work.... a lot of the features of the System Events scripting does not always work....



[ Reply to This | # ]
didn't work (10.2.4)
Authored by: WinterSolstice on Jul 13, '04 09:11:43AM

This works fine in Panther (10.3.4, though the path is a little different).

I sucessfully copied and pasted this applescript to modify TextEdit.

-WS



[ Reply to This | # ]
Transparent windows in any Cocoa program
Authored by: GlowingApple on Mar 27, '07 07:01:02PM
There's a program that has the same effect (and is free) called SetAlphaValue (http://www.mparrot.net/). Might just do the same thing, but in any case it provides a nice GUI for each app and I have had success with every Cocoa app I've used it on.

---
~Jayson <www.kempinger.homelinux.net>

[ Reply to This | # ]