Jump to content

Play with transparency


Apzo
 Share

Recommended Posts

Hello.

I just found the WinSetTrans function, realy cool !

So here is a simple code to get any window transparent or solid, using a tray icon and some hotkeys (modify them to suit your needs).

Opt("GUIOnEventMode", 1)

Opt("TrayMenuMode",1)
Opt("WinTitleMatchMode", 3)

$transp = TrayCreateMenu("Transparency")
$help = TrayCreateItem("Help", $transp)
$exit = TrayCreateItem("Quit", $transp)
TraySetToolTip ("Transparency")
TraySetState ()

HotKeySet("#{F10}", "transp")
HotKeySet("#{F11}", "solide")
HotKeySet("#{F12}", "CLOSEClicked")

While 1
    $msg = TrayGetMsg()
    Select
        Case $msg = 0
            ContinueLoop
        Case $msg=$help
            help()
        Case $msg = $exit
            CLOSEClicked()
    EndSelect
    Sleep(100)
Wend

Func help()
    MsgBox(-1, "Help", "Select a window."&@CR&"Win + F10 to get it transparent."&@CR&"Win + F11 to get it solid."&@CR&"Win + F12 to quit.")
EndFunc

Func transp()
    $ti = GetTitle()
    WinSetTrans($ti, "", 210)
EndFunc

Func solide()
    $ti = GetTitle()
    WinSetTrans($ti, "", 255)
EndFunc

Func GetTitle()
    $T = ""
    $L = WinList()
    
    If $L[0][0] > 1 Then
        For $i = 0 To $L[0][0]
            If $L[$i][0] <> "" Then
                If BitAnd (WinGetState($L[$i][0]), 8 ) Then
                    $T=$L[$i][0]
                EndIf
            EndIf
        Next
    EndIf
    Return $T
EndFunc

Func CLOSEClicked()
    Exit
EndFunc

Func OnAutoItExit()
    Exit
EndFunc

I had some troubles to get the name of the current active window, I used WinList and WinGetState but perhaps I missed something ?

Have fun B)

Apzo.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...