Gianni Posted April 23 Share Posted April 23 (edited) For comparative testing purposes I tried to translate the script created by @Numeric1 at this link which uses AutoitObject, so as to use AutoItObject_Internal.au3 by @genius257 instead. (The latter does not require additional DLLs.). Maybe it seems a little slower and slightly less responsive (?) P.S. I created a new thread just to not hijack @Numeric1's original thread. (any improvements and corrections relating to the translation of the listing are welcome) expandcollapse popup; =============================================================================================================================== ; original script created by @Numeric1 at the link below ; https://www.autoitscript.com/forum/topic/211824-ping-pong-game-with-autoitobject/ ; =============================================================================================================================== ; Game Overview: ; - The game consists of a paddle and a ball. ; - The player controls the paddle using the left and right arrow keys. ; - The objective is to bounce the ball off the paddle and prevent it from hitting the bottom edge of the window. ; - If the ball hits the bottom edge, the game ends. ; - As the game progresses, the speed of the ball increases periodically, making it more challenging. ; Controls: ; - Left Arrow Key: Move the paddle to the left. ; - Right Arrow Key: Move the paddle to the right. ; - S Key: Pause the game. ; - When the game is paused, press Left or Right arrow key to resume. ; Enjoy playing Ping Pong! ; =============================================================================================================================== #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> ; #include "AutoItObject.au3" #include "AutoItObject_Internal.au3" ; <-- https://www.autoitscript.com/forum/topic/185720-autoitobject-pure-autoit #include <Misc.au3> Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") _GDIPlus_Startup() Const $COLOR_RED = 0xFFFF0000 Const $COLOR_GREEN = 0xFF00FF00 Func Ball($x = 0, $y = 0, $size = 5) Local $cBall = IDispatch() ; _AutoItObject_Class() With $cBall .dx = 10 .dy = -10 .size = $size .X = $x .Y = $y .__defineGetter("move", _move) EndWith Return $cBall ; .Object EndFunc ;==>Ball Func Paddle($x = 0, $size = 5) Local $cPaddle = IDispatch() ; _AutoItObject_Class() With $cPaddle .X = $x .size = $size .dx = 20 .__defineGetter("moveLeft", _moveLeft) .__defineGetter("moveRight", _moveRight) EndWith Return $cPaddle ; .Object EndFunc ;==>Paddle Func _moveLeft($this) $this.parent.X -= $this.parent.dx If $this.parent.X < 0 Then $this.parent.X = 0 EndFunc ;==>_moveLeft Func _moveRight($this) ; , $maxX) Local $maxX = $this.arguments.values[0] Local $paddleWidth = $this.parent.size If $this.parent.X + $this.parent.dx + $paddleWidth <= $maxX Then $this.parent.X += $this.parent.dx Else $this.parent.X = $maxX - $paddleWidth EndIf EndFunc ;==>_moveRight Func GamePanel() Local $hGUI = GUICreate("Ping Pong", 400, 300, -1, -1, $WS_SIZEBOX + $WS_SYSMENU) GUISetBkColor(0x000000) GUISetState() Local $aClient = WinGetClientSize($hGUI) If @error Then Return SetError(1, 0, 0) Local $iWidth = $aClient[0] Local $iHeight = $aClient[1] Local $aGDIMap[5] $aGDIMap[0] = _GDIPlus_GraphicsCreateFromHWND($hGUI) $aGDIMap[1] = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $aGDIMap[0]) $aGDIMap[2] = _GDIPlus_ImageGetGraphicsContext($aGDIMap[1]) $aGDIMap[3] = _GDIPlus_BrushCreateSolid($COLOR_RED) $aGDIMap[4] = _GDIPlus_HatchBrushCreate(4, $COLOR_GREEN) Local $Ball = Ball(40, 40) Local $paddleX = Paddle(150, 100) Local $cGamePanel = IDispatch() ; _AutoItObject_Class() With $cGamePanel .iWidth = $iWidth .iHeight = $iHeight .ball = $Ball .paddle = $paddleX .map = $aGDIMap .speedLevel = 100 .__defineGetter("move", _move) .__defineGetter("drawStage", _drawStage) .__defineGetter("cleanUpResources", _cleanUpResources) .__destructor(_cleanUpResources) .__defineGetter("runGameLoop", _runGameLoop) EndWith Return $cGamePanel ; .Object EndFunc ;==>GamePanel Func _move($this) Local $x = $this.parent.ball.X Local $y = $this.parent.ball.Y Local $dx = $this.parent.ball.dx Local $dy = $this.parent.ball.dy Local $Width = $this.parent.iWidth Local $Height = $this.parent.iHeight Local $BallSize = $this.parent.ball.size If $y + $dy >= ($Height - 40) And $x + $BallSize >= $this.parent.paddle.X And $x <= $this.parent.paddle.X + $this.parent.paddle.size Then $dy *= -1 EndIf If $y + $dy <= 0 Then $dy = Abs($dy) EndIf If $y + $dy >= $Height - $BallSize Then MsgBox(0, "Game Over", "You missed the ball! Game Over!") Exit EndIf If $x + $dx <= 0 Then $dx = Abs($dx) EndIf If $x + $dx >= $Width - $BallSize Then $dx = -Abs($dx) EndIf $x += $dx $y += $dy $this.parent.ball.dx = $dx $this.parent.ball.dy = $dy $this.parent.ball.X = $x $this.parent.ball.Y = $y $this.parent.drawStage() EndFunc ;==>_move Func _drawStage($this) Local $hGraphics = $this.parent.map[0] Local $hBitmap = $this.parent.map[1] Local $hGraphicsCtxt = $this.parent.map[2] Local $iX = $this.parent.ball.X Local $iY = $this.parent.ball.Y Local $iRadius = $this.parent.ball.size Local $padX = $this.parent.paddle.X Local $padH = $this.parent.iHeight - 40 _GDIPlus_GraphicsClear($hGraphicsCtxt, 0xFF000000) _GDIPlus_GraphicsFillEllipse($hGraphicsCtxt, $iX - $iRadius, $iY - $iRadius, $iRadius * 2, $iRadius * 2, $this.parent.map[3]) _GDIPlus_GraphicsFillRect($hGraphicsCtxt, $padX, $padH, $this.parent.paddle.size, 10, $this.parent.map[4]) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $this.parent.iWidth, $this.parent.iHeight) EndFunc ;==>_drawStage Func _cleanUpResources($this) ConsoleWrite("clean up ressources...." & @CRLF) Local $map = $this.parent.map _GDIPlus_GraphicsDispose($map[0]) _GDIPlus_BitmapDispose($map[1]) _GDIPlus_GraphicsDispose($map[2]) _GDIPlus_BrushDispose($map[3]) $this.parent.map = 0 _GDIPlus_Shutdown() EndFunc ;==>_cleanUpResources Func _runGameLoop($this) Local $speedUpTime = 5000 Local $lastMoveTime = TimerInit() Local $maxX = $this.parent.iWidth While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop If _IsPressed(25) Then $this.parent.paddle.moveLeft() If _IsPressed(27) Then $this.parent.paddle.moveRight($maxX) If _IsPressed(53) Then While 1 If _IsPressed(25) Or _IsPressed(27) Then ExitLoop Sleep(100) WEnd EndIf If TimerDiff($lastMoveTime) >= $speedUpTime Then $this.parent.speedLevel -= 5 If $this.parent.speedLevel < 0 Then $this.parent.speedLevel = 0 $lastMoveTime = TimerInit() EndIf $this.parent.move() Sleep($this.parent.speedLevel) WEnd EndFunc ;==>_runGameLoop Func _ErrFunc($oError) ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc ;================================================ Global $game = GamePanel() $game.runGameLoop() ConsoleWrite("------> the end <-------" & @CRLF) ; $game = 0 ;================================================= Edited April 23 by Gianni ioa747 and Danyfirex 2 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Numeric1 Posted April 23 Share Posted April 23 (edited) The tests previously conducted to assess the performance of the UDFs AutoItObject.au3 and AutoItObject_Internal.au3 under various conditions have highlighted discernible differences, albeit subtle. The analysis of the collected data underscores the slight preference in terms of speed for AutoItObject.au3. While this difference may not be considerable, it remains non-negligible in certain usage contexts. It is important to note that each UDF has its own advantages and disadvantages, which can influence their selection depending on the specific project requirements. The comparative table provided by @genius257 while informative, may spark debates and additional nuances regarding the evaluation of the performance and features of each UDF. Unfortunately, I no longer have the test code available. Edited April 23 by Numeric1 genius257 and Gianni 1 1 Link to comment Share on other sites More sharing options...
genius257 Posted April 23 Share Posted April 23 Hi @Gianni 🙂, AutoItObject_Internal is much slower than AutoitObject. An issue regarding speed exists on github: https://github.com/genius257/AutoItObject-Internal/issues/10 Gianni 1 My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser Link to comment Share on other sites More sharing options...
genius257 Posted May 13 Share Posted May 13 (edited) So i have this project https://github.com/genius257/au3class and seeing the code, it just seemed to make sense for it to be made in this. I was also curious of the speed improvements, if i dropped the AutoItObject_Internal dependency, since all properties and methods are non dynamic, so no reason to check each property name manually for a match every time. Anyway, it's still slower than AutoitObject, but faster than AutoItObject_Internal. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <Misc.au3> Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") _GDIPlus_Startup() Const $COLOR_RED = 0xFFFF0000 Const $COLOR_GREEN = 0xFF00FF00 Func ___Class__Ball_VariantHelper() Local Static $tVariant = DllStructCreate("ushort vt;ushort r1;ushort r2;ushort r3;PTR data;PTR data2") Local Static $tObject = DllStructCreate("int RefCount;int Size;ptr Object;ptr Methods[7];ptr Variant;") Local Static $oObject = 0 If $oObject <> 0 Then Return $oObject Local $hQueryInterface = DllCallbackRegister(___Class__Ball_VariantHelperQueryInterface, "LONG", "ptr;ptr;ptr") Local $hAddRef = DllCallbackRegister(___Class__Ball_VariantHelperAddRef, "dword", "PTR") Local $hRelease = DllCallbackRegister(___Class__Ball_VariantHelperRelease, "dword", "PTR") Local $hGetTypeInfoCount = DllCallbackRegister(___Class__Ball_VariantHelperGetTypeInfoCount, "long", "ptr;ptr") Local $hGetTypeInfo = DllCallbackRegister(___Class__Ball_VariantHelperGetTypeInfo, "long", "ptr;uint;int;ptr") Local $hGetIDsOfNames = DllCallbackRegister(___Class__Ball_VariantHelperGetIDsOfNames, "long", "ptr;ptr;ptr;uint;int;ptr") Local $hInvoke = DllCallbackRegister(___Class__Ball_VariantHelperInvoke, "long", "ptr;int;ptr;int;ushort;ptr;ptr;ptr;ptr") DllStructSetData($tObject, "Methods", DllCallbackGetPtr($hQueryInterface), 1) DllStructSetData($tObject, "Methods", DllCallbackGetPtr($hAddRef), 2) DllStructSetData($tObject, "Methods", DllCallbackGetPtr($hRelease), 3) DllStructSetData($tObject, "Methods", DllCallbackGetPtr($hGetTypeInfoCount), 4) DllStructSetData($tObject, "Methods", DllCallbackGetPtr($hGetTypeInfo), 5) DllStructSetData($tObject, "Methods", DllCallbackGetPtr($hGetIDsOfNames), 6) DllStructSetData($tObject, "Methods", DllCallbackGetPtr($hInvoke), 7) DllStructSetData($tObject, "RefCount", 1) ; initial ref count is 1 DllStructSetData($tObject, "Size", 7) ; number of interface methods DllStructSetData($tObject, "Object", DllStructGetPtr($tObject, "Methods")) ; Interface method pointers DllStructSetData($tObject, "Variant", DllStructGetPtr($tVariant)) $oObject = ObjCreateInterface(DllStructGetPtr($tObject, "Object"), "{00020400-0000-0000-C000-000000000046}", Default, True) ; pointer that's wrapped into object Return $oObject EndFunc Func ___Class__Ball_VariantHelperQueryInterface($pSelf, $pRIID, $pObj) If $pObj=0 Then Return $__AOI_E_POINTER Local $sGUID=DllCall("ole32.dll", "int", "StringFromGUID2", "PTR", $pRIID, "wstr", "", "int", 40)[2] If (Not ($sGUID="{00020400-0000-0000-C000-000000000046}")) And (Not ($sGUID="{00000000-0000-0000-C000-000000000046}")) Then Return -2147467262 Local $tStruct = DllStructCreate("ptr", $pObj) DllStructSetData($tStruct, 1, $pSelf) ___Class__Ball_VariantHelperAddRef($pSelf) Return 0 EndFunc Func ___Class__Ball_VariantHelperAddRef($pSelf) Local $tStruct = DllStructCreate("int Ref", $pSelf - 8) $tStruct.Ref += 1 Return $tStruct.Ref EndFunc Func ___Class__Ball_VariantHelperRelease($pSelf) Local $tObject = DllStructCreate("int RefCount;int Size;ptr Object;ptr Methods[7];ptr Variant;", $pSelf - 8) $tObject.RefCount -= 1 If $tObject.RefCount > 0 Then Return $tObject.RefCount DllCall("OleAut32.dll","LONG","VariantClear","ptr",$tObject.Variant) DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", DllCall("kernel32.dll", "ptr", "GlobalHandle", "ptr", $tObject.Variant)[0]) DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", DllCall("kernel32.dll", "ptr", "GlobalHandle", "ptr", DllStructGetPtr($tObject))[0]) Return 0 EndFunc Func ___Class__Ball_VariantHelperGetTypeInfoCount($pSelf, $pctinfo) DllStructSetData(DllStructCreate("UINT",$pctinfo),1, 0) Return 0 EndFunc Func ___Class__Ball_VariantHelperGetTypeInfo($pSelf, $iTInfo, $lcid, $ppTInfo) If $iTInfo<>0 Then Return -2147352565 If $ppTInfo=0 Then Return -2147024809 Return 0 EndFunc Func ___Class__Ball_VariantHelperGetIDsOfNames($pSelf, $riid, $rgszNames, $cNames, $lcid, $rgDispId) Local $tIds = DllStructCreate("long i", $rgDispId) DllStructSetData($tIds, 1, 1) Return 0 EndFunc Func ___Class__Ball_VariantHelperInvoke($pSelf, $dispIdMember, $riid, $lcid, $wFlags, $pDispParams, $pVarResult, $pExcepInfo, $puArgErr) Local $tObject = DllStructCreate("int RefCount;int Size;ptr Object;ptr Methods[7];ptr Variant;", $pSelf - 8) If BitAND($wFlags, 2) = 2 Then DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "ptr", $tObject.Variant) Return 0 EndIf If BitAND($wFlags, 4) = 4 Then $tParams = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tParams.cArgs <> 1 Then Return -2147352562 DllCall("OleAut32.dll","LONG","VariantClear","ptr",$tObject.Variant) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$tObject.Variant, "ptr", $tParams.rgvargs) Return 0 EndIf Return -2147352567 EndFunc Func ___Class__Ball_ToVariant($vValue) Local $oObject = ___Class__Ball_VariantHelper() $oObject.a = $vValue Local $tObject = DllStructCreate("int RefCount;int Size;ptr Object;ptr Methods[7];ptr Variant;", ptr($oObject) - 8) Local $tVariant = DllStructCreate("ushort vt;ushort r1;ushort r2;ushort r3;PTR data;PTR data2") DllCall("OleAut32.dll","LONG","VariantClear","struct*",$tVariant) DllCall("OleAut32.dll","LONG","VariantCopy","struct*",$tVariant, "ptr", $tObject.Variant) Return $tVariant EndFunc Func ___Class__Ball_FromVariant($pVariant) Local $oObject = ___Class__Ball_VariantHelper() Local $tObject = DllStructCreate("int RefCount;int Size;ptr Object;ptr Methods[7];ptr Variant;", ptr($oObject) - 8) DllCall("OleAut32.dll","LONG","VariantClear","ptr",$tObject.Variant) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$tObject.Variant, "struct*", $pVariant) Return $oObject.a EndFunc Func Ball($x = 0, $y = 0, $size = 5) Local Static $QueryInterface = DllCallbackRegister(__Object__Class_Ball_QueryInterface, 'LONG', 'ptr;ptr;ptr'), $AddRef = DllCallbackRegister(__Object__Class_Ball_AddRef, 'dword', 'PTR'), $Release = DllCallbackRegister(__Object__Class_Ball_Release, 'dword', 'PTR'), $GetTypeInfoCount = DllCallbackRegister(__Object__Class_Ball_GetTypeInfoCount, 'long', 'ptr;ptr'), $GetTypeInfo = DllCallbackRegister(__Object__Class_Ball_GetTypeInfo, 'long', 'ptr;uint;int;ptr'), $GetIDsOfNames = DllCallbackRegister(__Object__Class_Ball_GetIDsOfNames, 'long', 'ptr;ptr;ptr;uint;int;ptr'), $Invoke = DllCallbackRegister(__Object__Class_Ball_Invoke, 'long', 'ptr;int;ptr;int;ushort;ptr;ptr;ptr;ptr') $tObject = DllStructCreate('int RefCount;int Size;ptr Object;ptr Methods[7];ptr Properties[5];') DllStructSetData($tObject, 'Methods', DllCallbackGetPtr($QueryInterface), 1) DllStructSetData($tObject, 'Methods', DllCallbackGetPtr($AddRef), 2) DllStructSetData($tObject, 'Methods', DllCallbackGetPtr($Release), 3) DllStructSetData($tObject, 'Methods', DllCallbackGetPtr($GetTypeInfoCount), 4) DllStructSetData($tObject, 'Methods', DllCallbackGetPtr($GetTypeInfo), 5) DllStructSetData($tObject, 'Methods', DllCallbackGetPtr($GetIDsOfNames), 6) DllStructSetData($tObject, 'Methods', DllCallbackGetPtr($Invoke), 7) DllStructSetData($tObject, 'RefCount', 1) DllStructSetData($tObject, 'Size', 7) $pObject = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", 0x0002, "ulong_ptr", DllStructGetSize($tObject))[0])[0] DllCall("kernel32.dll", "none", "RtlMoveMemory", "struct*", $pObject, "struct*", $tObject, "ulong_ptr", DllStructGetSize($tObject)) $tObject = DllStructCreate('int RefCount;int Size;ptr Object;ptr Methods[7];ptr Properties[5];', $pObject) DllStructSetData($tObject, "Object", DllStructGetPtr($tObject, "Methods")) Local Static $tVariant = DllStructCreate("ushort vt;ushort r1;ushort r2;ushort r3;PTR data;PTR data2") DllStructSetData($tVariant, 'vt', 1) $pObject = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", 0x0002, "ulong_ptr", DllStructGetSize($tVariant))[0])[0] DllCall("kernel32.dll", "none", "RtlMoveMemory", "struct*", $pObject, "struct*", ___Class__Ball_ToVariant( 10), "ulong_ptr", DllStructGetSize($tVariant)) DllStructSetData($tObject, "Properties", $pObject, 1) $pObject = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", 0x0002, "ulong_ptr", DllStructGetSize($tVariant))[0])[0] DllCall("kernel32.dll", "none", "RtlMoveMemory", "struct*", $pObject, "struct*", ___Class__Ball_ToVariant( -10), "ulong_ptr", DllStructGetSize($tVariant)) DllStructSetData($tObject, "Properties", $pObject, 2) $pObject = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", 0x0002, "ulong_ptr", DllStructGetSize($tVariant))[0])[0] DllCall("kernel32.dll", "none", "RtlMoveMemory", "struct*", $pObject, "struct*", ___Class__Ball_ToVariant( 5), "ulong_ptr", DllStructGetSize($tVariant)) DllStructSetData($tObject, "Properties", $pObject, 3) $pObject = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", 0x0002, "ulong_ptr", DllStructGetSize($tVariant))[0])[0] DllCall("kernel32.dll", "none", "RtlMoveMemory", "struct*", $pObject, "struct*", ___Class__Ball_ToVariant( 0), "ulong_ptr", DllStructGetSize($tVariant)) DllStructSetData($tObject, "Properties", $pObject, 4) $pObject = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", 0x0002, "ulong_ptr", DllStructGetSize($tVariant))[0])[0] DllCall("kernel32.dll", "none", "RtlMoveMemory", "struct*", $pObject, "struct*", ___Class__Ball_ToVariant( 0), "ulong_ptr", DllStructGetSize($tVariant)) DllStructSetData($tObject, "Properties", $pObject, 5) Local $oObject = ObjCreateInterface(DllStructGetPtr($tObject, "Object"), "{00020400-0000-0000-C000-000000000046}", Default, True) __Class_Ball___construct($oObject,$x,$y,$size) If @error <> 0 Then Return SetError(@error, @extended, 0) Return $oObject EndFunc Func __Object__Class_Ball_QueryInterface($pSelf, $pRIID, $pObj) ___Class__Ball_VariantHelperQueryInterface($pSelf, $pRIID, $pObj) EndFunc Func __Object__Class_Ball_AddRef($pSelf) Return ___Class__Ball_VariantHelperAddRef($pSelf) EndFunc Func __Object__Class_Ball_Release($pSelf) $tObject = DllStructCreate('int RefCount;int Size;ptr Object;ptr Methods[7];ptr Properties[5];', $pSelf - 8) $tObject.RefCount -= 1 If $tObject.RefCount > 0 Then Return $tObject.RefCount $pProperty = DllStructGetData($tObject, "Properties", 1) DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pProperty) DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", DllCall("kernel32.dll", "ptr", "GlobalHandle", "ptr", $pProperty)[0]) $pProperty = DllStructGetData($tObject, "Properties", 2) DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pProperty) DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", DllCall("kernel32.dll", "ptr", "GlobalHandle", "ptr", $pProperty)[0]) $pProperty = DllStructGetData($tObject, "Properties", 3) DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pProperty) DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", DllCall("kernel32.dll", "ptr", "GlobalHandle", "ptr", $pProperty)[0]) $pProperty = DllStructGetData($tObject, "Properties", 4) DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pProperty) DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", DllCall("kernel32.dll", "ptr", "GlobalHandle", "ptr", $pProperty)[0]) $pProperty = DllStructGetData($tObject, "Properties", 5) DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pProperty) DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", DllCall("kernel32.dll", "ptr", "GlobalHandle", "ptr", $pProperty)[0]) DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", DllCall("kernel32.dll", "ptr", "GlobalHandle", "ptr", DllStructGetPtr($tObject))[0]) Return 0 EndFunc Func __Object__Class_Ball_GetTypeInfoCount($pSelf, $pctinfo) Return ___Class__Ball_VariantHelperGetTypeInfoCount($pSelf, $pctinfo) EndFunc Func __Object__Class_Ball_GetTypeInfo($pSelf, $iTInfo, $lcid, $ppTInfo) Return ___Class__Ball_VariantHelperGetTypeInfo($pSelf, $iTInfo, $lcid, $ppTInfo) EndFunc Func __Object__Class_Ball_GetIDsOfNames($pSelf, $riid, $rgszNames, $cNames, $lcid, $rgDispId) Local $tId = DllStructCreate("long i", $rgDispId) Local $pStr = DllStructGetData(DllStructCreate("ptr", $rgszNames), 1) Local $s_rgszName = DllStructGetData(DllStructCreate("WCHAR[255]", $pStr), 1) Switch $s_rgszName Case "dx" DllStructSetData($tId, 1, 1) Case "dy" DllStructSetData($tId, 1, 2) Case "size" DllStructSetData($tId, 1, 3) Case "x" DllStructSetData($tId, 1, 4) Case "y" DllStructSetData($tId, 1, 5) Case "move" DllStructSetData($tId, 1, 6) Case Else DllStructSetData($tId, 1, -1) Return -2147352570 EndSwitch Return 0 EndFunc Func __Object__Class_Ball_Invoke($pSelf, $dispIdMember, $riid, $lcid, $wFlags, $pDispParams, $pVarResult, $pExcepInfo, $puArgErr) If $dispIdMember=-1 Then Return -2147352573 $tObject = DllStructCreate('int RefCount;int Size;ptr Object;ptr Methods[7];ptr Properties[5];', $pSelf - 8) Local Static $iVariant = DllStructGetSize(DllStructCreate("ushort vt;ushort r1;ushort r2;ushort r3;PTR data;PTR data2")) Local Static $Invoke = DllCallbackRegister(__Object__Class_Ball_InvokeAccessor, 'long', 'ptr;int;ptr;int;ushort;ptr;ptr;ptr;ptr') Switch $dispIdMember Case 1 If BitAND($wFlags, 2)=2 Then DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "ptr", DllStructGetData($tObject, "Properties", 1)) Return 0 EndIf Local $tParams = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tParams.cArgs <> 1 Then Return -2147352562 DllCall("OleAut32.dll","LONG","VariantClear","ptr",DllStructGetData($tObject, "Properties", 1)) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",DllStructGetData($tObject, "Properties", 1), "ptr", $tParams.rgvargs) Return 0 Case 2 If BitAND($wFlags, 2)=2 Then DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "ptr", DllStructGetData($tObject, "Properties", 2)) Return 0 EndIf Local $tParams = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tParams.cArgs <> 1 Then Return -2147352562 DllCall("OleAut32.dll","LONG","VariantClear","ptr",DllStructGetData($tObject, "Properties", 2)) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",DllStructGetData($tObject, "Properties", 2), "ptr", $tParams.rgvargs) Return 0 Case 3 If BitAND($wFlags, 2)=2 Then DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "ptr", DllStructGetData($tObject, "Properties", 3)) Return 0 EndIf Local $tParams = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tParams.cArgs <> 1 Then Return -2147352562 DllCall("OleAut32.dll","LONG","VariantClear","ptr",DllStructGetData($tObject, "Properties", 3)) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",DllStructGetData($tObject, "Properties", 3), "ptr", $tParams.rgvargs) Return 0 Case 4 If BitAND($wFlags, 2)=2 Then DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "ptr", DllStructGetData($tObject, "Properties", 4)) Return 0 EndIf Local $tParams = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tParams.cArgs <> 1 Then Return -2147352562 DllCall("OleAut32.dll","LONG","VariantClear","ptr",DllStructGetData($tObject, "Properties", 4)) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",DllStructGetData($tObject, "Properties", 4), "ptr", $tParams.rgvargs) Return 0 Case 5 If BitAND($wFlags, 2)=2 Then DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "ptr", DllStructGetData($tObject, "Properties", 5)) Return 0 EndIf Local $tParams = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tParams.cArgs <> 1 Then Return -2147352562 DllCall("OleAut32.dll","LONG","VariantClear","ptr",DllStructGetData($tObject, "Properties", 5)) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",DllStructGetData($tObject, "Properties", 5), "ptr", $tParams.rgvargs) Return 0 Case 6 If BitAND($wFlags, 4) = 4 Or BitAND($wFlags, 8) = 8 Then Return -2147352567 $tDISPPARAMS = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tDISPPARAMS.cArgs < 0 Or $tDISPPARAMS.cArgs > 0 Then Return -2147352562 __Object__Class_Ball_AddRef($pSelf) Local $parameters[$tDISPPARAMS.cArgs + 2] = ["CallArgArray", ObjCreateInterface(DllStructGetPtr($tObject, "Object"), "{00020400-0000-0000-C000-000000000046}", Default, True)] Local $j = 2 For $i=$tDISPPARAMS.cArgs-1 To 0 Step -1 $parameters[$j] = ___Class__Ball_FromVariant($tDISPPARAMS.rgvargs+$iVariant*$i) Next Local $vValue = Call(__Class_Ball_move, $parameters) If @error <> 0 Then Return -2147352567 $tVariant = ___Class__Ball_ToVariant($vValue) DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "struct*", $tVariant) Return 0 EndSwitch EndFunc Func __Object__Class_Ball_InvokeAccessor($pSelf, $dispIdMember, $riid, $lcid, $wFlags, $pDispParams, $pVarResult, $pExcepInfo, $puArgErr) Local $_tObject = DllStructCreate("int RefCount;int Size;ptr Object;ptr Methods[7];int PropertyIndex;ptr OriginalObject;", $pSelf - 8) If $dispIdMember = $_tObject.PropertyIndex Then $tObject = DllStructCreate('int RefCount;int Size;ptr Object;ptr Methods[7];ptr Properties[5];', $_tObject.OriginalObject - 8) If BitAND($wFlags, 2)=2 Then DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "ptr", DllStructGetData($tObject, "Properties", $dispIdMember)) Return 0 EndIf Local $tParams = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tParams.cArgs <> 1 Then Return -2147352562 DllCall("OleAut32.dll","LONG","VariantClear","ptr",DllStructGetData($tObject, "Properties", $dispIdMember)) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",DllStructGetData($tObject, "Properties", $dispIdMember), "ptr", $tParams.rgvargs) Return 0 EndIf Return __Object__Class_Ball_Invoke($_tObject.OriginalObject, $dispIdMember, $riid, $lcid, $wFlags, $pDispParams, $pVarResult, $pExcepInfo, $puArgErr) EndFunc Func __Class_Ball___construct($this, $x = 0, $y = 0, $size = 5) $this.x = $x $this.y = $y $this.size = $size EndFunc Func __Class_Ball_move($this) ; _move EndFunc Func ___Class__Paddle_VariantHelper() Local Static $tVariant = DllStructCreate("ushort vt;ushort r1;ushort r2;ushort r3;PTR data;PTR data2") Local Static $tObject = DllStructCreate("int RefCount;int Size;ptr Object;ptr Methods[7];ptr Variant;") Local Static $oObject = 0 If $oObject <> 0 Then Return $oObject Local $hQueryInterface = DllCallbackRegister(___Class__Paddle_VariantHelperQueryInterface, "LONG", "ptr;ptr;ptr") Local $hAddRef = DllCallbackRegister(___Class__Paddle_VariantHelperAddRef, "dword", "PTR") Local $hRelease = DllCallbackRegister(___Class__Paddle_VariantHelperRelease, "dword", "PTR") Local $hGetTypeInfoCount = DllCallbackRegister(___Class__Paddle_VariantHelperGetTypeInfoCount, "long", "ptr;ptr") Local $hGetTypeInfo = DllCallbackRegister(___Class__Paddle_VariantHelperGetTypeInfo, "long", "ptr;uint;int;ptr") Local $hGetIDsOfNames = DllCallbackRegister(___Class__Paddle_VariantHelperGetIDsOfNames, "long", "ptr;ptr;ptr;uint;int;ptr") Local $hInvoke = DllCallbackRegister(___Class__Paddle_VariantHelperInvoke, "long", "ptr;int;ptr;int;ushort;ptr;ptr;ptr;ptr") DllStructSetData($tObject, "Methods", DllCallbackGetPtr($hQueryInterface), 1) DllStructSetData($tObject, "Methods", DllCallbackGetPtr($hAddRef), 2) DllStructSetData($tObject, "Methods", DllCallbackGetPtr($hRelease), 3) DllStructSetData($tObject, "Methods", DllCallbackGetPtr($hGetTypeInfoCount), 4) DllStructSetData($tObject, "Methods", DllCallbackGetPtr($hGetTypeInfo), 5) DllStructSetData($tObject, "Methods", DllCallbackGetPtr($hGetIDsOfNames), 6) DllStructSetData($tObject, "Methods", DllCallbackGetPtr($hInvoke), 7) DllStructSetData($tObject, "RefCount", 1) ; initial ref count is 1 DllStructSetData($tObject, "Size", 7) ; number of interface methods DllStructSetData($tObject, "Object", DllStructGetPtr($tObject, "Methods")) ; Interface method pointers DllStructSetData($tObject, "Variant", DllStructGetPtr($tVariant)) $oObject = ObjCreateInterface(DllStructGetPtr($tObject, "Object"), "{00020400-0000-0000-C000-000000000046}", Default, True) ; pointer that's wrapped into object Return $oObject EndFunc Func ___Class__Paddle_VariantHelperQueryInterface($pSelf, $pRIID, $pObj) If $pObj=0 Then Return $__AOI_E_POINTER Local $sGUID=DllCall("ole32.dll", "int", "StringFromGUID2", "PTR", $pRIID, "wstr", "", "int", 40)[2] If (Not ($sGUID="{00020400-0000-0000-C000-000000000046}")) And (Not ($sGUID="{00000000-0000-0000-C000-000000000046}")) Then Return -2147467262 Local $tStruct = DllStructCreate("ptr", $pObj) DllStructSetData($tStruct, 1, $pSelf) ___Class__Paddle_VariantHelperAddRef($pSelf) Return 0 EndFunc Func ___Class__Paddle_VariantHelperAddRef($pSelf) Local $tStruct = DllStructCreate("int Ref", $pSelf - 8) $tStruct.Ref += 1 Return $tStruct.Ref EndFunc Func ___Class__Paddle_VariantHelperRelease($pSelf) Local $tObject = DllStructCreate("int RefCount;int Size;ptr Object;ptr Methods[7];ptr Variant;", $pSelf - 8) $tObject.RefCount -= 1 If $tObject.RefCount > 0 Then Return $tObject.RefCount DllCall("OleAut32.dll","LONG","VariantClear","ptr",$tObject.Variant) DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", DllCall("kernel32.dll", "ptr", "GlobalHandle", "ptr", $tObject.Variant)[0]) DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", DllCall("kernel32.dll", "ptr", "GlobalHandle", "ptr", DllStructGetPtr($tObject))[0]) Return 0 EndFunc Func ___Class__Paddle_VariantHelperGetTypeInfoCount($pSelf, $pctinfo) DllStructSetData(DllStructCreate("UINT",$pctinfo),1, 0) Return 0 EndFunc Func ___Class__Paddle_VariantHelperGetTypeInfo($pSelf, $iTInfo, $lcid, $ppTInfo) If $iTInfo<>0 Then Return -2147352565 If $ppTInfo=0 Then Return -2147024809 Return 0 EndFunc Func ___Class__Paddle_VariantHelperGetIDsOfNames($pSelf, $riid, $rgszNames, $cNames, $lcid, $rgDispId) Local $tIds = DllStructCreate("long i", $rgDispId) DllStructSetData($tIds, 1, 1) Return 0 EndFunc Func ___Class__Paddle_VariantHelperInvoke($pSelf, $dispIdMember, $riid, $lcid, $wFlags, $pDispParams, $pVarResult, $pExcepInfo, $puArgErr) Local $tObject = DllStructCreate("int RefCount;int Size;ptr Object;ptr Methods[7];ptr Variant;", $pSelf - 8) If BitAND($wFlags, 2) = 2 Then DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "ptr", $tObject.Variant) Return 0 EndIf If BitAND($wFlags, 4) = 4 Then $tParams = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tParams.cArgs <> 1 Then Return -2147352562 DllCall("OleAut32.dll","LONG","VariantClear","ptr",$tObject.Variant) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$tObject.Variant, "ptr", $tParams.rgvargs) Return 0 EndIf Return -2147352567 EndFunc Func ___Class__Paddle_ToVariant($vValue) Local $oObject = ___Class__Paddle_VariantHelper() $oObject.a = $vValue Local $tObject = DllStructCreate("int RefCount;int Size;ptr Object;ptr Methods[7];ptr Variant;", ptr($oObject) - 8) Local $tVariant = DllStructCreate("ushort vt;ushort r1;ushort r2;ushort r3;PTR data;PTR data2") DllCall("OleAut32.dll","LONG","VariantClear","struct*",$tVariant) DllCall("OleAut32.dll","LONG","VariantCopy","struct*",$tVariant, "ptr", $tObject.Variant) Return $tVariant EndFunc Func ___Class__Paddle_FromVariant($pVariant) Local $oObject = ___Class__Paddle_VariantHelper() Local $tObject = DllStructCreate("int RefCount;int Size;ptr Object;ptr Methods[7];ptr Variant;", ptr($oObject) - 8) DllCall("OleAut32.dll","LONG","VariantClear","ptr",$tObject.Variant) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$tObject.Variant, "struct*", $pVariant) Return $oObject.a EndFunc Func Paddle($x = 0, $size = 5) Local Static $QueryInterface = DllCallbackRegister(__Object__Class_Paddle_QueryInterface, 'LONG', 'ptr;ptr;ptr'), $AddRef = DllCallbackRegister(__Object__Class_Paddle_AddRef, 'dword', 'PTR'), $Release = DllCallbackRegister(__Object__Class_Paddle_Release, 'dword', 'PTR'), $GetTypeInfoCount = DllCallbackRegister(__Object__Class_Paddle_GetTypeInfoCount, 'long', 'ptr;ptr'), $GetTypeInfo = DllCallbackRegister(__Object__Class_Paddle_GetTypeInfo, 'long', 'ptr;uint;int;ptr'), $GetIDsOfNames = DllCallbackRegister(__Object__Class_Paddle_GetIDsOfNames, 'long', 'ptr;ptr;ptr;uint;int;ptr'), $Invoke = DllCallbackRegister(__Object__Class_Paddle_Invoke, 'long', 'ptr;int;ptr;int;ushort;ptr;ptr;ptr;ptr') $tObject = DllStructCreate('int RefCount;int Size;ptr Object;ptr Methods[7];ptr Properties[3];') DllStructSetData($tObject, 'Methods', DllCallbackGetPtr($QueryInterface), 1) DllStructSetData($tObject, 'Methods', DllCallbackGetPtr($AddRef), 2) DllStructSetData($tObject, 'Methods', DllCallbackGetPtr($Release), 3) DllStructSetData($tObject, 'Methods', DllCallbackGetPtr($GetTypeInfoCount), 4) DllStructSetData($tObject, 'Methods', DllCallbackGetPtr($GetTypeInfo), 5) DllStructSetData($tObject, 'Methods', DllCallbackGetPtr($GetIDsOfNames), 6) DllStructSetData($tObject, 'Methods', DllCallbackGetPtr($Invoke), 7) DllStructSetData($tObject, 'RefCount', 1) DllStructSetData($tObject, 'Size', 7) $pObject = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", 0x0002, "ulong_ptr", DllStructGetSize($tObject))[0])[0] DllCall("kernel32.dll", "none", "RtlMoveMemory", "struct*", $pObject, "struct*", $tObject, "ulong_ptr", DllStructGetSize($tObject)) $tObject = DllStructCreate('int RefCount;int Size;ptr Object;ptr Methods[7];ptr Properties[3];', $pObject) DllStructSetData($tObject, "Object", DllStructGetPtr($tObject, "Methods")) Local Static $tVariant = DllStructCreate("ushort vt;ushort r1;ushort r2;ushort r3;PTR data;PTR data2") DllStructSetData($tVariant, 'vt', 1) $pObject = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", 0x0002, "ulong_ptr", DllStructGetSize($tVariant))[0])[0] DllCall("kernel32.dll", "none", "RtlMoveMemory", "struct*", $pObject, "struct*", ___Class__Paddle_ToVariant( 0), "ulong_ptr", DllStructGetSize($tVariant)) DllStructSetData($tObject, "Properties", $pObject, 1) $pObject = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", 0x0002, "ulong_ptr", DllStructGetSize($tVariant))[0])[0] DllCall("kernel32.dll", "none", "RtlMoveMemory", "struct*", $pObject, "struct*", ___Class__Paddle_ToVariant( 5), "ulong_ptr", DllStructGetSize($tVariant)) DllStructSetData($tObject, "Properties", $pObject, 2) $pObject = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", 0x0002, "ulong_ptr", DllStructGetSize($tVariant))[0])[0] DllCall("kernel32.dll", "none", "RtlMoveMemory", "struct*", $pObject, "struct*", ___Class__Paddle_ToVariant( 20), "ulong_ptr", DllStructGetSize($tVariant)) DllStructSetData($tObject, "Properties", $pObject, 3) Local $oObject = ObjCreateInterface(DllStructGetPtr($tObject, "Object"), "{00020400-0000-0000-C000-000000000046}", Default, True) __Class_Paddle___construct($oObject,$x,$size) If @error <> 0 Then Return SetError(@error, @extended, 0) Return $oObject EndFunc Func __Object__Class_Paddle_QueryInterface($pSelf, $pRIID, $pObj) ___Class__Paddle_VariantHelperQueryInterface($pSelf, $pRIID, $pObj) EndFunc Func __Object__Class_Paddle_AddRef($pSelf) Return ___Class__Paddle_VariantHelperAddRef($pSelf) EndFunc Func __Object__Class_Paddle_Release($pSelf) $tObject = DllStructCreate('int RefCount;int Size;ptr Object;ptr Methods[7];ptr Properties[3];', $pSelf - 8) $tObject.RefCount -= 1 If $tObject.RefCount > 0 Then Return $tObject.RefCount $pProperty = DllStructGetData($tObject, "Properties", 1) DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pProperty) DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", DllCall("kernel32.dll", "ptr", "GlobalHandle", "ptr", $pProperty)[0]) $pProperty = DllStructGetData($tObject, "Properties", 2) DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pProperty) DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", DllCall("kernel32.dll", "ptr", "GlobalHandle", "ptr", $pProperty)[0]) $pProperty = DllStructGetData($tObject, "Properties", 3) DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pProperty) DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", DllCall("kernel32.dll", "ptr", "GlobalHandle", "ptr", $pProperty)[0]) DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", DllCall("kernel32.dll", "ptr", "GlobalHandle", "ptr", DllStructGetPtr($tObject))[0]) Return 0 EndFunc Func __Object__Class_Paddle_GetTypeInfoCount($pSelf, $pctinfo) Return ___Class__Paddle_VariantHelperGetTypeInfoCount($pSelf, $pctinfo) EndFunc Func __Object__Class_Paddle_GetTypeInfo($pSelf, $iTInfo, $lcid, $ppTInfo) Return ___Class__Paddle_VariantHelperGetTypeInfo($pSelf, $iTInfo, $lcid, $ppTInfo) EndFunc Func __Object__Class_Paddle_GetIDsOfNames($pSelf, $riid, $rgszNames, $cNames, $lcid, $rgDispId) Local $tId = DllStructCreate("long i", $rgDispId) Local $pStr = DllStructGetData(DllStructCreate("ptr", $rgszNames), 1) Local $s_rgszName = DllStructGetData(DllStructCreate("WCHAR[255]", $pStr), 1) Switch $s_rgszName Case "X" DllStructSetData($tId, 1, 1) Case "size" DllStructSetData($tId, 1, 2) Case "dx" DllStructSetData($tId, 1, 3) Case "moveLeft" DllStructSetData($tId, 1, 4) Case "moveRight" DllStructSetData($tId, 1, 5) Case Else DllStructSetData($tId, 1, -1) Return -2147352570 EndSwitch Return 0 EndFunc Func __Object__Class_Paddle_Invoke($pSelf, $dispIdMember, $riid, $lcid, $wFlags, $pDispParams, $pVarResult, $pExcepInfo, $puArgErr) If $dispIdMember=-1 Then Return -2147352573 $tObject = DllStructCreate('int RefCount;int Size;ptr Object;ptr Methods[7];ptr Properties[3];', $pSelf - 8) Local Static $iVariant = DllStructGetSize(DllStructCreate("ushort vt;ushort r1;ushort r2;ushort r3;PTR data;PTR data2")) Local Static $Invoke = DllCallbackRegister(__Object__Class_Paddle_InvokeAccessor, 'long', 'ptr;int;ptr;int;ushort;ptr;ptr;ptr;ptr') Switch $dispIdMember Case 1 If BitAND($wFlags, 2)=2 Then DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "ptr", DllStructGetData($tObject, "Properties", 1)) Return 0 EndIf Local $tParams = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tParams.cArgs <> 1 Then Return -2147352562 DllCall("OleAut32.dll","LONG","VariantClear","ptr",DllStructGetData($tObject, "Properties", 1)) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",DllStructGetData($tObject, "Properties", 1), "ptr", $tParams.rgvargs) Return 0 Case 2 If BitAND($wFlags, 2)=2 Then DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "ptr", DllStructGetData($tObject, "Properties", 2)) Return 0 EndIf Local $tParams = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tParams.cArgs <> 1 Then Return -2147352562 DllCall("OleAut32.dll","LONG","VariantClear","ptr",DllStructGetData($tObject, "Properties", 2)) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",DllStructGetData($tObject, "Properties", 2), "ptr", $tParams.rgvargs) Return 0 Case 3 If BitAND($wFlags, 2)=2 Then DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "ptr", DllStructGetData($tObject, "Properties", 3)) Return 0 EndIf Local $tParams = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tParams.cArgs <> 1 Then Return -2147352562 DllCall("OleAut32.dll","LONG","VariantClear","ptr",DllStructGetData($tObject, "Properties", 3)) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",DllStructGetData($tObject, "Properties", 3), "ptr", $tParams.rgvargs) Return 0 Case 4 If BitAND($wFlags, 4) = 4 Or BitAND($wFlags, 8) = 8 Then Return -2147352567 $tDISPPARAMS = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tDISPPARAMS.cArgs < 0 Or $tDISPPARAMS.cArgs > 0 Then Return -2147352562 __Object__Class_Paddle_AddRef($pSelf) Local $parameters[$tDISPPARAMS.cArgs + 2] = ["CallArgArray", ObjCreateInterface(DllStructGetPtr($tObject, "Object"), "{00020400-0000-0000-C000-000000000046}", Default, True)] Local $j = 2 For $i=$tDISPPARAMS.cArgs-1 To 0 Step -1 $parameters[$j] = ___Class__Paddle_FromVariant($tDISPPARAMS.rgvargs+$iVariant*$i) Next Local $vValue = Call(__Class_Paddle_moveLeft, $parameters) If @error <> 0 Then Return -2147352567 $tVariant = ___Class__Paddle_ToVariant($vValue) DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "struct*", $tVariant) Return 0 Case 5 If BitAND($wFlags, 4) = 4 Or BitAND($wFlags, 8) = 8 Then Return -2147352567 $tDISPPARAMS = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tDISPPARAMS.cArgs < 1 Or $tDISPPARAMS.cArgs > 1 Then Return -2147352562 __Object__Class_Paddle_AddRef($pSelf) Local $parameters[$tDISPPARAMS.cArgs + 2] = ["CallArgArray", ObjCreateInterface(DllStructGetPtr($tObject, "Object"), "{00020400-0000-0000-C000-000000000046}", Default, True)] Local $j = 2 For $i=$tDISPPARAMS.cArgs-1 To 0 Step -1 $parameters[$j] = ___Class__Paddle_FromVariant($tDISPPARAMS.rgvargs+$iVariant*$i) Next Local $vValue = Call(__Class_Paddle_moveRight, $parameters) If @error <> 0 Then Return -2147352567 $tVariant = ___Class__Paddle_ToVariant($vValue) DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "struct*", $tVariant) Return 0 EndSwitch EndFunc Func __Object__Class_Paddle_InvokeAccessor($pSelf, $dispIdMember, $riid, $lcid, $wFlags, $pDispParams, $pVarResult, $pExcepInfo, $puArgErr) Local $_tObject = DllStructCreate("int RefCount;int Size;ptr Object;ptr Methods[7];int PropertyIndex;ptr OriginalObject;", $pSelf - 8) If $dispIdMember = $_tObject.PropertyIndex Then $tObject = DllStructCreate('int RefCount;int Size;ptr Object;ptr Methods[7];ptr Properties[3];', $_tObject.OriginalObject - 8) If BitAND($wFlags, 2)=2 Then DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "ptr", DllStructGetData($tObject, "Properties", $dispIdMember)) Return 0 EndIf Local $tParams = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tParams.cArgs <> 1 Then Return -2147352562 DllCall("OleAut32.dll","LONG","VariantClear","ptr",DllStructGetData($tObject, "Properties", $dispIdMember)) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",DllStructGetData($tObject, "Properties", $dispIdMember), "ptr", $tParams.rgvargs) Return 0 EndIf Return __Object__Class_Paddle_Invoke($_tObject.OriginalObject, $dispIdMember, $riid, $lcid, $wFlags, $pDispParams, $pVarResult, $pExcepInfo, $puArgErr) EndFunc Func __Class_Paddle___construct($this, $x = 0, $size = 5) $this.X = $x $this.size = $size EndFunc Func __Class_Paddle_moveLeft($this) $this.X -= $this.dx If $this.X < 0 Then $this.X = 0 EndFunc Func __Class_Paddle_moveRight($this,$maxX) Local $paddleWidth = $this.size If $this.X + $this.dx + $paddleWidth <= $maxX Then $this.X += $this.dx Else $this.X = $maxX - $paddleWidth EndIf EndFunc Func ___Class__GamePanel_VariantHelper() Local Static $tVariant = DllStructCreate("ushort vt;ushort r1;ushort r2;ushort r3;PTR data;PTR data2") Local Static $tObject = DllStructCreate("int RefCount;int Size;ptr Object;ptr Methods[7];ptr Variant;") Local Static $oObject = 0 If $oObject <> 0 Then Return $oObject Local $hQueryInterface = DllCallbackRegister(___Class__GamePanel_VariantHelperQueryInterface, "LONG", "ptr;ptr;ptr") Local $hAddRef = DllCallbackRegister(___Class__GamePanel_VariantHelperAddRef, "dword", "PTR") Local $hRelease = DllCallbackRegister(___Class__GamePanel_VariantHelperRelease, "dword", "PTR") Local $hGetTypeInfoCount = DllCallbackRegister(___Class__GamePanel_VariantHelperGetTypeInfoCount, "long", "ptr;ptr") Local $hGetTypeInfo = DllCallbackRegister(___Class__GamePanel_VariantHelperGetTypeInfo, "long", "ptr;uint;int;ptr") Local $hGetIDsOfNames = DllCallbackRegister(___Class__GamePanel_VariantHelperGetIDsOfNames, "long", "ptr;ptr;ptr;uint;int;ptr") Local $hInvoke = DllCallbackRegister(___Class__GamePanel_VariantHelperInvoke, "long", "ptr;int;ptr;int;ushort;ptr;ptr;ptr;ptr") DllStructSetData($tObject, "Methods", DllCallbackGetPtr($hQueryInterface), 1) DllStructSetData($tObject, "Methods", DllCallbackGetPtr($hAddRef), 2) DllStructSetData($tObject, "Methods", DllCallbackGetPtr($hRelease), 3) DllStructSetData($tObject, "Methods", DllCallbackGetPtr($hGetTypeInfoCount), 4) DllStructSetData($tObject, "Methods", DllCallbackGetPtr($hGetTypeInfo), 5) DllStructSetData($tObject, "Methods", DllCallbackGetPtr($hGetIDsOfNames), 6) DllStructSetData($tObject, "Methods", DllCallbackGetPtr($hInvoke), 7) DllStructSetData($tObject, "RefCount", 1) ; initial ref count is 1 DllStructSetData($tObject, "Size", 7) ; number of interface methods DllStructSetData($tObject, "Object", DllStructGetPtr($tObject, "Methods")) ; Interface method pointers DllStructSetData($tObject, "Variant", DllStructGetPtr($tVariant)) $oObject = ObjCreateInterface(DllStructGetPtr($tObject, "Object"), "{00020400-0000-0000-C000-000000000046}", Default, True) ; pointer that's wrapped into object Return $oObject EndFunc Func ___Class__GamePanel_VariantHelperQueryInterface($pSelf, $pRIID, $pObj) If $pObj=0 Then Return $__AOI_E_POINTER Local $sGUID=DllCall("ole32.dll", "int", "StringFromGUID2", "PTR", $pRIID, "wstr", "", "int", 40)[2] If (Not ($sGUID="{00020400-0000-0000-C000-000000000046}")) And (Not ($sGUID="{00000000-0000-0000-C000-000000000046}")) Then Return -2147467262 Local $tStruct = DllStructCreate("ptr", $pObj) DllStructSetData($tStruct, 1, $pSelf) ___Class__GamePanel_VariantHelperAddRef($pSelf) Return 0 EndFunc Func ___Class__GamePanel_VariantHelperAddRef($pSelf) Local $tStruct = DllStructCreate("int Ref", $pSelf - 8) $tStruct.Ref += 1 Return $tStruct.Ref EndFunc Func ___Class__GamePanel_VariantHelperRelease($pSelf) Local $tObject = DllStructCreate("int RefCount;int Size;ptr Object;ptr Methods[7];ptr Variant;", $pSelf - 8) $tObject.RefCount -= 1 If $tObject.RefCount > 0 Then Return $tObject.RefCount DllCall("OleAut32.dll","LONG","VariantClear","ptr",$tObject.Variant) DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", DllCall("kernel32.dll", "ptr", "GlobalHandle", "ptr", $tObject.Variant)[0]) DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", DllCall("kernel32.dll", "ptr", "GlobalHandle", "ptr", DllStructGetPtr($tObject))[0]) Return 0 EndFunc Func ___Class__GamePanel_VariantHelperGetTypeInfoCount($pSelf, $pctinfo) DllStructSetData(DllStructCreate("UINT",$pctinfo),1, 0) Return 0 EndFunc Func ___Class__GamePanel_VariantHelperGetTypeInfo($pSelf, $iTInfo, $lcid, $ppTInfo) If $iTInfo<>0 Then Return -2147352565 If $ppTInfo=0 Then Return -2147024809 Return 0 EndFunc Func ___Class__GamePanel_VariantHelperGetIDsOfNames($pSelf, $riid, $rgszNames, $cNames, $lcid, $rgDispId) Local $tIds = DllStructCreate("long i", $rgDispId) DllStructSetData($tIds, 1, 1) Return 0 EndFunc Func ___Class__GamePanel_VariantHelperInvoke($pSelf, $dispIdMember, $riid, $lcid, $wFlags, $pDispParams, $pVarResult, $pExcepInfo, $puArgErr) Local $tObject = DllStructCreate("int RefCount;int Size;ptr Object;ptr Methods[7];ptr Variant;", $pSelf - 8) If BitAND($wFlags, 2) = 2 Then DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "ptr", $tObject.Variant) Return 0 EndIf If BitAND($wFlags, 4) = 4 Then $tParams = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tParams.cArgs <> 1 Then Return -2147352562 DllCall("OleAut32.dll","LONG","VariantClear","ptr",$tObject.Variant) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$tObject.Variant, "ptr", $tParams.rgvargs) Return 0 EndIf Return -2147352567 EndFunc Func ___Class__GamePanel_ToVariant($vValue) Local $oObject = ___Class__GamePanel_VariantHelper() $oObject.a = $vValue Local $tObject = DllStructCreate("int RefCount;int Size;ptr Object;ptr Methods[7];ptr Variant;", ptr($oObject) - 8) Local $tVariant = DllStructCreate("ushort vt;ushort r1;ushort r2;ushort r3;PTR data;PTR data2") DllCall("OleAut32.dll","LONG","VariantClear","struct*",$tVariant) DllCall("OleAut32.dll","LONG","VariantCopy","struct*",$tVariant, "ptr", $tObject.Variant) Return $tVariant EndFunc Func ___Class__GamePanel_FromVariant($pVariant) Local $oObject = ___Class__GamePanel_VariantHelper() Local $tObject = DllStructCreate("int RefCount;int Size;ptr Object;ptr Methods[7];ptr Variant;", ptr($oObject) - 8) DllCall("OleAut32.dll","LONG","VariantClear","ptr",$tObject.Variant) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$tObject.Variant, "struct*", $pVariant) Return $oObject.a EndFunc Func GamePanel() Local Static $QueryInterface = DllCallbackRegister(__Object__Class_GamePanel_QueryInterface, 'LONG', 'ptr;ptr;ptr'), $AddRef = DllCallbackRegister(__Object__Class_GamePanel_AddRef, 'dword', 'PTR'), $Release = DllCallbackRegister(__Object__Class_GamePanel_Release, 'dword', 'PTR'), $GetTypeInfoCount = DllCallbackRegister(__Object__Class_GamePanel_GetTypeInfoCount, 'long', 'ptr;ptr'), $GetTypeInfo = DllCallbackRegister(__Object__Class_GamePanel_GetTypeInfo, 'long', 'ptr;uint;int;ptr'), $GetIDsOfNames = DllCallbackRegister(__Object__Class_GamePanel_GetIDsOfNames, 'long', 'ptr;ptr;ptr;uint;int;ptr'), $Invoke = DllCallbackRegister(__Object__Class_GamePanel_Invoke, 'long', 'ptr;int;ptr;int;ushort;ptr;ptr;ptr;ptr') $tObject = DllStructCreate('int RefCount;int Size;ptr Object;ptr Methods[7];ptr Properties[6];') DllStructSetData($tObject, 'Methods', DllCallbackGetPtr($QueryInterface), 1) DllStructSetData($tObject, 'Methods', DllCallbackGetPtr($AddRef), 2) DllStructSetData($tObject, 'Methods', DllCallbackGetPtr($Release), 3) DllStructSetData($tObject, 'Methods', DllCallbackGetPtr($GetTypeInfoCount), 4) DllStructSetData($tObject, 'Methods', DllCallbackGetPtr($GetTypeInfo), 5) DllStructSetData($tObject, 'Methods', DllCallbackGetPtr($GetIDsOfNames), 6) DllStructSetData($tObject, 'Methods', DllCallbackGetPtr($Invoke), 7) DllStructSetData($tObject, 'RefCount', 1) DllStructSetData($tObject, 'Size', 7) $pObject = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", 0x0002, "ulong_ptr", DllStructGetSize($tObject))[0])[0] DllCall("kernel32.dll", "none", "RtlMoveMemory", "struct*", $pObject, "struct*", $tObject, "ulong_ptr", DllStructGetSize($tObject)) $tObject = DllStructCreate('int RefCount;int Size;ptr Object;ptr Methods[7];ptr Properties[6];', $pObject) DllStructSetData($tObject, "Object", DllStructGetPtr($tObject, "Methods")) Local Static $tVariant = DllStructCreate("ushort vt;ushort r1;ushort r2;ushort r3;PTR data;PTR data2") DllStructSetData($tVariant, 'vt', 1) $pObject = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", 0x0002, "ulong_ptr", DllStructGetSize($tVariant))[0])[0] DllCall("kernel32.dll", "none", "RtlMoveMemory", "struct*", $pObject, "struct*", $tVariant, "ulong_ptr", DllStructGetSize($tVariant)) DllStructSetData($tObject, "Properties", $pObject, 1) $pObject = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", 0x0002, "ulong_ptr", DllStructGetSize($tVariant))[0])[0] DllCall("kernel32.dll", "none", "RtlMoveMemory", "struct*", $pObject, "struct*", $tVariant, "ulong_ptr", DllStructGetSize($tVariant)) DllStructSetData($tObject, "Properties", $pObject, 2) $pObject = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", 0x0002, "ulong_ptr", DllStructGetSize($tVariant))[0])[0] DllCall("kernel32.dll", "none", "RtlMoveMemory", "struct*", $pObject, "struct*", $tVariant, "ulong_ptr", DllStructGetSize($tVariant)) DllStructSetData($tObject, "Properties", $pObject, 3) $pObject = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", 0x0002, "ulong_ptr", DllStructGetSize($tVariant))[0])[0] DllCall("kernel32.dll", "none", "RtlMoveMemory", "struct*", $pObject, "struct*", $tVariant, "ulong_ptr", DllStructGetSize($tVariant)) DllStructSetData($tObject, "Properties", $pObject, 4) $pObject = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", 0x0002, "ulong_ptr", DllStructGetSize($tVariant))[0])[0] DllCall("kernel32.dll", "none", "RtlMoveMemory", "struct*", $pObject, "struct*", $tVariant, "ulong_ptr", DllStructGetSize($tVariant)) DllStructSetData($tObject, "Properties", $pObject, 5) $pObject = DllCall("kernel32.dll", "ptr", "GlobalLock", "handle", DllCall("kernel32.dll", "handle", "GlobalAlloc", "uint", 0x0002, "ulong_ptr", DllStructGetSize($tVariant))[0])[0] DllCall("kernel32.dll", "none", "RtlMoveMemory", "struct*", $pObject, "struct*", ___Class__GamePanel_ToVariant( 100), "ulong_ptr", DllStructGetSize($tVariant)) DllStructSetData($tObject, "Properties", $pObject, 6) Local $oObject = ObjCreateInterface(DllStructGetPtr($tObject, "Object"), "{00020400-0000-0000-C000-000000000046}", Default, True) __Class_GamePanel___construct($oObject) If @error <> 0 Then Return SetError(@error, @extended, 0) Return $oObject EndFunc Func __Object__Class_GamePanel_QueryInterface($pSelf, $pRIID, $pObj) ___Class__GamePanel_VariantHelperQueryInterface($pSelf, $pRIID, $pObj) EndFunc Func __Object__Class_GamePanel_AddRef($pSelf) Return ___Class__GamePanel_VariantHelperAddRef($pSelf) EndFunc Func __Object__Class_GamePanel_Release($pSelf) $tObject = DllStructCreate('int RefCount;int Size;ptr Object;ptr Methods[7];ptr Properties[6];', $pSelf - 8) $tObject.RefCount -= 1 If $tObject.RefCount > 0 Then Return $tObject.RefCount $pProperty = DllStructGetData($tObject, "Properties", 1) DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pProperty) DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", DllCall("kernel32.dll", "ptr", "GlobalHandle", "ptr", $pProperty)[0]) $pProperty = DllStructGetData($tObject, "Properties", 2) DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pProperty) DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", DllCall("kernel32.dll", "ptr", "GlobalHandle", "ptr", $pProperty)[0]) $pProperty = DllStructGetData($tObject, "Properties", 3) DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pProperty) DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", DllCall("kernel32.dll", "ptr", "GlobalHandle", "ptr", $pProperty)[0]) $pProperty = DllStructGetData($tObject, "Properties", 4) DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pProperty) DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", DllCall("kernel32.dll", "ptr", "GlobalHandle", "ptr", $pProperty)[0]) $pProperty = DllStructGetData($tObject, "Properties", 5) DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pProperty) DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", DllCall("kernel32.dll", "ptr", "GlobalHandle", "ptr", $pProperty)[0]) $pProperty = DllStructGetData($tObject, "Properties", 6) DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pProperty) DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", DllCall("kernel32.dll", "ptr", "GlobalHandle", "ptr", $pProperty)[0]) DllCall("kernel32.dll", "ptr", "GlobalFree", "handle", DllCall("kernel32.dll", "ptr", "GlobalHandle", "ptr", DllStructGetPtr($tObject))[0]) Return 0 EndFunc Func __Object__Class_GamePanel_GetTypeInfoCount($pSelf, $pctinfo) Return ___Class__GamePanel_VariantHelperGetTypeInfoCount($pSelf, $pctinfo) EndFunc Func __Object__Class_GamePanel_GetTypeInfo($pSelf, $iTInfo, $lcid, $ppTInfo) Return ___Class__GamePanel_VariantHelperGetTypeInfo($pSelf, $iTInfo, $lcid, $ppTInfo) EndFunc Func __Object__Class_GamePanel_GetIDsOfNames($pSelf, $riid, $rgszNames, $cNames, $lcid, $rgDispId) Local $tId = DllStructCreate("long i", $rgDispId) Local $pStr = DllStructGetData(DllStructCreate("ptr", $rgszNames), 1) Local $s_rgszName = DllStructGetData(DllStructCreate("WCHAR[255]", $pStr), 1) Switch $s_rgszName Case "iWidth" DllStructSetData($tId, 1, 1) Case "iHeight" DllStructSetData($tId, 1, 2) Case "ball" DllStructSetData($tId, 1, 3) Case "paddle" DllStructSetData($tId, 1, 4) Case "map" DllStructSetData($tId, 1, 5) Case "speedLevel" DllStructSetData($tId, 1, 6) Case "__destructor" DllStructSetData($tId, 1, 7) Case "move" DllStructSetData($tId, 1, 8) Case "drawStage" DllStructSetData($tId, 1, 9) Case "cleanUpResources" DllStructSetData($tId, 1, 10) Case "runGameLoop" DllStructSetData($tId, 1, 11) Case Else DllStructSetData($tId, 1, -1) Return -2147352570 EndSwitch Return 0 EndFunc Func __Object__Class_GamePanel_Invoke($pSelf, $dispIdMember, $riid, $lcid, $wFlags, $pDispParams, $pVarResult, $pExcepInfo, $puArgErr) If $dispIdMember=-1 Then Return -2147352573 $tObject = DllStructCreate('int RefCount;int Size;ptr Object;ptr Methods[7];ptr Properties[6];', $pSelf - 8) Local Static $iVariant = DllStructGetSize(DllStructCreate("ushort vt;ushort r1;ushort r2;ushort r3;PTR data;PTR data2")) Local Static $Invoke = DllCallbackRegister(__Object__Class_GamePanel_InvokeAccessor, 'long', 'ptr;int;ptr;int;ushort;ptr;ptr;ptr;ptr') Switch $dispIdMember Case 1 If BitAND($wFlags, 2)=2 Then DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "ptr", DllStructGetData($tObject, "Properties", 1)) Return 0 EndIf Local $tParams = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tParams.cArgs <> 1 Then Return -2147352562 DllCall("OleAut32.dll","LONG","VariantClear","ptr",DllStructGetData($tObject, "Properties", 1)) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",DllStructGetData($tObject, "Properties", 1), "ptr", $tParams.rgvargs) Return 0 Case 2 If BitAND($wFlags, 2)=2 Then DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "ptr", DllStructGetData($tObject, "Properties", 2)) Return 0 EndIf Local $tParams = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tParams.cArgs <> 1 Then Return -2147352562 DllCall("OleAut32.dll","LONG","VariantClear","ptr",DllStructGetData($tObject, "Properties", 2)) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",DllStructGetData($tObject, "Properties", 2), "ptr", $tParams.rgvargs) Return 0 Case 3 If BitAND($wFlags, 2)=2 Then DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "ptr", DllStructGetData($tObject, "Properties", 3)) Return 0 EndIf Local $tParams = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tParams.cArgs <> 1 Then Return -2147352562 DllCall("OleAut32.dll","LONG","VariantClear","ptr",DllStructGetData($tObject, "Properties", 3)) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",DllStructGetData($tObject, "Properties", 3), "ptr", $tParams.rgvargs) Return 0 Case 4 If BitAND($wFlags, 2)=2 Then DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "ptr", DllStructGetData($tObject, "Properties", 4)) Return 0 EndIf Local $tParams = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tParams.cArgs <> 1 Then Return -2147352562 DllCall("OleAut32.dll","LONG","VariantClear","ptr",DllStructGetData($tObject, "Properties", 4)) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",DllStructGetData($tObject, "Properties", 4), "ptr", $tParams.rgvargs) Return 0 Case 5 If BitAND($wFlags, 2)=2 Then DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "ptr", DllStructGetData($tObject, "Properties", 5)) Return 0 EndIf Local $tParams = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tParams.cArgs <> 1 Then Return -2147352562 DllCall("OleAut32.dll","LONG","VariantClear","ptr",DllStructGetData($tObject, "Properties", 5)) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",DllStructGetData($tObject, "Properties", 5), "ptr", $tParams.rgvargs) Return 0 Case 6 If BitAND($wFlags, 2)=2 Then DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "ptr", DllStructGetData($tObject, "Properties", 6)) Return 0 EndIf Local $tParams = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tParams.cArgs <> 1 Then Return -2147352562 DllCall("OleAut32.dll","LONG","VariantClear","ptr",DllStructGetData($tObject, "Properties", 6)) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",DllStructGetData($tObject, "Properties", 6), "ptr", $tParams.rgvargs) Return 0 Case 7 If BitAND($wFlags, 4) = 4 Or BitAND($wFlags, 8) = 8 Then Return -2147352567 $tDISPPARAMS = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tDISPPARAMS.cArgs < 0 Or $tDISPPARAMS.cArgs > 0 Then Return -2147352562 __Object__Class_GamePanel_AddRef($pSelf) Local $parameters[$tDISPPARAMS.cArgs + 2] = ["CallArgArray", ObjCreateInterface(DllStructGetPtr($tObject, "Object"), "{00020400-0000-0000-C000-000000000046}", Default, True)] Local $j = 2 For $i=$tDISPPARAMS.cArgs-1 To 0 Step -1 $parameters[$j] = ___Class__GamePanel_FromVariant($tDISPPARAMS.rgvargs+$iVariant*$i) Next Local $vValue = Call(__Class_GamePanel___destructor, $parameters) If @error <> 0 Then Return -2147352567 $tVariant = ___Class__GamePanel_ToVariant($vValue) DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "struct*", $tVariant) Return 0 Case 8 If BitAND($wFlags, 4) = 4 Or BitAND($wFlags, 8) = 8 Then Return -2147352567 $tDISPPARAMS = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tDISPPARAMS.cArgs < 0 Or $tDISPPARAMS.cArgs > 0 Then Return -2147352562 __Object__Class_GamePanel_AddRef($pSelf) Local $parameters[$tDISPPARAMS.cArgs + 2] = ["CallArgArray", ObjCreateInterface(DllStructGetPtr($tObject, "Object"), "{00020400-0000-0000-C000-000000000046}", Default, True)] Local $j = 2 For $i=$tDISPPARAMS.cArgs-1 To 0 Step -1 $parameters[$j] = ___Class__GamePanel_FromVariant($tDISPPARAMS.rgvargs+$iVariant*$i) Next Local $vValue = Call(__Class_GamePanel_move, $parameters) If @error <> 0 Then Return -2147352567 $tVariant = ___Class__GamePanel_ToVariant($vValue) DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "struct*", $tVariant) Return 0 Case 9 If BitAND($wFlags, 4) = 4 Or BitAND($wFlags, 8) = 8 Then Return -2147352567 $tDISPPARAMS = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tDISPPARAMS.cArgs < 0 Or $tDISPPARAMS.cArgs > 0 Then Return -2147352562 __Object__Class_GamePanel_AddRef($pSelf) Local $parameters[$tDISPPARAMS.cArgs + 2] = ["CallArgArray", ObjCreateInterface(DllStructGetPtr($tObject, "Object"), "{00020400-0000-0000-C000-000000000046}", Default, True)] Local $j = 2 For $i=$tDISPPARAMS.cArgs-1 To 0 Step -1 $parameters[$j] = ___Class__GamePanel_FromVariant($tDISPPARAMS.rgvargs+$iVariant*$i) Next Local $vValue = Call(__Class_GamePanel_drawStage, $parameters) If @error <> 0 Then Return -2147352567 $tVariant = ___Class__GamePanel_ToVariant($vValue) DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "struct*", $tVariant) Return 0 Case 10 If BitAND($wFlags, 4) = 4 Or BitAND($wFlags, 8) = 8 Then Return -2147352567 $tDISPPARAMS = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tDISPPARAMS.cArgs < 0 Or $tDISPPARAMS.cArgs > 0 Then Return -2147352562 __Object__Class_GamePanel_AddRef($pSelf) Local $parameters[$tDISPPARAMS.cArgs + 2] = ["CallArgArray", ObjCreateInterface(DllStructGetPtr($tObject, "Object"), "{00020400-0000-0000-C000-000000000046}", Default, True)] Local $j = 2 For $i=$tDISPPARAMS.cArgs-1 To 0 Step -1 $parameters[$j] = ___Class__GamePanel_FromVariant($tDISPPARAMS.rgvargs+$iVariant*$i) Next Local $vValue = Call(__Class_GamePanel_cleanUpResources, $parameters) If @error <> 0 Then Return -2147352567 $tVariant = ___Class__GamePanel_ToVariant($vValue) DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "struct*", $tVariant) Return 0 Case 11 If BitAND($wFlags, 4) = 4 Or BitAND($wFlags, 8) = 8 Then Return -2147352567 $tDISPPARAMS = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tDISPPARAMS.cArgs < 0 Or $tDISPPARAMS.cArgs > 0 Then Return -2147352562 __Object__Class_GamePanel_AddRef($pSelf) Local $parameters[$tDISPPARAMS.cArgs + 2] = ["CallArgArray", ObjCreateInterface(DllStructGetPtr($tObject, "Object"), "{00020400-0000-0000-C000-000000000046}", Default, True)] Local $j = 2 For $i=$tDISPPARAMS.cArgs-1 To 0 Step -1 $parameters[$j] = ___Class__GamePanel_FromVariant($tDISPPARAMS.rgvargs+$iVariant*$i) Next Local $vValue = Call(__Class_GamePanel_runGameLoop, $parameters) If @error <> 0 Then Return -2147352567 $tVariant = ___Class__GamePanel_ToVariant($vValue) DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "struct*", $tVariant) Return 0 EndSwitch EndFunc Func __Object__Class_GamePanel_InvokeAccessor($pSelf, $dispIdMember, $riid, $lcid, $wFlags, $pDispParams, $pVarResult, $pExcepInfo, $puArgErr) Local $_tObject = DllStructCreate("int RefCount;int Size;ptr Object;ptr Methods[7];int PropertyIndex;ptr OriginalObject;", $pSelf - 8) If $dispIdMember = $_tObject.PropertyIndex Then $tObject = DllStructCreate('int RefCount;int Size;ptr Object;ptr Methods[7];ptr Properties[6];', $_tObject.OriginalObject - 8) If BitAND($wFlags, 2)=2 Then DllCall("OleAut32.dll","LONG","VariantClear","ptr",$pVarResult) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",$pVarResult, "ptr", DllStructGetData($tObject, "Properties", $dispIdMember)) Return 0 EndIf Local $tParams = DllStructCreate("ptr rgvargs;ptr rgdispidNamedArgs;dword cArgs;dword cNamedArgs;", $pDispParams) If $tParams.cArgs <> 1 Then Return -2147352562 DllCall("OleAut32.dll","LONG","VariantClear","ptr",DllStructGetData($tObject, "Properties", $dispIdMember)) DllCall("OleAut32.dll","LONG","VariantCopy","ptr",DllStructGetData($tObject, "Properties", $dispIdMember), "ptr", $tParams.rgvargs) Return 0 EndIf Return __Object__Class_GamePanel_Invoke($_tObject.OriginalObject, $dispIdMember, $riid, $lcid, $wFlags, $pDispParams, $pVarResult, $pExcepInfo, $puArgErr) EndFunc Func __Class_GamePanel___construct($this) Local $hGUI = GUICreate("Ping Pong", 400, 300, -1, -1, $WS_SIZEBOX + $WS_SYSMENU) GUISetBkColor(0x000000) GUISetState() Local $aClient = WinGetClientSize($hGUI) If @error Then Return SetError(1, 0, 0) Local $iWidth = $aClient[0] Local $iHeight = $aClient[1] Local $aGDIMap[5] $aGDIMap[0] = _GDIPlus_GraphicsCreateFromHWND($hGUI) $aGDIMap[1] = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $aGDIMap[0]) $aGDIMap[2] = _GDIPlus_ImageGetGraphicsContext($aGDIMap[1]) $aGDIMap[3] = _GDIPlus_BrushCreateSolid($COLOR_RED) $aGDIMap[4] = _GDIPlus_HatchBrushCreate(4, $COLOR_GREEN) Local $Ball = Ball(40, 40) Local $paddleX = Paddle(150, 100) $this.iWidth = $iWidth $this.iHeight = $iHeight $this.ball = $Ball $this.paddle = $paddleX $this.map = $aGDIMap EndFunc Func __Class_GamePanel___destructor($this) $this.cleanUpResources() EndFunc Func __Class_GamePanel_move($this) Local $x = $this.ball.X Local $y = $this.ball.Y Local $dx = $this.ball.dx Local $dy = $this.ball.dy Local $Width = $this.iWidth Local $Height = $this.iHeight Local $BallSize = $this.ball.size If $y + $dy >= ($Height - 40) And $x + $BallSize >= $this.paddle.X And $x <= $this.paddle.X + $this.paddle.size Then $dy *= -1 EndIf If $y + $dy <= 0 Then $dy = Abs($dy) EndIf If $y + $dy >= $Height - $BallSize Then MsgBox(0, "Game Over", "You missed the ball! Game Over!") Exit EndIf If $x + $dx <= 0 Then $dx = Abs($dx) EndIf If $x + $dx >= $Width - $BallSize Then $dx = -Abs($dx) EndIf $x += $dx $y += $dy $this.ball.dx = $dx $this.ball.dy = $dy $this.ball.X = $x $this.ball.Y = $y $this.drawStage() EndFunc Func __Class_GamePanel_drawStage($this) Local $hGraphics = $this.map[0] Local $hBitmap = $this.map[1] Local $hGraphicsCtxt = $this.map[2] Local $iX = $this.ball.X Local $iY = $this.ball.Y Local $iRadius = $this.ball.size Local $padX = $this.paddle.X Local $padH = $this.iHeight - 40 _GDIPlus_GraphicsClear($hGraphicsCtxt, 0xFF000000) _GDIPlus_GraphicsFillEllipse($hGraphicsCtxt, $iX - $iRadius, $iY - $iRadius, $iRadius * 2, $iRadius * 2, $this.map[3]) _GDIPlus_GraphicsFillRect($hGraphicsCtxt, $padX, $padH, $this.paddle.size, 10, $this.map[4]) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $this.iWidth, $this.iHeight) EndFunc Func __Class_GamePanel_cleanUpResources($this) ConsoleWrite("clean up ressources...." & @CRLF) Local $map = $this.map _GDIPlus_GraphicsDispose($map[0]) _GDIPlus_BitmapDispose($map[1]) _GDIPlus_GraphicsDispose($map[2]) _GDIPlus_BrushDispose($map[3]) $this.map = 0 _GDIPlus_Shutdown() EndFunc Func __Class_GamePanel_runGameLoop($this) Local $speedUpTime = 5000 Local $lastMoveTime = TimerInit() Local $maxX = $this.iWidth While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop If _IsPressed(25) Then $this.paddle.moveLeft() If _IsPressed(27) Then $this.paddle.moveRight($maxX) If _IsPressed(53) Then While 1 If _IsPressed(25) Or _IsPressed(27) Then ExitLoop Sleep(100) WEnd EndIf If TimerDiff($lastMoveTime) >= $speedUpTime Then $this.speedLevel -= 5 If $this.speedLevel < 0 Then $this.speedLevel = 0 $lastMoveTime = TimerInit() EndIf $this.move() Sleep($this.speedLevel) WEnd EndFunc Global $game = GamePanel() $game.runGameLoop() ConsoleWrite("------> the end <-------" & @CRLF) $game = 0 Generated from this: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <Misc.au3> Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") _GDIPlus_Startup() Const $COLOR_RED = 0xFFFF0000 Const $COLOR_GREEN = 0xFF00FF00 Class Ball $dx = 10 $dy = -10 $size = 5 $x = 0 $y = 0 Func __construct($x = 0, $y = 0, $size = 5) $this.x = $x $this.y = $y $this.size = $size EndFunc Func move() ; _move EndFunc EndClass Class Paddle $X = 0 $size = 5 $dx = 20 Func __construct($x = 0, $size = 5) $this.X = $x $this.size = $size EndFunc Func moveLeft() $this.X -= $this.dx If $this.X < 0 Then $this.X = 0 EndFunc Func moveRight($maxX) Local $paddleWidth = $this.size If $this.X + $this.dx + $paddleWidth <= $maxX Then $this.X += $this.dx Else $this.X = $maxX - $paddleWidth EndIf EndFunc EndClass Class GamePanel $iWidth $iHeight $ball $paddle $map $speedLevel = 100 Func __construct() Local $hGUI = GUICreate("Ping Pong", 400, 300, -1, -1, $WS_SIZEBOX + $WS_SYSMENU) GUISetBkColor(0x000000) GUISetState() Local $aClient = WinGetClientSize($hGUI) If @error Then Return SetError(1, 0, 0) Local $iWidth = $aClient[0] Local $iHeight = $aClient[1] Local $aGDIMap[5] $aGDIMap[0] = _GDIPlus_GraphicsCreateFromHWND($hGUI) $aGDIMap[1] = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $aGDIMap[0]) $aGDIMap[2] = _GDIPlus_ImageGetGraphicsContext($aGDIMap[1]) $aGDIMap[3] = _GDIPlus_BrushCreateSolid($COLOR_RED) $aGDIMap[4] = _GDIPlus_HatchBrushCreate(4, $COLOR_GREEN) Local $Ball = Ball(40, 40) Local $paddleX = Paddle(150, 100) $this.iWidth = $iWidth $this.iHeight = $iHeight $this.ball = $Ball $this.paddle = $paddleX $this.map = $aGDIMap EndFunc Func __destructor() $this.cleanUpResources() EndFunc Func move() Local $x = $this.ball.X Local $y = $this.ball.Y Local $dx = $this.ball.dx Local $dy = $this.ball.dy Local $Width = $this.iWidth Local $Height = $this.iHeight Local $BallSize = $this.ball.size If $y + $dy >= ($Height - 40) And $x + $BallSize >= $this.paddle.X And $x <= $this.paddle.X + $this.paddle.size Then $dy *= -1 EndIf If $y + $dy <= 0 Then $dy = Abs($dy) EndIf If $y + $dy >= $Height - $BallSize Then MsgBox(0, "Game Over", "You missed the ball! Game Over!") Exit EndIf If $x + $dx <= 0 Then $dx = Abs($dx) EndIf If $x + $dx >= $Width - $BallSize Then $dx = -Abs($dx) EndIf $x += $dx $y += $dy $this.ball.dx = $dx $this.ball.dy = $dy $this.ball.X = $x $this.ball.Y = $y $this.drawStage() EndFunc Func drawStage() Local $hGraphics = $this.map[0] Local $hBitmap = $this.map[1] Local $hGraphicsCtxt = $this.map[2] Local $iX = $this.ball.X Local $iY = $this.ball.Y Local $iRadius = $this.ball.size Local $padX = $this.paddle.X Local $padH = $this.iHeight - 40 _GDIPlus_GraphicsClear($hGraphicsCtxt, 0xFF000000) _GDIPlus_GraphicsFillEllipse($hGraphicsCtxt, $iX - $iRadius, $iY - $iRadius, $iRadius * 2, $iRadius * 2, $this.map[3]) _GDIPlus_GraphicsFillRect($hGraphicsCtxt, $padX, $padH, $this.paddle.size, 10, $this.map[4]) _GDIPlus_GraphicsDrawImageRect($hGraphics, $hBitmap, 0, 0, $this.iWidth, $this.iHeight) EndFunc Func cleanUpResources() ConsoleWrite("clean up ressources...." & @CRLF) Local $map = $this.map _GDIPlus_GraphicsDispose($map[0]) _GDIPlus_BitmapDispose($map[1]) _GDIPlus_GraphicsDispose($map[2]) _GDIPlus_BrushDispose($map[3]) $this.map = 0 _GDIPlus_Shutdown() EndFunc Func runGameLoop() Local $speedUpTime = 5000 Local $lastMoveTime = TimerInit() Local $maxX = $this.iWidth While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop If _IsPressed(25) Then $this.paddle.moveLeft() If _IsPressed(27) Then $this.paddle.moveRight($maxX) If _IsPressed(53) Then While 1 If _IsPressed(25) Or _IsPressed(27) Then ExitLoop Sleep(100) WEnd EndIf If TimerDiff($lastMoveTime) >= $speedUpTime Then $this.speedLevel -= 5 If $this.speedLevel < 0 Then $this.speedLevel = 0 $lastMoveTime = TimerInit() EndIf $this.move() Sleep($this.speedLevel) WEnd EndFunc EndClass Global $game = GamePanel() $game.runGameLoop() ConsoleWrite("------> the end <-------" & @CRLF) $game = 0 I'm still re-writing my au3class project, so memory cleanup and the destructor currently is not working Update: destructor is now working Edited May 20 by genius257 Updated generated code after new au3class changes Gianni 1 My highlighted topics: AutoIt Package Manager, AutoItObject Pure AutoIt, AutoIt extension for Visual Studio Code Github: AutoIt HTTP Server, AutoIt HTML Parser Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now