Jump to content

Recommended Posts

Posted (edited)

hello!,

i am new in the forum.

Is posible create gui effects with AutoitObject like DllCall ("User32.dll", "int",  "AnimateWindow"...)?.

User32.dll AnimateWindow function pauses the script, and I need the effects without stopping or Sleep the script, because i'm using a Child window and I want to close the child window with effects without affecting the parent window, for example while the child window is closing with effect I can keep using the parent window without any problem, press a button, close window etc. Everything is working.

there any way to do with AutoitObject?

 

 

thanks in advance

Edited by Robert4099
Posted

I don't know a direct answer to your question regarding Autoitobject, or if such a trivial action might be stable in a spawned thread (AutoIt scripts are single threaded).

But I'd consider creating a new script on the fly to deal with such an action if I wanted it.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Posted

Here is an example showing this 'issue'.

#include <WinAPIEx.au3>
#include <APIConstants.au3>

Global $HideStyle = BitOR($AW_CENTER, $AW_HIDE)
Global $ShowStyle = $AW_CENTER
Global $AnimateTime = 600

Global $hGui = GUICreate("AnimateWindow Asynchron", 400, 400)

Global $nButton = GUICtrlCreateButton("Animate", 10, 10, 100, 30)
Global $nLabel = GUICtrlCreateLabel("0", 150, 150, 100, 100, 0x201)
AdlibRegister("_CountUp", 100)

GUISetState()

Global $iMsg
While 1
$iMsg = GUIGetMsg()
Switch $iMsg
Case -3
AdlibUnRegister("_CountUp")
Exit
Case $nButton
_WinAPI_AnimateWindow($hGui, $HideStyle, $AnimateTime)
_WinAPI_AnimateWindow($hGui, $ShowStyle, $AnimateTime)
EndSwitch
Sleep(10)
WEnd


Func _CountUp()
GUICtrlSetData($nLabel, GUICtrlRead($nLabel) + 1)
EndFunc ;==>_CountUp
But where do I need this?

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Posted (edited)
Here's an Script to explain my problem.
 
instructions:
Press the button "Effects" and while the effects are working, try press the button Msgbox or close the window, you will see that is not possible to do this.
 
Script:
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>

#region GUI
Global $hGUI_Main = GUICreate("")
Global $Button1 = GUICtrlCreateButton("Effects", 56, 48, 75, 25)
Global $Button2 = GUICtrlCreateButton("Msgbox", 224, 48, 75, 25)


Global $hGUI_Child = GUICreate("MyGUI", 400, 70, -1, -1, $WS_POPUP, $WS_EX_TOPMOST,$hGUI_Main)
GUISetBkColor(0x000000, $hGUI_Child)

Local $iMyLabel = GUICtrlCreateLabel("Hello!", 0, 0, 400, 70, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetColor($iMyLabel, 0xFFFFFF)
GUICtrlSetFont($iMyLabel, 17)

_GuiRoundCorners($hGUI_Child, 0, 0, 7, 7)

WinSetTrans($hGUI_Child, "", 150)
GUISetState(@SW_SHOW, $hGUI_Child)
GUISetState(@SW_SHOW, $hGUI_Main)
#endregion




While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
       AnimateW($hGUI_Child)

        Case $Button2
        MsgBox("","MsgBox","Hello!")

    EndSwitch
WEnd

Func _GuiRoundCorners($hWnd, $iLeftRect, $iTopRect, $iWidthEllipse, $iHeightEllipse)
    Local $aPos = 0, $aRet = 0

    $aPos = WinGetPos($hWnd)

    $aRet = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $iLeftRect, "long", $iTopRect, "long", $aPos[2], "long", $aPos[3], "long", $iWidthEllipse, "long", $iHeightEllipse)
    If Not @error And $aRet[0] Then
        $aRet = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hWnd, "long", $aRet[0], "int", 1)
        If Not @error And $aRet[0] Then Return 1
    EndIf

    Return 0
EndFunc   ;==>_GuiRoundCorners

Func AnimateW($hwnd)
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 800, "long", 0x00050001) ; slide out to right
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 800, "long", 0x00040004) ; slide-in from top
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 800, "long", 0x00050008) ; slide-out to top
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 800, "long", 0x00040008) ; slide-in from bottom
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 800, "long", 0x00050004) ; slide-out to bottom
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 800, "long", 0x00040005) ; diag slide-in from Top-left
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 800, "long", 0x0005000a) ; diag slide-out to Top-left
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 800, "long", 0x00040006) ; diag slide-in from Top-Right
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 800, "long", 0x00050009) ; diag slide-out to Top-Right
EndFunc
Edited by Robert4099
Posted

This doesn't close while the effect is happening but it will check in between DllCalls.

#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>

#region GUI
Global $hGUI_Main = GUICreate("")
Global $Button1 = GUICtrlCreateButton("Effects", 56, 48, 75, 25)
Global $Button2 = GUICtrlCreateButton("Msgbox", 224, 48, 75, 25)

Global $hGUI_Child = GUICreate("MyGUI", 400, 70, -1, -1, $WS_POPUP, $WS_EX_TOPMOST)
GUISetBkColor(0x000000, $hGUI_Child)

Local $iMyLabel = GUICtrlCreateLabel("Good news Dave, I can do that.", 0, 0, 400, 70, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetColor($iMyLabel, 0xFFFFFF)
GUICtrlSetFont($iMyLabel, 17)

_GuiRoundCorners($hGUI_Child, 0, 0, 7, 7)

WinSetTrans($hGUI_Child, "", 150)
GUISetState(@SW_SHOW, $hGUI_Child)
GUISetState(@SW_SHOW, $hGUI_Main)
#endregion

While 1
    $nMsg = GUIGetMsg()

    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
       AnimateW($hGUI_Child)

        Case $Button2
            MsgBox("","MsgBox","Hello!")

    EndSwitch
WEnd


Func _Loop()
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button2
            MsgBox("","MsgBox","Hello!")
    EndSwitch
EndFunc

Func _GuiRoundCorners($hWnd, $iLeftRect, $iTopRect, $iWidthEllipse, $iHeightEllipse)
    Local $aPos = 0, $aRet = 0

    $aPos = WinGetPos($hWnd)

    $aRet = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $iLeftRect, "long", $iTopRect, "long", $aPos[2], "long", $aPos[3], "long", $iWidthEllipse, "long", $iHeightEllipse)
    If Not @error And $aRet[0] Then
        $aRet = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hWnd, "long", $aRet[0], "int", 1)
        If Not @error And $aRet[0] Then Return 1
    EndIf

    Return 0
EndFunc   ;==>_GuiRoundCorners

Func AnimateW($hwnd)
    AdlibRegister("_Loop", 10)
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 800, "long", 0x00050001) ; slide out to right
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 800, "long", 0x00040004) ; slide-in from top
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 800, "long", 0x00050008) ; slide-out to top
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 800, "long", 0x00040008) ; slide-in from bottom
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 800, "long", 0x00050004) ; slide-out to bottom
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 800, "long", 0x00040005) ; diag slide-in from Top-left
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 800, "long", 0x0005000a) ; diag slide-out to Top-left
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 800, "long", 0x00040006) ; diag slide-in from Top-Right
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $hwnd, "int", 800, "long", 0x00050009) ; diag slide-out to Top-Right
    AdlibUnRegister("_Loop")
EndFunc

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...