Animate GUI

How to: Animate a GUI window

Animate GUIIn this tutorial, we will learn about a process you can use to animate a GUI Window, using the AnimateWindow function, wrapped in an AutoHotkey function of the same name in this guide.

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.


AnimateWindow(hWnd,Duration,Flag) {

Return DllCall("AnimateWindow","UInt",hWnd,"Int",Duration,"UInt",Flag)


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
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 +LastFound
Gui,Show,w400 h300 Hide, Animated Window ( Fade-In / Fade-Out )

AnimateWindow(GUI_ID, Duration, FADE_SHOW)

AnimateWindow(GUI_ID, Duration, FADE_HIDE)

ReturnAnimateWindow(hWnd,Duration,Flag) {
    Return DllCall("AnimateWindow","UInt",hWnd,"Int",Duration,"UInt",Flag)

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!

Leave a Reply