insignia96 Posted December 12, 2009 Posted December 12, 2009 (edited) This is a simple little UDF I made that fades your GUI in with pure AutoIt.To show your GUI simply call the _FadeGUIIn() function, the only parameter is a handle to the GUI, and it will fade in. here is the UDF:expandcollapse popup#include-once ; #INDEX# ======================================================================================================================= ; Title .........: GUI Fading Script ; Description ...: This module contains functions used to fade a GUI in and out with pure AutoIt code. ; AutoIt Version.: 3.3.0.0 (Current Release) ; Author ........: Insignia96 (iWoW Programming) ; =============================================================================================================================== ; =============================================================================================================================== ; #NO_DOC_FUNCTION# ============================================================================================================= ; Not working/documented/implimented at this time ; =============================================================================================================================== ; NONE ; =============================================================================================================================== ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ;_FadeGUIIn ;_FadeGUIOut ; =============================================================================================================================== ; #DECLARES# ;=============================================================================== ; Global $GUIFADE_MAXTRANS = 255 ; the current max transparency level ; ; ;========================================================================================== ; #FUNCTION# ;=============================================================================== ; ; Name...........: _FadeGUIIn ; Description ...: Gradually shows a GUI. ; Syntax.........: _FadeGUIIn( $hWnd ) ; Parameters ....: $hWnd - Handle to GUI you wish to fade in. ; $iMax - The transparency level to stop at. (0-255, 0 = hidden, 255 = fully shown) ; Return values .: None ; Author ........: Insignia96 (iWoW Programming) ; Modified.......: Saturday, December 12, 2009 ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; Yes ; ; ;========================================================================================== Func _FadeGUIIn($hWnd,$iMax=255) $GUIFADE_MAXTRANS = $iMax WinSetTrans($hWnd, "", 0) GUISetState(@SW_SHOW) Local $delay = 0 For $i = 1 To $iMax Step 1 WinSetTrans($hWnd, "", $i) Sleep($delay) Next EndFunc ;==>_FadeGUIIn ; #FUNCTION# ;=============================================================================== ; ; Name...........: _FadeGUIOut ; Description ...: Gradually fades a GUI out. ; Syntax.........: _FadeGUIOut( $hWnd ) ; Parameters ....: $hWnd - Handle to GUI you wish to fade out. ; Return values .: None ; Author ........: Insignia96 (iWoW Programming) ; Modified.......: Saturday, December 12, 2009 ; Remarks .......: ; Related .......: ; Link ..........; ; Example .......; Yes ; ; ;========================================================================================== Func _FadeGUIOut($hWnd) Local $delay = 0 For $i = $GUIFADE_MAXTRANS To 0 Step -1 WinSetTrans($hWnd, "", $i) Sleep($delay) Next GUISetState(@SW_HIDE) EndFunc ;==>_FadeGUIOutAnd I also provided an example script:; ~~~~~~~~~~~ INCLUDES ~~~~~~~~~~ #include "GUIFade.au3" ; ~~~~~~~~~~~ END INCLUDES ~~~~~~~~~~~ ; ~~~~~~~~~~~ INTERNAL CONFIGURATION ~~~~~~~~~~ Global $width = 350 ; Width of GUI to be created. Global $height = 350 ; Height of GUI to be created. Global $title = "Test GUI" ; Title of GUI to be created. Global $max_trans = 255 ; How transparent do you want the window, 0 = hidden, 255 = fully shown ; ~~~~~~~~~~~ END CONF ~~~~~~~~~~~ Global $pos[2] $pos[0] = @DesktopWidth / 2 - $width / 2 ; X (left) position of window $pos[1] = @DesktopHeight / 2 - $height / 2 ; Y (top) Position of window Global $hGUI = GUICreate($title & " - w/ Fade in/out", $width, $height, $pos[0], $pos[1]) _FadeGUIIn($hGUI,$max_trans) While 1 Local $nMsg = GUIGetMsg() Switch $nMsg Case -3 _FadeGUIOut($hGUI) Exit EndSwitch WEndI also made a zip file for download here: GUIFade.zipEnjoy! (and please comment!)EDIT: Fixed titleEDIT2: added $iMax parameter (GEOSoft's idea)WARNING: The $iMax Parameter may cause problems when using the _GUIFadeOut() function on multiple GUI's Edited December 12, 2009 by insignia96 Visit my website to see all my finished releases!Releases here:UDFs:GUI ResizingColor List (Web Colors)GUIFade_NearestPower
GEOSoft Posted December 12, 2009 Posted December 12, 2009 That works. I just find it easier to use the DLL method. DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hWnd, "int", $tFade, "long", $Fade) Where $tFade is the fade in/out time And $Fade is 0x80000 for fade in and 0x90000 for fade out George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
insignia96 Posted December 12, 2009 Author Posted December 12, 2009 I just wanted it in "Pure AutoIt", also im pretty sure this way works faster. Visit my website to see all my finished releases!Releases here:UDFs:GUI ResizingColor List (Web Colors)GUIFade_NearestPower
GEOSoft Posted December 12, 2009 Posted December 12, 2009 No problem with that but can I suggest a minor change in them? Just to allow for those windows where someone wants semi-transparency, add a parameter to replace the 255 and another to control $delay ($iDelay below) so people can choose the transition rate. Func _FadeGUIIn($hWnd, $iMax = 255, $iDelay = 0) WinSetTrans($hWnd, "", 0) GUISetState(@SW_SHOW) For $i = 1 To $iMax Step 1 WinSetTrans($hWnd, "", $i) Sleep($iDelay) Next EndFunc ;==>_FadeGUIIn George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
insignia96 Posted December 12, 2009 Author Posted December 12, 2009 No problem with that but can I suggest a minor change in them? Just to allow for those windows where someone wants semi-transparency, add a parameter to replace the 255 and another to control $delay ($iDelay below) so people can choose the transition rate. Func _FadeGUIIn($hWnd, $iMax = 255, $iDelay = 0) WinSetTrans($hWnd, "", 0) GUISetState(@SW_SHOW) For $i = 1 To $iMax Step 1 WinSetTrans($hWnd, "", $i) Sleep($iDelay) Next EndFunc ;==>_FadeGUIIn Actually, it had a delay parameter at first, however the sleep function could only do 10ms between increments, that meant that it was really slow, so i deleted it. I will add the semi-transparency option. Visit my website to see all my finished releases!Releases here:UDFs:GUI ResizingColor List (Web Colors)GUIFade_NearestPower
AdmiralAlkex Posted December 13, 2009 Posted December 13, 2009 I just wanted it in "Pure AutoIt", also im pretty sure this way works faster.What?That works.I just find it easier to use the DLL method.DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hWnd, "int", $tFade, "long", $Fade)Where $tFade is the fade in/out time And $Fade is 0x80000 for fade in and 0x90000 for fade out .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
GEOSoft Posted December 13, 2009 Posted December 13, 2009 What?I also forgot to mention that $tFade is in milliseconds George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
cramaboule Posted December 13, 2009 Posted December 13, 2009 I did that long time ago !!! see my sign "Ending Script Nicely" Cramaboule !!! My Autoit programs: MAC Address - - Delete Temp Files - - Ping Test - - Play Video with VLC full screen dual monitors - - Set IP - - Pics Converter - - AutoUpdater - - CPU Usage - - Ending Script Nicely - - GDI+ GUI crossfades (slide transitions) - - Beamer - - Search and Search in Files - - Silent Ninite Others: Export Icons into Dll - - My website
GEOSoft Posted December 13, 2009 Posted December 13, 2009 I did that long time ago !!!see my sign "Ending Script Nicely" Cramaboule !!!So have several others. People have been writing that since WinSetTrans() was first added to AutoIt, none the less, he made it work which was good practice. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!"
nugame Posted December 23, 2009 Posted December 23, 2009 No problem with that but can I suggest a minor change in them? Just to allow for those windows where someone wants semi-transparency, add a parameter to replace the 255 and another to control $delay ($iDelay below) so people can choose the transition rate. Func _FadeGUIIn($hWnd, $iMax = 255, $iDelay = 0) WinSetTrans($hWnd, "", 0) GUISetState(@SW_SHOW) For $i = 1 To $iMax Step 1 WinSetTrans($hWnd, "", $i) Sleep($iDelay) Next EndFunc ;==>_FadeGUIIn I put in the delay. good thing to do. I agree with the dll concept. DLL is more stable to less frequent changes. I did a major autoit automation for client. when it came to update for more features, had to update autoit on each site which should be done anyhow. Just like to change one for all sites. My two cents worth. thanks. I will use this one you did. Dr SherlockAlways a way
Michel Claveau Posted December 28, 2009 Posted December 28, 2009 (edited) Hi! Difference between Autoit_trans method and DLL method: - DLL method delete shadow of the window before fadein (and re-set after fadeout). - Autoit_trans keep shadow during run. (under Win 7-32 + Aero + shadow) Edited December 28, 2009 by Michel Claveau
KaFu Posted December 29, 2009 Posted December 29, 2009 Also you should change GUISetState(xxx) to GUISetState(xxx, $hWnd), otherwise the function always refers to the last gui handle used. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
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