Jump to content

UDF - _WinSetTran_Fade


Recommended Posts

I thought I'd share this little script I made. I don't know if something like this has already been made but I found it useful. Mods, please feel free to move/delete.

This UDF will fade transparency for a specified window.

$FromNumer -> A number that it should fade from; needs to be numerical

$ToNumber -> A numer that it should fade to; needs to be numerical

$StepNumber -> Works in conjunction with $CountSpeed to set how fast the window will fade and how smooth it fades; needs to be numerical (generally 1-10)

$CountSpeed -> Works in conjunction with $StepNumber to set how fast the window will fade and how smooth it fades; needs to be numerical (generally small and easily dividable by the $ToNumber; like 2, 10, 5)

$CountWindowTitle -> Title of the window to fade

The $ToNumber and $FromNumber can be swapped to fade in and out if that's your inclination.

;EXAMPLES -
; _WinSetTrans_Fade(100, 255, 5, 1, "MyWindow")
; _WinSetTrans_Fade(255, 50, 2, 10, "MyWindow")

FUNC _WinSetTrans_Fade($FromNumber, $ToNumber, $StepNumber, $CountSpeed, $CountWindowTitle)
    Local $V
            
        For $V = $FromNumber to $ToNumber Step $StepNumber
            Sleep($CountSpeed)
                Select
                    Case $FromNumber < $ToNumber
                        $V += 1
                                
                    Case $FromNumber > $ToNumber
                        $V -= 1
                                
                EndSelect
            WinSetTrans($CountWindowTitle, "", $v)
        Next
    
    WinSetTrans($CountWindowTitle, "", $ToNumber)
    
EndFunc
Link to comment
Share on other sites

I thought I'd share this little script I made. I don't know if something like this has already been made but I found it useful. Mods, please feel free to move/delete.

This UDF will fade transparency for a specified window.

$FromNumer -> A number that it should fade from; needs to be numerical

$ToNumber -> A numer that it should fade to; needs to be numerical

$StepNumber -> Works in conjunction with $CountSpeed to set how fast the window will fade and how smooth it fades; needs to be numerical (generally 1-10)

$CountSpeed -> Works in conjunction with $StepNumber to set how fast the window will fade and how smooth it fades; needs to be numerical (generally small and easily dividable by the $ToNumber; like 2, 10, 5)

$CountWindowTitle -> Title of the window to fade

The $ToNumber and $FromNumber can be swapped to fade in and out if that's your inclination.

;EXAMPLES -
; _WinSetTrans_Fade(100, 255, 5, 1, "MyWindow")
; _WinSetTrans_Fade(255, 50, 2, 10, "MyWindow")

FUNC _WinSetTrans_Fade($FromNumber, $ToNumber, $StepNumber, $CountSpeed, $CountWindowTitle)
    Local $V
            
        For $V = $FromNumber to $ToNumber Step $StepNumber
            Sleep($CountSpeed)
                Select
                    Case $FromNumber < $ToNumber
                        $V += 1
                                
                    Case $FromNumber > $ToNumber
                        $V -= 1
                                
                EndSelect
            WinSetTrans($CountWindowTitle, "", $v)
        Next
    
    WinSetTrans($CountWindowTitle, "", $ToNumber)
    
EndFunc
how do I start it?
Link to comment
Share on other sites

Something like...

#include <GUIConstants.au3>

GUICreate("MyProgram", 200, 200)

GUICtrlCreateLabel("Fading window test", 10,10,200,35, $SS_LEFT)
GUICtrlSetFont(-1, 8, 400, 2)

$Button_2 = GUICtrlCreateButton("Fade In", 10, 60, 70, 20);Fade In
$Button_3 = GUICtrlCreateButton("Fade Out", 10,80, 70, 20);Fade Out

GUISetState()

While 1
    $msg = GUIGetMsg()

    Select

        Case $msg = $GUI_EVENT_CLOSE; -----> Close program via the X
            Exit
            
        Case $msg = $Button_2; -----> Fade In
            _WinSetTrans_Fade(100, 255, 5, 1, "MyProgram")

        Case $msg = $Button_3; -----> Fade Out
            _WinSetTrans_Fade(255, 100, 5, 1, "MyProgram")

    EndSelect

WEnd

;EXAMPLES -
; _WinSetTrans_Fade(100, 255, 5, 1, "MyWindow")
; _WinSetTrans_Fade(255, 50, 2, 10, "MyWindow")

FUNC _WinSetTrans_Fade($FromNumber, $ToNumber, $StepNumber, $CountSpeed, $CountWindowTitle)
    Local $V
            
        For $V = $FromNumber to $ToNumber Step $StepNumber
            Sleep($CountSpeed)
                Select
                    Case $FromNumber < $ToNumber
                        $V += 1
                                
                    Case $FromNumber > $ToNumber
                        $V -= 1
                                
                EndSelect
            WinSetTrans($CountWindowTitle, "", $v)
        Next
    
    WinSetTrans($CountWindowTitle, "", $ToNumber)
    
EndFunc
Edited by kickarse
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...