Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/19/2024 in Posts

  1. Are we going to pull the first .DNG file sorted by name, date, or file size?
    2 points
  2. Gianni

    IsArrayEmpty

    In this topic from some time ago (https://www.autoitscript.com/forum/topic/180468-traversing-array/), we were basically discussing how to traverse all the elements of a generic array whose dimensions are unknown. Well in the last post of that thread I posted a way to achieve that. Using that function can save "a few" bytes and shorten the function considerably. You can pass multidimensional arrays and even arrays that contain nested arrays without any problems. I coded the logic whether to consider an element empty or not empty in the function itself on line 30 of the listing rather than passing it via parameter so as to be able to better customize the criterion. Func IsArrayEmpty(ByRef $aMyArray) If Not IsArray($aMyArray) Then Return SetError(1, 0, -1) Local $iDimensions = UBound($aMyArray, 0) Local $sArraySubscript = "$aMyArray" For $i = 0 To $iDimensions - 1 $sArraySubscript &= '[$aLoops[' & $i & '][2]]' Next Local $aLoops[$iDimensions][3] For $i = 0 To $iDimensions - 1 $aLoops[$i][0] = 0 $aLoops[$i][1] = UBound($aMyArray, $i + 1) - 1 $aLoops[$i][2] = $aLoops[$i][0] Next Local $x, $vContent Do $vContent = Execute($sArraySubscript) If IsArray($vContent) Then $IsEmpty = IsArrayEmpty($vContent) ; <-- recursive call for nested arrays Else ; check out your "voidness" logic here ; ------------------------------------ $IsEmpty = ($vContent = '') Or ($vContent = False) Or ($vContent = Null) ; ...... up to you decide EndIf If Not $IsEmpty Then Return False ; Is not Empty $x = UBound($aLoops) - 1 $aLoops[$x][2] += 1 While ($aLoops[$x][2] > $aLoops[$x][1]) $aLoops[$x][2] = $aLoops[$x][0] $x -= 1 If $x < 0 Then ExitLoop $aLoops[$x][2] += 1 WEnd Until $x < 0 Return True ; Is Empty EndFunc ;==>IsArrayEmpty
    1 point
  3. example to take the first file with a .txt extension ; https://www.autoitscript.com/forum/topic/211902-code-to-obtain-only-the-first-file-of-the-a-lot-of-folders/ #include <File.au3> _FindAllDir(@MyDocumentsDir) ;---------------------------------------------------------------------------------------- Func _FindAllDir($dir) If StringRight($dir, 1) <> "\" Then $dir &= "\" $ArraySrtfiles = _FileListToArrayRec($dir, "*", $FLTAR_FOLDERS, $FLTAR_RECUR) If Not IsArray($ArraySrtfiles) Then ConsoleWrite($dir & " = Invalid input path" & @CRLF) Return Else Local $sResult For $x = 1 To $ArraySrtfiles[0] ;ConsoleWrite($dir & $ArraySrtfiles[$x] & @CRLF) $sResult = _FindFirstFile($dir & $ArraySrtfiles[$x], ".txt") If $sResult Then ConsoleWrite($dir & $ArraySrtfiles[$x] & $sResult & @CRLF) Next EndIf EndFunc ;==>_FindAllDir ;---------------------------------------------------------------------------------------- Func _FindFirstFile($dir, $Extension) ; Assign a Local variable the search handle of all files in the current directory. Local $hSearch = FileFindFirstFile($dir & "*" & $Extension) ; Check if the search was successful, if not display a message and return False. If $hSearch = -1 Then ;ConsoleWrite("! Error: No files/directories matched the search pattern." & @CRLF) Return False EndIf ; Assign a Local variable the empty string which will contain the files names found. Local $sFileName = "" While 1 $sFileName = FileFindNextFile($hSearch) ; If there is no more file matching the search. If @error Then ExitLoop ; By first matching ExitLoop If $sFileName Then ExitLoop WEnd ; Close the search handle. FileClose($hSearch) Return $sFileName EndFunc ;==>_FindFirstFile ;----------------------------------------------------------------------------------------
    1 point
  4. this COMPLETELY solves the problem, but I solved it differently - first we launch 2 windows, each with its own port (for example 2828 and 2829), then we connect to each window (if necessary) on the assigned port when the window was launched I hope it’s clear it wasn’t easy for me to understand all this..)) This is just a sketch, an example of work so to speak: #include <MsgBoxConstants.au3> #include "wd_capabilities.au3" #include "wd_helper.au3" ;_WD_Option('DriverClose', False) ;_WD_Option('DriverDetect', False) ;====================================================== ;connecting to an EXISTING Firefox window - you only need to specify the port ;(it must be different - 2828, 2829, 2830, each Firefox-window has its own port) If 1 = 1 Then ;the most important thing here is the PORT _WD_Option('Driver', 'geckodriver.exe') _WD_Option('DriverParams', '--log trace --connect-existing --marionette-port 2828') _WD_Option('Port', 4444) _WD_Startup() $WD_SESSION = _WD_CreateSession() ;testing _WD_Navigate($WD_SESSION, "https://www.google.com") MsgBox(64,'','Ok?') ;_WD_DeleteSession($WD_SESSION) _WD_Shutdown() Else ;====================================================== ;launch a Firefox window with a specific port and exit _WD_Option('Driver', 'geckodriver.exe') _WD_Option('DriverParams', '--log trace --marionette-port 2828') _WD_Option('Port', 4444) _WD_Startup() _WD_CapabilitiesStartup() _WD_CapabilitiesAdd('alwaysMatch') _WD_CapabilitiesAdd('acceptInsecureCerts', True) _WD_CapabilitiesAdd('firstMatch', 'firefox') _WD_CapabilitiesAdd('pageLoadStrategy', 'none') $WD_SESSION = _WD_CreateSession(_WD_CapabilitiesGet()) _WD_Navigate($WD_SESSION, "https://www.autoitscript.com/forum") ;_WD_DeleteSession($WD_SESSION) _WD_Shutdown() EndIf
    1 point
  5. Have you tried using _WD_Window with "new" for the subcommand?
    1 point
  6. 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. #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: #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
    1 point
  7. Oookkk, target is moving...Hold on : For $i = 0 To _GUICtrlListView_GetItemCount($list) - 1 If _GUICtrlListView_GetItemChecked($list, $i) Then ConsoleWrite(_GUICtrlListView_GetItemText($list, $i) & @CRLF) Else ConsoleWrite("False" & @CRLF) EndIf Next
    1 point
  8. Gianni

    BrowserControl Companion

    Making the integration between AutoIt and the BrowserControl easier may facilitate the development of interesting programs. Just think of all those (fantastic) libraries and frameworks available for javascript that could be integrated and exploited in an AutoIt program. For example, to graphically present the results of an AutoIt processing in the GUI, ... and many other possibilities. Providing the basic functions to implement this synergistic interaction is the purpose of this post (if for no other reason, just even to collect some tests done over time here and there, so as not to leave them scattered and easily find them in just one place) In this UDF there are only a few functions (or better if called wrappers), but I hope to add more as I go and, even better, to receive suggestions and advice on new features and techniques to improve and expand it. _WebBrowser_GUICtrlCreate Create an Internet Explorer 'Browser Control' _WebBrowser_SetHTML Set a new HTML listing in the BrowserControl _WebBrowser_CSS_Inject Creates into the html document a CSS node element with embedded the passed CSS _WebBrowser_JS_Inject Creates into the html document a javascript node element with embedded the passed javascript _WebBrowser_JS_Eval Evaluates a passed string as JavaScript code and executes it _WebBrowser_JS_setTimeout Calls a javascript function or executes a javascript code snippet [option after a specified delay] _WebBrowser_JS_ElementGetRef Retrieves a reference to an element suitable to be used from AutoIt _WebBrowser_ExecuteDotNotation Get a reference to an object's child member or the value of a property, by means of a dotted path _WebBrowser_BasicHTML Returns a basic html page listing (a little enhanced than about:blank) The three examples provided in the attached ziped file are a bit 'improvised' and do not take advantage of all the possibilities offered by the underlying javascript libraries used. They are just three "hello world" scripts to test the ABC of the interaction with the "BrowserControl". (ToDo: Interaction with javascript custom events) Bug reports, creative criticisms and suggestions (particularly regarding the interaction with javascript custom events) are welcome I hope you can have fun with the Browser Control BrowserControl.zip
    1 point
×
×
  • Create New...