Jameser's Tech Tips

Sunday, July 23, 2006

Tip #26: Advanced Windows XP Transparency Techniques

Today's tip is on applying transparency settings to windows in Windows XP at application launch... We have previously taken a look at a method to apply a transparency effect to running applications, but today's tip will allow you to configure shortcuts with the desired transparency level...

We'll be using a utility called AutoHotKey, which is an amazing tool for automating Windows processes and creating useful Windows-centric scripts... I won't get into the details of the many facets of this program, but if you install it for the purposes of this tip, I'd recommend spending a while checking out the help file to discover what it is capable of...

AutoHotKey can be downloaded from here...

After you have downloaded and installed AutoHotKey, you can create simple scripts and save them as .AHK files, which will be processed by AutoHotKey when launched... The small script below will allow you to open Notepad (or any other program) with a transparency level of approximately 75% (192/255)...

;Hides the AutoHotKey System Tray Icon When Launched
#NoTrayIcon
;Run the Application, Don't Display Yet, and Assign PID to "ThePid"
Run Notepad.exe,,Hide,ThePid
;Allow WinWait to Detect Hidden Windows
DetectHiddenWindows, On
;Wait for the Application to Become Active
WinWait ahk_pid %ThePid%
;Set the Transparency to ~75% (192/255)
WinSet, Transparent, 192
;Show the Window Now
WinShow
;Make the Application the Active Window
WinActivate

The comments in the script should explain the purpose of each line... After you have created and saved the AHK file to your desktop, you can double-click the icon to launch the application with the transparency effects applied... You can also change the icon to the source application by selecting the shortcut's Properties and clicking on Change Icon...


Another effect I've found to be quite cool is to apply the transparency incrementally, so the application appears to fade in from invisible to fully opaque... The script below demonstrates this technique:

;Hides the AutoHotKey System Tray Icon When Launched
#NoTrayIcon
;Run the Application, Don't Display Yet, and Assign PID to "ThePid"
Run Notepad.exe,,Hide,ThePid
;Allow WinWait to Detect Hidden Windows
DetectHiddenWindows, On
;Wait for the Application to Become Active
WinWait ahk_pid %ThePid%
;Set the Transparency to ~75% (192/255)
WinSet, Transparent, 0
;Show the Window Now
WinShow
;Make the Application the Active Window
WinActivate
;Loop Up To 255 (Full Opacity) For A Cool Effect
Loop, 255 {
WinSet, Transparent, %A_index%
}


By looping through the transparency levels, we can achieve a nice fade-in effect, which should take around 1 second with a fast PC...

If you have any questions on today's tip, please leave a comment... Check back tomorrow for all new tips...

3 Comments:

  • At 9/05/2006 3:49 PM, Anonymous Anonymous said…

    Can this be applied to normal "windows" themselves?

     
  • At 9/05/2006 4:15 PM, Blogger Jameser said…

    I'm not certain that I understand your question... This technique can be used to apply transparency to an application immediately at launch... For changing the transparency of an existing window, you would use this method... Let me know if you were talking about something different...

    Thanks for the comment...

    James...

     
  • At 11/08/2006 2:32 PM, Anonymous Anonymous said…

    I think what he means is when you open a folder, let's say 'My Music' or 'My Documents'. Do you need to follow the same steps then?

     

Post a Comment

<< Home