This function was introduced in Win98, and is very easy to use. By using this function, you can easily animate a GUI window as you want.
For example, you can Fade-in / Fade-out your GUI, you can also slide-in from the left and slide-out from the right.
In the AnimateWindow() function, you need to pass some parameters aka window’s handle, time delay, some flags to get the desired animation effect.
Let us see it in action.
In the above code, three parameters are passed into AnimateWindow (), as listed below:
- hWnd: It is the Window’s handle/id.
- Duration: Animation duration in milliseconds
- Flag: Animation flag, which can be one of the following or a combination to achieve
the desired animation effect:
- 1 = Left to Right
- 2 = Right to Left
- 3 = Top to Bottom
- 4 = Bottom to Top
- 16 = Center
- 65536 = hide
- 131072 = Show
- 262144 = Slide
- 524288 = Fade
Note: AnimateWindow() accepts the flag value as Hex value not an Integar. So, you will have to first convert the above Integar values to Hex values before passing them to AnimateWindow(). You can also use an Integar to Hex converter.
Example of a Fade-in/Fade-out’ing GUI
FADE := 524288
SHOW := 131072
HIDE := 65536F_SHOW := FADE+SHOW
F_HIDE := FADE+HIDE ;Converting the above to Hexdecimal valueSetFormat, Integer, Hex
F_SHOW+=0 ; Converts to 0xa0000
F_HIDE+=0 ; Converts to 0x90000
SetFormat, Integer, dDuration = 700 ;Gui, Margin, 0,0
Gui,Show,w400 h300 Hide, Animated Window ( Fade-In / Fade-Out )
AnimateWindow(GUI_ID, Duration, FADE_SHOW)
AnimateWindow(GUI_ID, Duration, FADE_HIDE)
In the above code,
- Fade, Show, and Hide are the animation flags
- F_SHOW is a parameter in which the combined effect of Fade and Show flags is being passed
- F_HIDE is a parameter in which the combined effect of Fade and Hide flags is being passed
- Duration for the animation has been set to 700 milliseconds
- GUI_ID holds the GUI Window handle
Demonstrated above is just one example of animating a GUI Window.
Depending upon your requirement, you can animate the window as you want by trying the different combination of flags and time duration.
For example, you can do Swipe-in / Swipe-out. You can also scroll the text from top to bottom or from bottom to top.
So, try to get the best animation you want.
And let me know if you need help!
Latest posts by jszadmin (see all)
- AutoHotkey Webinar: 21/02/2017: Simple and Associative Arrays - February 22, 2017
- AutoHotkey Webinar: 17/01/2017: Troubleshooting and Debugging - January 19, 2017
- AutoHotkey Webinar: 11/15/2016 Regular Expressions - November 17, 2016