Jump to content
Sign in to follow this  

Window Smooth Resize

Recommended Posts


First UDF I've posted on here. Sorry if I screwed anything up massively in advance.

I've been working with Javascript a lot recently and noticed the use of these transitions and decided to attempt to port them to AutoIt.

Adapted from Robert Penner Easing equations <http://www.robertpenner.com/easing/>

Flickers if used on an AutoIt GUI :/

; Name:         :   _WinSineInOutResize
; Description:      :   Smoothly resizes GUI based on a sine wave.
; Parameter(s):     :   $hWnd       -   GUI Handle
;                   $iResizeTo  -   Size to resize to
;                   $iDuration  -   Amount of time to run the resize for
;                   $iFPS       -   Frames/Second. Amount of times to run the effect in one second.
; Requirement:      :   None
; Return Value(s):  :   True    -   Success
;                   False   -   Invalid GUI handle
; User CallTip:     :
; Author(s):        :   this
; Note(s):          :   Adapted from Robert Penner Easing equations <http://www.robertpenner.com/easing/>.

Global Const $pi = ATan(1) * 4

Func _WinSineInOutResize($hWnd, $iResizeTo = 0, $iDuration = 500, $iFPS = 50)
    If Not IsHWnd($hWnd) Or Not WinExists($hWnd) Then
        ConsoleWriteError("Invalid Window handle for _GUI_SineResize 1st parameter" & @CRLF)
        Return False
        $aSize = WinGetPos($hWnd)
        $oTimer = TimerInit()
        While 1
            WinMove($hWnd, "", Default, Default, Default, -(($iResizeTo - $aSize[3]) / 2) * (Cos($pi * (TimerDiff($oTimer) / $iDuration)) - 1) + $aSize[3], 1)
            If TimerDiff($oTimer) > $iDuration Then
                WinMove($hWnd, "", Default, Default, Default, $iResizeTo)
            Sleep(1000 / $iFPS)
EndFunc   ;==>_WinSineInOutResize
  • Like 1

UDFsWinSineInOutResize () - Resize a window smoothly based on a sine curve.

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this