WinSetTransparent

指定されたウィンドウを半透明にします。

WinSetTransparent N, WinTitle, WinText, ExcludeTitle, ExcludeText

パラメータ

N

型:整数または文字列

透明度を有効にするには、0から255の間で透明度を示す数値を指定する:0はウィンドウを不可視にし、255は不透明にする。

"Off" (case-insensitive) or an empty string may be specified to completely turn off transparency for a window. This is functionally identical to WinSetTransColor "Off". Specifying Off is different than specifying 255 because it may improve performance and reduce usage of system resources (but probably only when desktop composition is disabled).

WinTitle、WinText、ExcludeTitle、ExcludeText

型:文字列整数またはオブジェクト

もしこれらの項目が未設定または省略されたときは、最後に見つかったウィンドウが使用されます。そうでないときは、WinTitleウィンドウタイトルまたはターゲットウィンドウを識別するための他の基準、および/またはWinTextにターゲットウィンドウの単一のテキスト要素からの部分文字列(付属のWindow Spyユーティリティを使えばわかります)を指定します。

ExcludeTitleExcludeTextはウィンドウのタイトルまたはテキストで除外するために使用します。指定の仕方はWinTitleWinTextに似ていますが、ExcludeTitleはウィンドウのタイトル以外の基準(ウィンドウクラスやHWNDなど)を認識しません。

ウィンドウのタイトルとテキストは大文字と小文字を区別します。DetectHiddenWindows関数 と DetectHiddenText関数で変更しない限り、初期設定では非表示ウィンドウは検出されず、非表示テキストは検出されます。SetTitleMatchMode関数で変更しない限り、初期設定ではウィンドウのタイトルはその中のどこかにWinTitleまたはExcludeTitleを含んでいれば一致します。

エラー処理

ウィンドウが見つからないときは、TargetErrorがスローされます。

変更が適用できなかったときはOSErrorがスローされます。

備考

例えば、タスクバーを透明にするには、WinSetTransparent 150, "ahk_class Shell_TrayWnd"を使います。同様に、古典的なスタートメニューを透明にするには、例2を参照してください。スタートメニューのサブメニューを透明にするには、例3のスクリプトも含めてください。

Setting the transparency level to 255 before using Off might avoid window redrawing problems such as a black background. If the window still fails to be redrawn correctly, see WinRedraw for a possible workaround.

マウスカーソルの下にあるウィンドウのIDは、MouseGetPos関数で取得できます。

WinSetTransColor, Win functions, Control functions

メモ帳を少し透明にする。

WinSetTransparent 200, "Untitled - Notepad"

古典的なスタートメニューを透明にします(スタートメニューのサブメニューをさらに透明にするには、例3を参照してください)。

DetectHiddenWindows True
WinSetTransparent 150, "ahk_class BaseBar"

すべてのメニューまたは選択されたメニューが表示されると同時にシステム全体を透明にする。このようなスクリプトは、それ自身のメニューを透明にすることはできないが、他のスクリプトのメニューを透明にすることはできることに注意すること。

SetTimer WatchForMenu, 5

WatchForMenu()
{
    DetectHiddenWindows True  ; Might allow detection of menu sooner.
    if WinExist("ahk_class #32768")
        WinSetTransparent 150  ; Uses the window found by the above line.
}

WinSetTransparentとWinSetTransColorの効果を示す。注:TransColorの結果不可視になったピクセルの上にマウスカーソルがあるときにホットキーのいずれかを押すと、そのピクセルの下に表示されているウィンドウが代わりに操作されます!

#t::  ; Press Win+T to make the color under the mouse cursor invisible.
{
    MouseGetPos &MouseX, &MouseY, &MouseWin
    MouseRGB := PixelGetColor(MouseX, MouseY)
    ; It seems necessary to turn off any existing transparency first:
    WinSetTransColor "Off", MouseWin
    WinSetTransColor MouseRGB " 220", MouseWin
}

#o::  ; Press Win+O to turn off transparency for the window under the mouse.
{
    MouseGetPos ,, &MouseWin
    WinSetTransColor "Off", MouseWin
}

#g::  ; Press Win+G to show the current settings of the window under the mouse.
{
    MouseGetPos ,, &MouseWin
    TransDegree := WinGetTransparent(MouseWin)
    TransColor := WinGetTransColor(MouseWin)
    ToolTip "Translucency:`t" TransDegree "`nTransColor:`t" TransColor
}