Jump to content

Recommended Posts

Posted (edited)

The work speaks for itself. :lol:
 

; https://www.autoitscript.com/forum/topic/213089-click-fun/
;----------------------------------------------------------------------------------------
; Title...........: _Explosion.au3
; Description.....: Simulates an explosion effect on a series of popup windows.
; AutoIt Version..: 3.3.16.1   Author: ioa747  Script Version: 0.2
; Note............: Testet in Win10 22H2       Date:23/08/2025
;----------------------------------------------------------------------------------------
#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
#include <WindowsConstants.au3>
#include <Math.au3>
#include <GUIConstantsEx.au3>
#include <WinAPIConstants.au3>

_Example()

Func _Example()
    Local $hGUI = GUICreate('Fireworks Example', 500, 300)
    Local $idBtn_Click = GUICtrlCreateButton("Click", 400, 270, 85, 25)
    Local $idBtn_Close = GUICtrlCreateButton("Close", 300, 270, 85, 25)
    GUISetState(@SW_SHOW)

    Local $msg, $aPos
    While True
        $msg = GUIGetMsg()
        Switch $msg
            Case $GUI_EVENT_CLOSE ; standard window close
                GUIDelete($hGUI)
                Sleep(50)
                $aPos = MouseGetPos()
                _Explosion($aPos[0] - 250, $aPos[1] + 150)
                ExitLoop

            Case $idBtn_Close ; The window will shrink and then explode.
                $aPos = _Shrink($hGUI)
                _Explosion($aPos[0], $aPos[1])
                ExitLoop

            Case $idBtn_Click ; explosion at the mouse cursor position.
                $aPos = MouseGetPos()
                _Explosion($aPos[0], $aPos[1])

        EndSwitch
    WEnd
EndFunc

Func _Shrink($hWin, $iSteps = 10)
    Local $aWPos = WinGetPos($hWin)
    Local $iCenterX = $aWPos[0] + ($aWPos[2] / 2)
    Local $iCenterY = $aWPos[1] + ($aWPos[3] / 2)
    For $i = 1 To $iSteps
        Local $iNewW = $aWPos[2] - ($i * $aWPos[2] / $iSteps)
        Local $iNewH = $aWPos[3] - ($i * $aWPos[3] / $iSteps)
        Local $iNewX = $aWPos[0] + (($aWPos[2] - $iNewW) / 2)
        Local $iNewY = $aWPos[1] + (($aWPos[3] - $iNewH) / 2)
        WinMove($hWin, '', $iNewX, $iNewY, $iNewW, $iNewH)
        Sleep(10)
    Next
    GUIDelete($hWin)
    Local $aPos[] = [$iCenterX, $iCenterY]
    Return $aPos
EndFunc

Func _Explosion($iX, $iY)
    Local Const $aColors[5] = [0xFFD800, 0xFFFFFF, 0xD59262, 0x808141, 0x3B3C23]
    Local Const $iPieces = 10
    Local $aGUI[$iPieces][7]

    ; GUICreate
    For $i = 0 To $iPieces - 1
        $aGUI[$i][1] = $iX                  ; x
        $aGUI[$i][2] = $iY                  ; y
        $aGUI[$i][3] = Random(5, 15, 1)     ; w
        $aGUI[$i][4] = $aGUI[$i][3]         ; h
        $aGUI[$i][5] = Random(15, 25, 1)    ; speed
        $aGUI[$i][6] = $i * (360 / $iPieces); direction (circular)
        $aGUI[$i][0] = GUICreate('', $aGUI[$i][3], $aGUI[$i][4], $aGUI[$i][1], $aGUI[$i][2], $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
        GUISetBkColor($aColors[Random(0, UBound($aColors) - 1, 1)])
        GUISetState(@SW_SHOWNOACTIVATE)
    Next

    While 1
        Local $bActive = False
        For $i = 0 To $iPieces - 1
            If WinExists($aGUI[$i][0]) Then
                $bActive = True
                Local $fRad = _Radian($aGUI[$i][6])
                $aGUI[$i][1] += ($aGUI[$i][5] * Cos($fRad))
                $aGUI[$i][2] += ($aGUI[$i][5] * Sin($fRad))
                $aGUI[$i][3] -= 1
                $aGUI[$i][4] -= 1
                $aGUI[$i][5] *= 0.95
                WinMove($aGUI[$i][0], '', $aGUI[$i][1], $aGUI[$i][2], $aGUI[$i][3], $aGUI[$i][4])
                If $aGUI[$i][3] <= 1 Or $aGUI[$i][4] <= 1 Then GUIDelete($aGUI[$i][0])
            EndIf
        Next
        If Not $bActive Then ExitLoop
        Sleep(10)
    WEnd
EndFunc

have fun  :)
Thank you very much 

 

Edited by ioa747
Version: 0.2 - I did it in two functions

I know that I know nothing

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
×
×
  • Create New...