WinSetTransparent()

Auto Hotkey

WinSetTransparent

Makes a window semi-transparent.

WinSetTransparent Value , WinTitle, WinText,  ExcludeTitle, ExcludeText
Command  Example: WinSetTransparent 150, "A"
Function Example: WinSetTransparent(150, "A")

Parameters

Value

Specify a number between 0 and 255 to indicate the degree of transparency: 0 makes the window invisible while 255 makes it opaque. Transparency may be turned off completely for a window by specifying the word OFF. This is different than specifying 255 because it may improve performance and reduce usage of system resources.

WinTitle

A window title or other criteria identifying the target window. See WinTitle.

WinText

If present, this parameter must be a substring from a single text element of the target window (as revealed by the included Window Spy utility). Hidden text elements are detected if DetectHiddenText is ON.

ExcludeTitle

Windows whose titles include this value will not be considered.

ExcludeText

Windows whose text include this value will not be considered.

Known Limitations for Transparent and TransColor:

  • They have no effect on a window that lacks a caption (title bar) and lacks the always-on-top property. For GUI windows, this can be solved by removing the caption only after making the window transparent. Alternatively, the following properties allow transparency to take effect: Gui -Caption +ToolWindow.
  • Setting "Transparent" to 255 prior to turning it off might avoid window redrawing problems such as a black background. If the window still fails to be redrawn correctly, see Redraw for a possible workaround.
  • To change a window's existing TransColor, it may be necessary to turn off transparency before making the change.

Tip: To make the task bar transparent, use WinSet, Transparent, 150, ahk_class Shell_TrayWnd. Similarly, to make the Start Menu transparent, follow this example:

DetectHiddenWindows, on
WinSet, Transparent, 150, ahk_class BaseBar  ; To make the Start Menu's submenus transparent, also include the script below.

To make all or selected menus on the entire system transparent, keep a script such as the following always running. Note that although such a script cannot make its own menus transparent, it can make those of other scripts transparent:

#Persistent
SetTimer, WatchForMenu, 5
return  ; End of auto-execute section.

WatchForMenu:
DetectHiddenWindows, on  ; Might allow detection of menu sooner.
IfWinExist, ahk_class #32768
    WinSet, Transparent, 150  ; Uses the window found by the above line.
return

Remarks

ErrorLevel is not changed by this command except where indicated above.

Although transparency is supported on Windows 2000/XP or later, retrieving the current transparency settings of a window is possible only on Windows XP or later (via WinGet).

Window titles and text are case sensitive. Hidden windows are not detected unless DetectHiddenWindows has been turned on.

Related

WinGet, WinHide, WinSetTitle, WinMove, WinActivate, Control

Examples

WinSetTransparent, 200, Untitled - Notepad ; Make the window a little bit transparent.