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.

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

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

 

Conclusion

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!

jszadmin

Drafter and Webmaster at JSZapp.com
I’m Jackie Sztuk or JSZ. I have a Drafter’s degree from Copenhagen Technical College (KTS) and my passion for windows scripting is what makes me want to help as meny as i can by writing great and easy to follow How-to's.

jszadmin

I’m Jackie Sztuk or JSZ. I have a Drafter’s degree from Copenhagen Technical College (KTS) and my passion for windows scripting is what makes me want to help as meny as i can by writing great and easy to follow How-to's.

Leave a Reply