How to Animate a GUI Window ?
http://www.autohotke...p?p=65596#65596Foreword: The post is all about DllCall to AnimateWindow function in User32.dll.
MSDN Reference: AnimateWindow Function
Additional Reference: Animate a Window - Real's PB How-to
AnimateWindow() : The Wrapper for User32.dll\AnimateWindow function.AnimateWindow(hWnd,Duration,Flag) { Return DllCall("AnimateWindow","UInt",hWnd,"Int",Duration,"UInt",Flag) }
AnimateWindow() requires three parameters :
[*:1c7sutcr]Handle to the GUI Window
[*:1c7sutcr]Duration of the Animation (in milliseconds)
[*:1c7sutcr]Animation flag which may be any (or proper combination) of the following :/* Note: Following integers have to be converted to Hex before passing as a parameter to AnimateWindow 1 = Left to Right 2 = Right to Left 4 = Top to Bottom 8 = Bottom to Top 16 = Center 65536 = Hide 131072 = Show 262144 = Slide 524288 = Fade */[/list]How to Fade-In / Fade-Out a GUI ? How To Fade In Fade Out a GUI ?
Copy / Paste / Try example:FADE := 524288 SHOW := 131072 HIDE := 65536 FADE_SHOW := FADE+SHOW FADE_HIDE := FADE+HIDE ;Converting the above to Hexdecimal value SetFormat, Integer, Hex FADE_SHOW+=0 ; Converts to 0xa0000 FADE_HIDE+=0 ; Converts to 0x90000 SetFormat, Integer, d Duration = 500 ; Duration of Animation in milliseconds Gui, Margin, 0,0 Gui +LastFound GUI_ID:=WinExist() ; Handle to the GUI Gui,Show,w400 h300 Hide, Animated Window ( Fade-In / Fade-Out ) AnimateWindow(GUI_ID, Duration, FADE_SHOW) Return GuiEscape: GuiClose: AnimateWindow(GUI_ID, Duration, FADE_HIDE) ExitApp Return AnimateWindow(hWnd,Duration,Flag) { Return DllCall("AnimateWindow","UInt",hWnd,"Int",Duration,"UInt",Flag) }Optimised version of above code:Gui, Margin, 0,0 Gui +LastFound GUI_ID:=WinExist() Gui,Show,w400 h300 Hide, Animated Window ( Fade-In / Fade-Out ) DllCall("AnimateWindow","UInt",GUI_ID,"Int",500,"UInt","0xa0000") Return GuiEscape: GuiClose: DllCall("AnimateWindow","UInt",GUI_ID,"Int",500,"UInt","0x90000") ExitApp Return
We can modify the wrapper's DllCall to be:
DllCall("AnimateWindow", "UInt", hWnd, "Int", Duration, "Int", Flag)
so that we do not have to convert integers into hexdecimal values.
BUT!.. For reasons unknown to me, many transitions are not smooth (or noticeably jittery!) for me.
Please try both and use what suits you.
In case you need one, here is a simple Integer to Hexadecimal convertor
I made for myself to understand this stuff! I calculated the following effects:ROLL_LEFT_TO_RIGHT = 0x20001 ROLL_RIGHT_TO_LEFT = 0x20002 ROLL_TOP_TO_BOTTOM = 0x20004 ROLL_BOTTOM_TO_TOP = 0x20008 ROLL_DIAG_TL_TO_BR = 0x20005 ROLL_DIAG_TR_TO_BL = 0x20006 ROLL_DIAG_BL_TO_TR = 0x20009 ROLL_DIAG_BR_TO_TL = 0x2000a SLIDE_LEFT_TO_RIGHT= 0x40001 SLIDE_RIGHT_TO_LEFT= 0x40002 SLIDE_TOP_TO_BOTTOM= 0x40004 SLIDE_BOTTOM_TO_TOP= 0x40008 SLIDE_DIAG_TL_TO_BR= 0x40005 SLIDE_DIAG_TR_TO_BL= 0x40006 SLIDE_DIAG_BL_TO_TR= 0x40009 SLIDE_DIAG_BR_TO_TL= 0x40010 ZOOM_IN = 0x16 ZOOM_OUT = 0x10010 FADE_IN = 0xa0000 FADE_OUT = 0x90000
Visit the following post to download & try SlideShow.exe which extensively and effectively
uses the AnimateWindow function:
Edit:
Animated SplashImage !
Copy / Paste / Try example: Fade-In / Fade-OutIfNotExist, asplash1.gif URLDownloadToFile , https://ahknet.autohotkey.com/goyyah/CrazyScripts/SlideShow/asplash1.gif , asplash1.gif Gui, Margin, 0,0 Gui +LastFound GUI_ID:=WinExist() Gui, -Caption +AlwaysOnTop +Border Gui, Add, Picture, , asplash1.gif Gui,Show, AutoSize Hide, Animated Splash Window - Demo DllCall("AnimateWindow","UInt",GUI_ID,"Int",500,"UInt","0xa0000") Sleep 3000 DllCall("AnimateWindow","UInt",GUI_ID,"Int",500,"UInt","0x90000") ExitApp
Copy / Paste / Try example: Slide-In from left / Slide-Out to rightIfNotExist, asplash1.gif URLDownloadToFile , https://ahknet.autohotkey.com/goyyah/CrazyScripts/SlideShow/asplash1.gif , asplash1.gif Gui, Margin, 0,0 Gui +LastFound GUI_ID:=WinExist() Gui, -Caption +AlwaysOnTop +Border Gui, Add, Picture, , asplash1.gif Gui,Show, AutoSize Hide, Animated Splash Window - Demo DllCall("AnimateWindow","UInt",GUI_ID,"Int",1000,"UInt","0x40001") Sleep 3000 DllCall("AnimateWindow","UInt",GUI_ID,"Int",1000,"UInt","0x50001") ExitApp
Edit:
Animated SplashText!
Copy / Paste / Try example: Slow Scrolling TextScrollText = ( AutoHotkey is a free, open-source utility for Windows. With it, you can: Automate almost anything by sending keystrokes and mouse clicks. You can write macros by hand or use the macro recorder. Create hotkeys for keyboard, joystick, and mouse. Virtually any key, button, or combination can become a hotkey. Expand abbreviations as you type them. For example, typing "btw" can automatically produce "by the way". Create custom data entry forms, user interfaces, and menu bars. Remap keys and buttons on your keyboard, joystick, and mouse. Respond to signals from hand-held remote controls via the WinLIRC client script. Run existing AutoIt v2 scripts and enhance them with new capabilities. Convert any script into an EXE file that can be run on computers that don't have AutoHotkey installed. ) Gui, Margin, 0,0 Gui +LastFound GUI_ID:=WinExist() Gui, -Caption +AlwaysOnTop +Border Gui, Color, FFFFFF Gui, Margin, 40, 40 Gui, Font, s12 Bold, Verdana Gui, Add, Text, x41 y41 c808080 BackGroundTrans, % ScrollText Gui, Add, Text, x40 y40 c000000 BackGroundTrans, % ScrollText Gui,Show, AutoSize Hide, Animated Splash Window - Demo DllCall("AnimateWindow","UInt",GUI_ID,"Int",20000,"UInt","0x40008") DllCall("AnimateWindow","UInt",GUI_ID,"Int",20000,"UInt","0x50008") ExitApp