Leaderboard
Popular Content
Showing content with the highest reputation on 10/17/2013 in all areas
-
In the new versions of Autoit, the code does not work... The code has been updated... and now it works... Thanks. FlashMemoryStream.zip download intro.swf https://www.w3schools.com/html/intro.swf #AutoIt3Wrapper_Res_File_Add=intro.swf,FILES,SWF,0 #include <WinAPI.au3> #include <Memory.au3> #include <GUIConstantsEx.au3> ;https://www.w3schools.com/html/intro.swf Global $cNewMemStream[1],$ClassFlashMemoryStream[1],$Atl = DllOpen("Atl.dll"),$Ole32 = DllOpen("Ole32.dll") Global $RegReadMethod = DllCallbackRegister( "Read","LONG","PTR;PTR;ULONG;PTR" ) , $WinInit = False $Gui = GUICreate("My GUI",450,400,100,50) $hMemory = ResToGlobalAlloc("SWF","FILES") if Not($hMemory) Then $hMemory = FileToGlobalAlloc("intro.swf") if @error Then Exit $ReturnArray = GUICtrlCreateFlashFromMem($hMemory,10,10,430,300) $CtrlId = $ReturnArray[0] $FlashCOMobject = $ReturnArray[1] $Button_1 = GUICtrlCreateButton("Button",175,330,100,40) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 MsgBox(0,"Msg","OK") EndSelect WEnd Exit Func GUICtrlCreateFlashFromMem($hMemory,$L,$T,$W,$H) $StreamData = _MemGlobalLock($hMemory) if Not($StreamData) Then Return SetError(1,0,0) $StreamSize = _MemGlobalSize($hMemory) if Not($StreamSize) Then Return SetError(2,0,0) if Not($WinInit) Then $Return = DllCall($Ole32,"long","CoInitialize","ptr",0) if @error Or ($Return[0] <> 0 And $Return[0] <> 1) Then Return SetError(3,0,0) $Return = DllCall($Atl,"BOOL","AtlAxWinInit") if @error Or $Return[0] = 0 Then Return SetError(4,0,0) $WinInit = True EndIf $CtrlId = GUICtrlCreateLabel("",$L,$T,$W,$H) if @error Then Return SetError(5,0,0) $CtrlHandle = GUICtrlGetHandle($CtrlId) $Return = DllCall($Atl,"long","AtlAxCreateControl","wstr","ShockwaveFlash.ShockwaveFlash" _ ,"ptr",$CtrlHandle,"ptr",0,"ptr*",0) if @error Or $Return[0] <> 0 Then GUICtrlDelete($CtrlId) Return SetError(6,0,0) EndIf $IUnknown = $Return[4] ;Release Method = 3 InterfaceCall($IUnknown,"long",3) $Return = DllCall($Atl,"long","AtlAxGetControl","ptr",$CtrlHandle,"ptr*",0) if @error Or $Return[0] <> 0 Then GUICtrlDelete($CtrlId) Return SetError(7,0,0) EndIf $ShockwaveFlash = $Return[2] $IID_IDispatch = IIDFromString("{00020400-0000-0000-C000-000000000046}") ;QueryInterface Method = 1 $Return = InterfaceCall($ShockwaveFlash,"long",1,"struct*",$IID_IDispatch,"idispatch*",0) if @error Or $Return[0] <> 0 Then GUICtrlDelete($CtrlId) Return SetError(8,0,0) EndIf $DisphShockwaveFlash = $Return[2] $IID_IPersistStreamInit = IIDFromString("{7FD52380-4E07-101B-AE2D-08002B2EC713}") ;QueryInterface Method = 1 $Return = InterfaceCall($ShockwaveFlash,"long",1,"struct*",$IID_IPersistStreamInit,"ptr*",0) if @error Or $Return[0] <> 0 Then GUICtrlDelete($CtrlId) Return SetError(9,0,0) EndIf $IPersistStreamInit = $Return[2] $RtArray = ClassFlashMemoryStream($StreamData,$StreamSize) if @error Then ;Release Method = 3 InterfaceCall($IPersistStreamInit,"long",3) Return SetError(10,0,0) EndIf $CFlashMemoryStream = $RtArray[0] $IStream = $RtArray[1] ; InitNew Method = 9 $Return = InterfaceCall($IPersistStreamInit,"long",9) if @error Or $Return[0] <> 0 Then ;Release Method = 3 InterfaceCall($IPersistStreamInit,"long",3) ;Release Method = 3 InterfaceCall($IStream,"long",3) ReDim $ClassFlashMemoryStream[UBound($ClassFlashMemoryStream) - 1] Return SetError(11,0,0) EndIf ;load Method = 3 $Return = InterfaceCall($IPersistStreamInit,"long",6,"ptr",DllStructGetPtr($CFlashMemoryStream)) if @error Or $Return[0] <> 0 Then ;Release Method = 3 InterfaceCall($IPersistStreamInit,"long",3) ;Release Method = 3 InterfaceCall($IStream,"long",3) ReDim $ClassFlashMemoryStream[UBound($ClassFlashMemoryStream) - 1] Return SetError(12,0,0) EndIf Local $ReturnArray[6] $ReturnArray[0] = $CtrlId ; Ctrl Id Of Label (ShockwaveFlash Window) $ReturnArray[1] = $DisphShockwaveFlash ;ShockwaveFlash COM object $ReturnArray[2] = $ShockwaveFlash ;ShockwaveFlash Interface $ReturnArray[3] = $CFlashMemoryStream ;Class FlashMemoryStream Struct $ReturnArray[4] = $IPersistStreamInit ;IPersistStreamInit Interface $ReturnArray[5] = $IStream ;$IStream Interface Return $ReturnArray EndFunc Func FileToGlobalAlloc($FileName) Local $nBytes $FileSize = FileGetSize($FileName) if @error Then Return SetError(1,0,0) $hMemory = _MemGlobalAlloc($FileSize,$GHND) if Not($hMemory) Then Return SetError(2,0,0) $GlobalLock = _MemGlobalLock($hMemory) if Not($GlobalLock) Then _MemGlobalFree($hMemory) Return SetError(3,0,0) EndIf $hFile = _WinAPI_CreateFile($FileName,2,2) if Not($hFile) Then _MemGlobalFree($hMemory) Return SetError(4,0,0) EndIf $BOOL =_WinAPI_ReadFile($hFile,$GlobalLock,$FileSize,$nBytes) if Not($BOOL) Then _MemGlobalFree($hMemory) _WinAPI_CloseHandle($hFile) Return SetError(5,0,0) EndIf _WinAPI_CloseHandle($hFile) Return $hMemory EndFunc Func ResToGlobalAlloc($ResName,$ResType,$ResLanguage = -1) $ByteStruct = ResGet($ResName,$ResType,$ResLanguage) if @error Then Return SetError(1,0,0) $ResSize = @extended $hMemory = _MemGlobalAlloc($ResSize,$GHND) if Not($hMemory) Then Return SetError(2,0,0) $GlobalLock = _MemGlobalLock($hMemory) if Not($GlobalLock) Then _MemGlobalFree($hMemory) Return SetError(3,0,0) EndIf _MemMoveMemory(DllStructGetPtr($ByteStruct),$GlobalLock,$ResSize) Return $hMemory EndFunc Func ResGet($ResName,$ResType,$ResLanguage = -1,$HModule = 0) Local $DataType1 = "LONG",$DataType2 = "LONG" Local $LPVOID,$HRSRC,$ResSize,$HGLOBAL if IsString($ResName) Then $ResName = StringUpper($ResName) $DataType1 = "WSTR" EndIf If IsString($ResType) Then $ResType = StringUpper($ResType) $DataType2 = "WSTR" EndIf if ($HModule = 0) Then $HModule = _WinAPI_GetModuleHandle(0) if ($ResLanguage <> -1) Then $HRSRC = DllCall("Kernel32.dll","ptr","FindResourceExW","ptr",$HModule,$DataType2, _ $ResType,$DataType1,$ResName,"WORD",$ResLanguage) if @error Or $HRSRC[0] = 0 Then Return SetError(1,0,0) Else $HRSRC = DllCall("Kernel32.dll","ptr","FindResourceW","ptr",$HModule,$DataType1,$ResName,$DataType2, _ $ResType) if @error Or $HRSRC[0] = 0 Then Return SetError(1,0,0) EndIf $HRSRC = $HRSRC[0] $ResSize = DllCall("Kernel32.dll","DWORD","SizeofResource","ptr",$HModule,"ptr",$HRSRC) if (@error Or $ResSize[0] = 0) Then Return SetError(2,0,0) $ResSize = $ResSize[0] $HGLOBAL = DllCall("Kernel32.dll","ptr","LoadResource","ptr",$HModule,"ptr",$HRSRC) if @error Or $HGLOBAL[0] = 0 Then Return SetError(3,0,0) $HGLOBAL = $HGLOBAL[0] $LPVOID = DllCall("Kernel32.dll","ptr","LockResource","ptr",$HGLOBAL) if @error Or $LPVOID[0] = 0 Then $BOOL = DllCall("Kernel32.dll","BOOL","FreeResource","ptr",$HGLOBAL) Return SetError(4,0,0) EndIf $LPVOID = $LPVOID[0] $ByteStruct = DllStructCreate("BYTE[" & $ResSize & "]") _MemMoveMemory($LPVOID,DllStructGetPtr($ByteStruct),$ResSize) $BOOL = DllCall("Kernel32.dll","BOOL","FreeResource","ptr",$HGLOBAL) Return SetError(0,$ResSize,$ByteStruct) EndFunc Func ClassFlashMemoryStream($StreamData,$StreamSize) Global $tagClassFlashMemoryStream = _ "ULONG_PTR QueryInterface;ULONG_PTR AddRef;ULONG_PTR Release;ULONG_PTR Read;ULONG_PTR Write;" & _ "ULONG_PTR Seek;ULONG_PTR SetSize;ULONG_PTR CopyTo;ULONG_PTR Commit;ULONG_PTR Revert;ULONG_PTR" & _ " LockRegion;ULONG_PTR UnlockRegion;ULONG_PTR Stat;ULONG_PTR Clone;PTR data;ULONG size;ULONG pos" $NewMemStream = DllStructCreate($tagClassFlashMemoryStream) $cNewMemStream[UBound($cNewMemStream) - 1] = $NewMemStream ReDim $cNewMemStream[UBound($cNewMemStream) + 1] Local $grfMode = BitOR(0x00000002,0x00001000,0x00000010) Local $HRESULT = DllCall("Ole32.dll","long","StgCreateDocfile","int",0,"DWORD",$grfMode _ ,"DWORD",0,"ptr*",0) if @error Or $HRESULT[0] <> 0 Then Return SetError(1,0,0) Local $pIStorage = $HRESULT[4] $grfMode = BitOR(0x00000002,0x00000010) $HRESULT = InterfaceCall($pIStorage,"long",4,"wstr","FlashStream","DWORD",$grfMode, _ "DWORD",0,"DWORD",0,"ptr*",0) ;CreateStream METHOD if @error Or $HRESULT[0] <> 0 Then ;Release Method = 3 InterfaceCall($pIStorage,"long",3) Return SetError(2,0,0) EndIf ;Release Method = 3 InterfaceCall($pIStorage,"long",3) Local $IStream = $HRESULT[5] $QueryInterface = GetMethodAddress($IStream,1) DllStructSetData($NewMemStream,1,$QueryInterface) $AddRef = GetMethodAddress($IStream,2) DllStructSetData($NewMemStream,2,$AddRef) $Release = GetMethodAddress($IStream,3) DllStructSetData($NewMemStream,3,$Release) ;----------------------------------------; $Read = DllCallbackGetPtr($RegReadMethod) DllStructSetData($NewMemStream,4,$Read) ;----------------------------------------; $Write = GetMethodAddress($IStream,5) DllStructSetData($NewMemStream,5,$Write) $Seek = GetMethodAddress($IStream,6) DllStructSetData($NewMemStream,6,$Seek) $SetSize = GetMethodAddress($IStream,7) DllStructSetData($NewMemStream,7,$SetSize) $CopyTo = GetMethodAddress($IStream,8) DllStructSetData($NewMemStream,8,$CopyTo) $Commit = GetMethodAddress($IStream,9) DllStructSetData($NewMemStream,9,$Commit) $Revert = GetMethodAddress($IStream,10) DllStructSetData($NewMemStream,10,$Revert) $LockRegion = GetMethodAddress($IStream,11) DllStructSetData($NewMemStream,11,$LockRegion) $UnlockRegion = GetMethodAddress($IStream,12) DllStructSetData($NewMemStream,12,$UnlockRegion) $Stat = GetMethodAddress($IStream,13) DllStructSetData($NewMemStream,13,$Stat) $Clone = GetMethodAddress($IStream,14) DllStructSetData($NewMemStream,14,$Clone) DllStructSetData($NewMemStream,15,$StreamData) DllStructSetData($NewMemStream,16,$StreamSize) DllStructSetData($NewMemStream,17,0) ; $StreamiPos = 0 $NewMemStreamPtr = DllStructGetPtr($NewMemStream) $ClassFlashMemoryStream[UBound($ClassFlashMemoryStream) - 1] = DllStructCreate("ULONG_PTR") DllStructSetData($ClassFlashMemoryStream[UBound($ClassFlashMemoryStream) - 1],1,$NewMemStreamPtr) ReDim $ClassFlashMemoryStream[UBound($ClassFlashMemoryStream) + 1] Local $RtArray[2] $RtArray[0] = $ClassFlashMemoryStream[UBound($ClassFlashMemoryStream) - 2] ;Class FlashMemoryStream Struct $RtArray[1] = $IStream ;$IStream Interface Return $RtArray EndFunc Func Read($Inface,$pv,$cb,$pcbRead) Global $tagClassFlashMemoryStream = _ "ULONG_PTR QueryInterface;ULONG_PTR AddRef;ULONG_PTR Release;ULONG_PTR Read;ULONG_PTR Write;" & _ "ULONG_PTR Seek;ULONG_PTR SetSize;ULONG_PTR CopyTo;ULONG_PTR Commit;ULONG_PTR Revert;ULONG_PTR" & _ " LockRegion;ULONG_PTR UnlockRegion;ULONG_PTR Stat;ULONG_PTR Clone;PTR data;ULONG size;ULONG pos" $OutCastStruct1 = DllStructCreate("ULONG_PTR",$Inface) $OutCast1 = DllStructGetData($OutCastStruct1,1) $CFlashMemoryStream = DllStructCreate($tagClassFlashMemoryStream,$OutCast1) $StreamData = DllStructGetData($CFlashMemoryStream,"data") $StreamSize = DllStructGetData($CFlashMemoryStream,"size") $StreamiPos = DllStructGetData($CFlashMemoryStream,"pos") if($StreamiPos == 0 And $cb == 4) Then $String = DllStructCreate("char[4]") DllStructSetData($String,1,"fUfU") _MemMoveMemory(DllStructGetPtr($String),$pv,4) DllStructSetData($CFlashMemoryStream,"pos",$StreamiPos + 4) return 0 ElseIf ($StreamiPos == 4 And $cb == 4) Then $IntSize = DllStructCreate("int") DllStructSetData($IntSize,1,$StreamSize) _MemMoveMemory(DllStructGetPtr($IntSize),$pv,4) DllStructSetData($CFlashMemoryStream,"size",$StreamSize + 8) DllStructSetData($CFlashMemoryStream,"pos",$StreamiPos + 4) return 0 Else if(($StreamiPos + $cb) > $StreamSize) Then $cb = ($StreamSize - $StreamiPos) if($cb == 0) Then return 1 _MemMoveMemory($StreamData + ($StreamiPos - 8),$pv,$cb) $IntCb = DllStructCreate("int") DllStructSetData($IntCb,1,$cb) if($pcbRead) Then _MemMoveMemory(DllStructGetPtr($IntCb),$pcbRead,4) DllStructSetData($CFlashMemoryStream,"pos",$StreamiPos + $cb) return 0 EndIf EndFunc Func InterfaceCall($Inface,$ReturnType,$MethodNum,$Type1 = 0,$Param1 = 0,$Type2 = 0,$Param2 = 0 _ ,$Type3 = 0,$Param3 = 0, $Type4 = 0,$Param4 = 0 ,$Type5 = 0 ,$Param5 = 0,$Type6 = 0,$Param6 = 0 _ ,$Type7 = 0,$Param7 = 0, $Type8 = 0,$Param8 = 0,$Type9 = 0,$Param9 = 0,$Type10 = 0,$Param10 = 0 _ ,$Type11= 0,$Param11= 0,$Type12= 0,$Param12= 0,$Type13= 0,$Param13 = 0,$Type14 = 0,$Param14 = 0 _ ,$Type15= 0,$Param15= 0,$Type16= 0,$Param16= 0,$Type17= 0,$Param17 = 0,$Type18 = 0,$Param18 = 0 _ ,$Type19= 0,$Param19= 0,$Type20= 0,$Param20= 0,$Type21= 0,$Param21 = 0,$Type22 = 0,$Param22 = 0 _ ,$Type23= 0,$Param23= 0,$Type24= 0,$Param24= 0,$Type25= 0,$Param25 = 0,$Type26 = 0,$Param26 = 0 _ ,$Type27= 0,$Param27= 0,$Type28= 0,$Param28= 0,$Type29= 0,$Param29 = 0,$Type30 = 0,$Param30 = 0) ;;Return Array Of DllCallAddress ;Only Call Virtual Method Form any Class Or From any Interface ;$MethodNum ==> Virtual Method Number In (Virtual Methods Table) ;See the examples ;-------------------------------------------------------------------;C++ Example1 ;C++ Example1 ;class iClass ;{ ;public: ;void MethodA() ;{ ;MessageBox(0,"MethodA","MSG",0); ;} ;virtual void VirtualMethodB() ;{ ;MessageBox(0,"VirtualMethodB","MSG",0); ;} ;virtual void VirtualMethodC() ;{ ;MessageBox(0,"VirtualMethodC","MSG",0); ;} ;void MethodB() ;{ ;MessageBox(0,"MethodB","MSG",0); ;} ;virtual void VirtualMethodA() ;{ ;MessageBox(0,"VirtualMethodA","MSG",0); ;} ;}; ;-----------------------------------------------------------;Virtual Methods Table ;Virtual Methods Table ;virtual void VirtualMethodB() ==> Virtual Method Number Is 1 ;virtual void VirtualMethodC() ==> Virtual Method Number Is 2 ;virtual void VirtualMethodA() ==> Virtual Method Number Is 3 ;-----------------------------------------------------------;Virtual Methods Table ;-------------------------------------------------------------------;C++ Example1 ;//////////////////////////////////////////////////////////////////////////////// ;-------------------------------------------------------------------;C++ Example2 ;C++ Example2 ;class iClassA ;{ ;public: ;void MethodA() ;{ ;MessageBox(0,"MethodA","MSG",0); ;} ;virtual void VirtualMethodB() ;{ ;MessageBox(0,"VirtualMethodB","MSG",0); ;} ;virtual void VirtualMethodC() ;{ ;MessageBox(0,"VirtualMethodC","MSG",0); ;} ;}; ;class iClassB : public iClassA ;{ ;public: ;void MethodD() ;{ ;MessageBox(0,"MethodD","MSG",0); ;} ;virtual void VirtualMethodF() ;{ ;MessageBox(0,"VirtualMethodF","MSG",0); ;} ;virtual void VirtualMethodE() ;{ ;MessageBox(0,"VirtualMethodE","MSG",0); ;} ;}; ;//////////////////////////////////////////////////////////////////////////////// ;//////////////////////////////////////////////////////////////////////////////// ;------------------------------------------;Virtual Methods Table Of iClassA Class ;Virtual Methods Table Of iClassA Class ;virtual void VirtualMethodB() ==> Virtual Method Number Is 1 ;virtual void VirtualMethodC() ==> Virtual Method Number Is 2 ;------------------------------------------;Virtual Methods Table Of iClassA Class ;//////////////////////////////////////////////////////////////////////////////// ;/////////////////////////////////////////////////////////////////////////////// ;------------------------------------------;Virtual Methods Table Of iClassB Class ;class iClassB : public iClassA ;base class ==> iClassA ;derived class ==> iClassB ;http://msdn.microsoft.com/en-us/library/hzk8a7d3.aspx ;When preceding the name of a base class, the public keyword specifies that the public ;and protected members of the base class are public and protected members, respectively, ;of the derived class. ;------------------------------------------------------------------------------------- ;Virtual Methods Table Of iClassB Class ;virtual void VirtualMethodB() In (iClassA) ==> Virtual Method Number Is 1 ;virtual void VirtualMethodC() In (iClassA) ==> Virtual Method Number Is 2 ;virtual void VirtualMethodF() In (iClassB) ==> Virtual Method Number Is 3 ;virtual void VirtualMethodE() In (iClassB) ==> Virtual Method Number Is 4 ;------------------------------------------;Virtual Methods Table Of iClassB Class ;-------------------------------------------------------------------;C++ Example2 ;//////////////////////////////////////////////////////////////////////////////// if Not IsPtr($Inface) Or ($MethodNum < 1) Then Return SetError(1,0,0) if (@NumParams > 3) And (Mod((@NumParams - 3),2) <> 0) Then Return SetError(2,0,0) Local $iMethAddress = GetMethodAddress($Inface,$MethodNum) if Not ($iMethAddress) Then Return SetError(3,0,0) Local $iDataType = "",$iFuncParam = "",$iCommand = "",$iReturn = 0 ;Why use Inface Param In DllCallAddress Function Because the Function of the method ;starts from the (Interface Or class) ;See here ;int class::MethodFunction( int Param ){return 0;}; $iCommand = 'DllCallAddress("' & $ReturnType & '",Eval("iMethAddress"),"ptr",Eval("Inface"),' For $i = 1 To ((@NumParams - 3) / 2) $iDataType = Eval("Type" & $i) $iCommand &= '"' & $iDataType & '",' $iFuncParam = 'Eval("Param' & $i & '"),' $iCommand &= $iFuncParam Next $iCommand = StringTrimRight($iCommand,1) $iCommand &= ")" $iReturn = Execute($iCommand) if @error Then Return SetError(4,0,0) Local $nReturn[UBound($iReturn) -1] , $j = 0 For $i = 0 To UBound($iReturn) - 1 if ($i = 1) Then ContinueLoop ;Skip $Inface Element $nReturn[$j] = $iReturn[$i] $j += 1 Next Return SetError(0,0,$nReturn) EndFunc Func GetMethodAddress($Inface,$MethodNum) ;$MethodNum ==> Virtual Method Number In (Virtual Methods Table) Local $SizeOfUlong_Ptr = 4,$iMethAddress = 0,$OutCastStruct1 = 0 Local $OutCast1 = 0 , $OutCastStruct2 = 0 if Not IsPtr($Inface) Or ($MethodNum < 1) Then Return SetError(1,0,0) ;------------------------------------------------------- $OutCastStruct1 = DllStructCreate("ULONG_PTR",$Inface) $OutCast1 = DllStructGetData($OutCastStruct1,1) ;In C++ ==> unsigned long** OutCast1 = *(unsigned long***)Inface; ;-------------------------------------------------------- ;------------------------------------------------------- $OutCastStruct2 = DllStructCreate("ULONG_PTR",$OutCast1 + ($SizeOfUlong_Ptr * ($MethodNum - 1))) $iMethAddress = DllStructGetData($OutCastStruct2,1) ;$OutCast1 + ($SizeOfUlong_Ptr * ($MethodNum - 1)) ==> $OutCast1 Is PTR Array Of Virtual Methods Table // Method PTR = Array[MethodNum - 1] ;In C++ ==> unsigned long* iMethAddress = *(unsigned long**)((BYTE*)OutCast1 + (SizeOfUlong_Ptr * (MethodNum - 1))); ;Or In C++ ==> unsigned long* iMethAddress = OutCast1[MethodNum - 1]; ;-------------------------------------------------------- if (IsBadCodePtr($iMethAddress)) Then Return SetError(2,0,0) Return SetError(0,0,$iMethAddress) EndFunc Func GetCount_Of_VirtualMethods($Inface) Local $SizeOfUlong_Ptr = 4,$iMethAddress = 0,$OutCastStruct1 = 0 Local $OutCast1 = 0 , $OutCastStruct2 = 0 , $MethodNum = 1 if Not IsPtr($Inface) Then Return SetError(1,0,0) ;------------------------------------------------------- $OutCastStruct1 = DllStructCreate("ULONG_PTR",$Inface) $OutCast1 = DllStructGetData($OutCastStruct1,1) ;In C++ ==> unsigned long** OutCast1 = *(unsigned long***)Inface; ;-------------------------------------------------------- While 1 ;------------------------------------------------------- $OutCastStruct2 = DllStructCreate("ULONG_PTR",DllStructGetData($OutCastStruct1,1) + ($SizeOfUlong_Ptr * ($MethodNum - 1))) $iMethAddress = DllStructGetData($OutCastStruct2,1) ;$OutCast1 + ($SizeOfUlong_Ptr * ($MethodNum - 1)) ==> $OutCast1 Is PTR Array Of Virtual Methods Table // Method PTR = Array[MethodNum - 1] ;In C++ ==> unsigned long* iMethAddress = *(unsigned long**)((BYTE*)OutCast1 + (SizeOfUlong_Ptr * (MethodNum - 1))); ;Or In C++ ==> unsigned long* iMethAddress = OutCast1[MethodNum - 1]; ;-------------------------------------------------------- if (IsBadCodePtr($iMethAddress)) Then $MethodNum -= 1 ExitLoop Else $MethodNum += 1 EndIf WEnd Return SetError(0,0,$MethodNum) EndFunc Func IsBadCodePtr($lpfn) Local $iReturn $iReturn = DllCall("Kernel32.dll","BOOL","IsBadCodePtr","ptr",$lpfn) if @error Then Return SetError(1,0,0) Return SetError(0,0,$iReturn[0]) EndFunc Func CLSIDFromString($psz) $GUID = DllStructCreate("ulong Data1;ushort Data2;ushort Data3;byte Data4[8]") $Oleerror = DllCall("Ole32.dll","int","CLSIDFromString","WSTR",$psz,"struct*",$GUID) if @error Or $Oleerror[0] <> 0 Then Return SetError(1,0,0) Return SetError(0,0,$Oleerror[2]) EndFunc Func IIDFromString($psz) $GUID = DllStructCreate("ulong Data1;ushort Data2;ushort Data3;byte Data4[8]") $Oleerror = DllCall("Ole32.dll","int","IIDFromString","WSTR",$psz,"struct*",$GUID) if @error Or $Oleerror[0] <> 0 Then Return SetError(1,0,0) Return SetError(0,0,$Oleerror[2]) EndFunc ;class FlashMemoryStream : IStream { ; public: ; FlashMemoryStream(void* data,ULONG size) { ; this->data = data; ; this->size = size; ; this->pos = 0; ; } ; ; HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, LPVOID* ppv) { ; return E_NOTIMPL; ; } ; ; ULONG STDMETHODCALLTYPE AddRef() { ; return E_NOTIMPL; ; } ; ; ULONG STDMETHODCALLTYPE Release() { ; return E_NOTIMPL; ; } ; ; // IStream methods ; STDMETHOD(Read) (void *pv,ULONG cb,ULONG *pcbRead) { ; if(pos == 0 && cb == 4) { ; memcpy(pv,"fUfU",4); ; pos += 4; ; return S_OK; ; } ; else if(pos == 4 && cb == 4) { ; memcpy(pv,&size,4); ; size += 8; ; pos += 4; ; return S_OK; ; } ; else { ; if(pos + cb > size) cb = size - pos; ; if(cb == 0) return S_FALSE; ; memcpy(pv,(char*)data + pos - 8,cb); ; if(pcbRead) (*pcbRead) = cb; ; pos += cb; ; return S_OK; ; } ; } ; ; STDMETHOD(Write) (void const *pv,ULONG cb,ULONG *pcbWritten) { return E_NOTIMPL; } ; STDMETHOD(Seek) (LARGE_INTEGER dlibMove,DWORD dwOrigin,ULARGE_INTEGER *plibNewPosition) { return E_NOTIMPL; } ; STDMETHOD(SetSize) (ULARGE_INTEGER libNewSize) { return E_NOTIMPL; } ; STDMETHOD(CopyTo) (IStream *pstm,ULARGE_INTEGER cb,ULARGE_INTEGER *pcbRead,ULARGE_INTEGER *pcbWritten) { return E_NOTIMPL; } ; STDMETHOD(Commit) (DWORD grfCommitFlags) { return E_NOTIMPL; } ; STDMETHOD(Revert) (void) { return E_NOTIMPL; } ; STDMETHOD(LockRegion) (ULARGE_INTEGER libOffset,ULARGE_INTEGER cb,DWORD dwLockType) { return E_NOTIMPL; } ; STDMETHOD(UnlockRegion) (ULARGE_INTEGER libOffset,ULARGE_INTEGER cb,DWORD dwLockType) { return E_NOTIMPL; } ; STDMETHOD(Stat) (STATSTG *pstatstg,DWORD grfStatFlag) { return E_NOTIMPL; } ; STDMETHOD(Clone) (IStream **ppstm) { return E_NOTIMPL; } ; ; void* data; ; ULONG size; ; ULONG pos; ; };1 point
-
Remote Gmail UDF Working It uses the Google atom API to get the Summary of the mail, The Summary of the mail is enough to get a direct link or a single function with parameters Execute any Function (or Script) and get the Return Values in your E-mail Requirements Gmail (Email) Account A Remote Computer with Internet Access Representation Functions You can now use you Gmail account to use Autoit Functions in a remote computer Can execute a function through reading the email. Can Email back the return values of an executed function. The parameter can even be a variable present in the script [see Syntax] Execute a Script through Direct Link. Execute multiple scripts zipped together through Direct Link. Can Email back the PID of the running executables with the scripts. Attach any file and get it in your email. Able to send the multiple attachments zipped together. Writes all the return values in a Log file. No email is executed twice, the Message IDs are stored for this purpose. Future Updates Support single line nesting Get the attachment, to execute the script Syntax Syntax for Functions PXL<FuncName>: (<data type>)<first param part a>+(<data type>)<first param part b>|(<data type>)<secondparam>/PXL Colon[:] - Separation of Function Name with the Parameters Bar [ | ] - Separation of different parameters Plus [+] - To Concatenate Values PXL /PXL - The tags where the code is enclosed Brackets [ () ] - For specifying the type of the parameter DataTypes - Always Preceded by any parameter and are enclosed with brackets ; | (s) - String ; | (n) - Number ; | (f) - Floating Number ; | (i) - Integer ; | (b ) - Binary ; | (v) - Variable ; | (h) - Hex ; | (m) - macro ; | (w) - Handle ; | (p) - Pointer Syntax for Direct Links PXL<DirectLink>^<Type>/PXL PXL /PXL - The tags where the code is enclosed Caret [ ^ ] - To Separate the Link and the Type Type - Either Zip or au3 DirectLink WebServer Some of webservers providing Direct Links DropBox [Tested - Recommended] Herosh [Tested]* FileToLink FileDen * DirectLink from Herosh changes therefore Example 4 wont work after a while Credits CaptainClucks - Atom Feed Jos - SMTP Mailer wraithdu - Zip UDF Change Log v1.0 - First Release v1.1 - Added Script Execution with Zipping Functionality v1.2 - Fixed some Minor bugs v1.3 - Added RemoteGmail_Startup v1.4 - Fixed Compiling Issues v1.5 - Added flexibility for execution of scripts from any email. The UDF - Download The UDF is currently tested on x86 All Comments ,Queries , Feedback and Advice are welcomed... The UDF with the Examples have been compiled in the following Zip v1.5 RemoteGmail.7z Previous Downloads : 1119 Regards Phoenix XL1 point
-
Monitor Configuration UDF
Bluesmaster reacted to jaberwacky for a topic
I found these functions on MSDN which control various aspects of monitors such as brightness, contrast, color temperature, etc. This works on my monitors on Windows7 x64. Your mileage may vary. Doesn't work on anything lower than Windows Vista. Not all monitors are supported. Requires the latest AutoIt3 beta. [10-17-2013] -- The VCPs described in the MCCS standard are now wrapped up into Monitor Configuration Wrapper.au3. BE CAREFUL WITH THESE! I made this UDF without any real understanding of why. I do not foresee myself using these, but I put them out here in case someone else does. These functions are all untested. I leave it up to you to decide if the functions that you want to use have been implemented correctly. If you bork your monitor, then go out and buy yourself something really nice. Here are the required au3 files: Monitor Configuration.zip previous: 52 The list of files in the UDF: Monitor Configuration Wrapper.au3 -- This wraps up the MCCS standard into a UDF. Deprecates Low Level.au3. Beware. Example High Level.au3 -- Run this example for a simple monitor configuration dashboard. Monitor Configuration High Level.au3 Monitor Configuration Low Level.au3 -- Deprecated. Monitor Configuration Constants.au3 Monitor Configuration.au3 -- Internal, do not use. What's that? You want to turn off your monitor programmatically? #include "Monitor Configuration Wrapper.au3" Global Const $physical_monitor = GetPhysicalMonitorsFromHMonitor(_WinAPI_EnumDisplayMonitors()[1][0]) PowerMode($physical_monitor, $POWER_OFF)1 point -
An improved _ArrayUnique
jaberwacky reacted to BrewManNH for a topic
The function _ArrayUnique in the Array UDF has some serious design flaws in it, not to mention it's incredibly slow. This is a rewrite of that function. Practically nothing from the original function has remained. This version... doesn't rely upon using _ArrayAdd, not using that shaved 4 seconds off when using this with a 4100+ row array. has extensive bounds checking on all parameters of the function, something the original didn't do at all. streamlines the error checking process so it returns quicker when something sent to it isn't set correctly, all done at the top of the function doesn't use Dim eliminates the $vDelim parameter, which even the documentation says about it, "However, cannot forsee its usefullness" adds the ability to return a 2D array if sent a 2D array, and the $bReturn2 parameter is set to true. This will search the column requested, finding any duplicated entries, removing those duplicate entries, but returning all the rows that were found first. I don't know if anyone will find any use for this part of the function, but it was surprisingly easy to implement it, so I figured I'd leave it in. This version is approximately 50 - 80% faster than the original, and won't crash your script if you send it the wrong values in the parameters. Please play around with this to see if you can break it, or improve it. There is an example script inside the archive that uses the MusicList file as input. The MusicList file is just a text file with 4104 lines and 6 columns, try running the new and original versions using the 6th column as a search and see the difference in execution time. Returning a 2D array on a large array is going to take a lot longer than just returning a single dimension of the array. Using it on the 6th column of this array is still faster than returning a 1D array using the original function. __ArrayUnique.zip1 point -
I've written some code for AutoIt that enables users to create objects from servers (dll-s) without the need to do any kind of registration manually. I didn't document it back then so likely you won't find any references. To use it, you would do something like this: Global Const $sCLSID_Mail = "{DF8A4FE2-221A-4504-987A-3FD4720DB929}" Global $hDLL = DllOpen("EASendMailObj.dll") ; path to the dll ; Create object $oObj = ObjCreate($sCLSID_Mail, Default, $hDLL) ; Do things with the object... ConsoleWrite("Date thingy = " & $oObj.Date & @CRLF) $oObj.BodyText = "Test Body" ;... Does that work for you? Oh and you need beta AutoIt for that.1 point
-
Less CPU usage
chriswaldeck reacted to Melba23 for a topic
chriswaldeck, Add a Sleep(10) in the While...WEnd loop to give the CPU a chance to draw breath. You should always add a Sleep to any tight loop unless there is a GUIGetMsg/TrayGetMsg command in there - those 2 functions have a built-in pause. M231 point -
You're right, it should say the subitem to search in a 2D array. EDIT: In looking into the guts of that function, there's a lot more wrong with it than the documentation.1 point
-
Take a look at _WinAPI_GetSaveFileName(). Also >this thread might be worth a read.1 point
-
Try this: ConsoleWrite(FloorEx(13.185) & @LF) ConsoleWrite(FloorEx(13.1899) & @LF) Func FloorEx($fNumber, $iDec = 3) Return Floor(Int($fNumber * 10^($iDec - 1))) / 10^($iDec - 1) EndFunc Br, UEZ1 point