CodeMaster Rapture Posted May 20, 2005 Posted May 20, 2005 Hello everyone! I brought you yet another nifty function. This time I've learned from yall and provided extensive error checking. Thank you everyone who gave me hints and tips on my StringStrip function. Now, on to the yummies!!!! expandcollapse popup#cs ************************************************************************************************ Author: CodeMaster Rapture Script Function: Fades a window in or out if the OS supports it. Usage: Fade(Window Title [,Fade in/out, Speed]) Parameters: Window Title -------- The name of the window to be faded. Fade in/out ---------- A value of 1 (default) will fade in, a value of 0 will fade out. Speed ---------------- How fast the window fades from 1 (slowest) to 10 (fasest and default) ************************************************************************************************ #ce Func Fade($Window, $Fade = 1, $Speed = 10) ;Error Checking If (NOT IsInt($Fade)) OR (($Fade <> 1) AND ($Fade <> -1)) Then MsgBox(16, "Error", "Illegal call to Fade Function: $Fade only allows integers of 1 or -1.") Exit ElseIf (NOT WinExists($Window)) Then MsgBox(16, "Error", "Could not find Window titled: " & $Window & ". Exiting.") Exit ElseIf (NOT IsString($Window)) Then MsgBox(16, "Error", "Illegal call to Fade Function: $Window must be a string.") Exit ElseIF ($Window == "") Then MsgBox(16, "Error", "Illegal call to Fade Function: No Window specified.") Exit ElseIf (NOT IsNumber($Speed)) Then MsgBox(16, "Error", "Illegal call to Fade Function: $Speed must be a number.") Exit ElseIf ($Speed < 1) Then $Speed = 1) ElseIf ($Speed > 10) Then $Speed = 10 EndIf ;Begin Fade Effect WinSetTrans($Title, "", 255) If NOT @error Then ;If the OS doesn't supporty Transparencies, don't fade. If $Fade = 1 Then ;Fade-In For $loop = 1 to 255 Step 1 WinSetTrans($Title, "", $loop) Sleep(10-$Speed) Next Else ;Fade-Out For $loop = 255 to 1 Step -1 WinSetTrans($Title, "", $loop) Sleep(10-$Speed) Next EndIf EndIf EndFunc Enjoy!
GaryFrost Posted May 20, 2005 Posted May 20, 2005 take a look at the following:http://www.autoitscript.com/forum/index.php?showtopic=10678http://www.autoitscript.com/forum/index.php?showtopic=10349 SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
CodeMaster Rapture Posted May 20, 2005 Author Posted May 20, 2005 take a look at the following:http://www.autoitscript.com/forum/index.php?showtopic=10678http://www.autoitscript.com/forum/index.php?showtopic=10349<{POST_SNAPBACK}>My bad, I did a search before i posted it and didn't find those. Oh well, this is just another way to do it (and cleaner than those IMHO).Sorry,CMR
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now