Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/13/2014 in all areas

  1. When you say "wstr" or "str" it means string pointer. That means your dll func should accept just that: unsigned int __stdcall _Asc(wchar_t* Char) { // Sanity check if (Char == nullptr) return 0; // Read firts character wchar_t x = Char[0]; // Return character value of your type return static_cast<unsigned int>(x); } And on script side: MsgBox(0,"Success", _Asc("A")) Func _Asc($char) $a_Asc = DllCall("AU3.dll", "uint", "_Asc", "wstr", $char) If @error Then Exit MsgBox(0, "_Asc Error", @error) EndIf Return $a_Asc[0] EndFunc
    2 points
  2. trancexx

    OOP or functional.

    AutoItObject is great way to learn some OOP basics from AutoIt. Memory usage shouldn't worry you, there wouldn't be differences. I never said this, but AutoItObject relies on one particular reference counting bug in AutoIt. When it would be fixed AutoItObject will stop working unless rewritten. But you also shouldn't worry much about that either, it probably will never be fixed .
    2 points
  3. wolf9228

    Other Interface call

    First Interface call '?do=embed' frameborder='0' data-embedContent>> By the project you can call methods of classes And Interface through DispCallFunc function I think the project is important for all ... Thanks All project files Other_InterfaceCall.zip InterfaceCall.au3 ;enum $tagCALLCONV Global $CC_FASTCALL = 0 Global $CC_CDECL = 1 Global $CC_MSCPASCAL = $CC_CDECL + 1 Global $CC_PASCAL = $CC_MSCPASCAL Global $CC_MACPASCAL = $CC_PASCAL + 1 Global $CC_STDCALL = $CC_MACPASCAL + 1 Global $CC_FPFASTCALL = $CC_STDCALL + 1 Global $CC_SYSCALL = $CC_FPFASTCALL + 1 Global $CC_MPWCDECL = $CC_SYSCALL + 1 Global $CC_MPWPASCAL = $CC_MPWCDECL + 1 Global $CC_MAX = $CC_MPWPASCAL + 1 ;enum $tagCALLCONV Global $OleAut32 = DllOpen("OleAut32.dll") Global $tagVariant = "USHORT vt;WORD wReserved1;WORD wReserved2;WORD wReserved3;byte union[8]" Global $SizeOfUlong_Ptr = DllStructGetSize(DllStructCreate("ULONG_PTR")) 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) ;Call Only Virtual Methods 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 ((@NumParams > 3) And (Mod((@NumParams - 3),2) <> 0)) Then Return SetError(1,0,0) Local $NumParams = ((@NumParams - 3) / 2) Local $nReturn[$NumParams + 1][3], $Variant = 0,$BOOLREF = 0,$RtVariant = 0 Local $Value = "",$DataType = "",$DataTypeNu = 0,$RtTypeNu = 0,$CALLCONV = $CC_STDCALL Local $VARIANTARG = DllStructCreate("PTR[" & $NumParams & "]") Local $VARTYPE = DllStructCreate("WORD[" & $NumParams & "]") $ReturnType = StringUpper($ReturnType) if (StringRight($ReturnType,6) == ";CDECL") Then $ReturnType = StringReplace($ReturnType,";CDECL","") $CALLCONV = $CC_CDECL EndIf For $i = 0 To $NumParams if ($i = 0) Then ; $i = 0 Is Return $DataType = $ReturnType $Value = "" $DataTypeNu = InfaceDataTypeNu($DataType) if @error Then Return SetError(2,0,0) $BOOLREF = @extended $RtTypeNu = $DataTypeNu $Variant = DllStructCreate($tagVariant) $RtVariant = $Variant $nReturn[$i][0] = $Variant DllStructSetData($Variant,"vt",$DataTypeNu) $DataType = StringReplace($DataType,"*","") Else $Value = Eval("Param" & $i) $DataType = Eval("Type" & $i) $DataTypeNu = InfaceDataTypeNu($DataType) if @error Then Return SetError(2,0,0) $BOOLREF = @extended $Variant = DllStructCreate($tagVariant) $nReturn[$i][0] = $Variant DllStructSetData($Variant,"vt",$DataTypeNu) DllStructSetData($VARTYPE,1,$DataTypeNu,$i) DllStructSetData($VARIANTARG,1,DllStructGetPtr($Variant),$i) EndIf $DataType = StringReplace(StringUpper($DataType),"*","") Switch $DataType Case "STR" if ($i = 0) Then $BOOLREF = True ; $i = 0 Is Return Switch $BOOLREF Case True $nReturn[$i][1] = MakByRef() $nReturn[$i][2] = 3 SetUnionOfVariant($Variant,"ptr",DllStructGetPtr($nReturn[$i][1])) Case False $StringSt = DllStructCreate("CHAR[" & (StringLen($Value) + 1) & "]") DllStructSetData($StringSt,1,$Value) $nReturn[$i][1] = $StringSt $nReturn[$i][2] = 2 SetUnionOfVariant($Variant,"ptr",DllStructGetPtr($StringSt)) EndSwitch Case "WSTR" if ($i = 0) Then $BOOLREF = True ; $i = 0 Is Return Switch $BOOLREF Case True $nReturn[$i][1] = MakByRef() $nReturn[$i][2] = 4 SetUnionOfVariant($Variant,"ptr",DllStructGetPtr($nReturn[$i][1])) Case False $StringSt = DllStructCreate("WCHAR[" & (StringLen($Value) + 1) & "]") DllStructSetData($StringSt,1,$Value) $nReturn[$i][1] = $StringSt $nReturn[$i][2] = 2 SetUnionOfVariant($Variant,"ptr",DllStructGetPtr($StringSt)) EndSwitch Case "STRUCT" $nReturn[$i][1] = $Value SetUnionOfVariant($Variant,"ptr",DllStructGetPtr($Value)) $nReturn[$i][2] = 0 Case Else Switch $BOOLREF Case True $nReturn[$i][1] = MakByRef($DataType) $nReturn[$i][2] = 1 SetUnionOfVariant($Variant,"ptr",DllStructGetPtr($nReturn[$i][1])) Case False $nReturn[$i][1] = $Value $nReturn[$i][2] = 0 SetUnionOfVariant($Variant,$DataType,$Value) EndSwitch EndSwitch Next Local $oVft = ($SizeOfUlong_Ptr * ($MethodNum - 1));$MethodNum ==> Virtual Method Number In Virtual Methods Table Start From 1 $HRESULT = DllCall($OleAut32,"long","DispCallFunc","ptr",$Inface,"ULONG_PTR",$oVft,"int",$CALLCONV _ ,"WORD",$RtTypeNu,"UINT",$NumParams,"struct*",$VARTYPE,"struct*",$VARIANTARG ,"struct*",$RtVariant) if @error Or $HRESULT[0] <> 0 Then Return SetError(3,0,0) Local $vReturn[($NumParams + 1)] For $i = 0 To $NumParams $Value = $nReturn[$i][1] $IsOutDllStruct = $nReturn[$i][2] if ($i = 0) Then ; $i = 0 Is Return Switch $IsOutDllStruct Case 0 ;WtheOut ByRef $vReturn[$i] = GetUnionOfVariant($RtVariant,$ReturnType) Case 1 ;Wthe ByRef $vReturn[$i] = GetByRefValue($Value) Case 3 ;Wthe ByRef Ans String Data Type $vReturn[$i] = StringFromPtr(GetByRefValue($Value),False) Case 4 ;Wthe ByRef UniCode String Data Type $vReturn[$i] = StringFromPtr(GetByRefValue($Value),True) EndSwitch Else ; Else Params Switch $IsOutDllStruct Case 0 ;WtheOut ByRef $vReturn[$i] = $Value Case 1 ;Wthe ByRef $vReturn[$i] = GetByRefValue($Value) Case 2 ;WtheOut ByRef Ans Or UniCode String Data Type $vReturn[$i] = DllStructGetData($Value,1) ;Get String From $StringSt Case 3 ;Wthe ByRef Ans String Data Type $vReturn[$i] = StringFromPtr(GetByRefValue($Value),False) Case 4 ;Wthe ByRef UniCode String Data Type $vReturn[$i] = StringFromPtr(GetByRefValue($Value),True) EndSwitch EndIf Next Return $vReturn EndFunc Func StringFromPtr($StringPtr,$UniCode = False) if (Not(IsPtr($StringPtr)) Or $StringPtr = Ptr(0)) Then Return SetError(1,0,"") if ($UniCode) Then $StrLen = DllCall("Kernel32.dll","int","lstrlenW","ptr",$StringPtr) if @error Then Return SetError(2,0,"") $StrLen = $StrLen[0] Return DllStructGetData(DllStructCreate("WCHAR[" & ($StrLen + 1) & "]",$StringPtr),1) Else $StrLen = DllCall("Kernel32.dll","int","lstrlenA","ptr",$StringPtr) if @error Then Return SetError(2,0,"") $StrLen = $StrLen[0] Return DllStructGetData(DllStructCreate("CHAR[" & ($StrLen + 1) & "]",$StringPtr),1) EndIf EndFunc Func InfaceDataTypeNu($DataType) ;VARIANT structure ;http://msdn.microsoft.com/en-us/library/windows/desktop/ms221627%28v=vs.85%29.aspx ;VARENUM enumeration ;http://msdn.microsoft.com/en-us/library/windows/desktop/ms221170%28v=vs.85%29.aspx Local $DataTypeNu , $VT_BYREF = 0x4000 $DataType = StringUpper($DataType) Switch $DataType Case "STRUCT*","STR","WSTR" $DataType = "PTR" Case "STR*","WSTR*" $DataType = "PTR*" EndSwitch Local $BOOLREF = (StringInStr($DataType,"*") <> 0) $DataType = StringReplace($DataType,"*","") Switch $DataType Case "NONE" $DataTypeNu = 24 Case "BYTE","BOOLEAN" $DataTypeNu = 17 Case "SHORT" $DataTypeNu = 2 Case "USHORT","WORD" $DataTypeNu = 18 Case "INT","LONG","BOOL" $DataTypeNu = 22 Case "UINT","ULONG","DWORD" $DataTypeNu = 23 Case "INT64" $DataTypeNu = 20 Case "UINT64" $DataTypeNu = 21 Case "FLOAT" $DataTypeNu = 4 Case "DOUBLE" $DataTypeNu = 5 ;--------------------------------------------------------------------------------------------- ;_____________ C++ 6.0 wtypes.h __________ ;VT_I8 = 20 ;VT_UI8 = 21 ;VT_I4 = 3 ;VT_UI4 = 19 ;#ifdef _WIN64 ;#define VT_INT_PTR VT_I8 ;#define VT_UINT_PTR VT_UI8 ;#else ;#define VT_INT_PTR VT_I4 ;#define VT_UINT_PTR VT_UI4 ;#endif ;_____________ C++ 6.0 wtypes.h __________ ; _WIN64 Macro Defined for applications for Win64. ;@AutoItX64 Returns 1 if the script is running under the native x64 version of AutoIt. Case "HWND" ;32bit(4bytes) integer $DataTypeNu = 3 ;VT_I4 Case "HANDLE" ;32bit(4bytes) integer $DataTypeNu = 3 ;VT_I4 Case "LPARAM","INT_PTR","LONG_PTR","LRESULT" ;32 or 64bit signed integer if (@AutoItX64) Then $DataTypeNu = 20 ;VT_I8 Else $DataTypeNu = 3 ;VT_I4 EndIf Case "PTR","UINT_PTR","ULONG_PTR","DWORD_PTR","WPARAM" ;32 or 64bit unsigned integer if (@AutoItX64) Then $DataTypeNu = 21 ;VT_UI8 Else $DataTypeNu = 19 ;VT_UI4 EndIf ;_____________ C++ 6.0 wtypes.h __________ ;VT_I8 = 20 ;VT_UI8 = 21 ;VT_I4 = 3 ;VT_UI4 = 19 ;#ifdef _WIN64 ;#define VT_INT_PTR VT_I8 ;#define VT_UINT_PTR VT_UI8 ;#else ;#define VT_INT_PTR VT_I4 ;#define VT_UINT_PTR VT_UI4 ;#endif ;_____________ C++ 6.0 wtypes.h __________ ; _WIN64 Macro Defined for applications for Win64. ;@AutoItX64 Returns 1 if the script is running under the native x64 version of AutoIt ;--------------------------------------------------------------------------------------------- Case Else Return SetError(1,0,-1) EndSwitch if ($BOOLREF) Then $DataTypeNu = BitOR($VT_BYREF,$DataTypeNu) Return SetError(0,$BOOLREF,$DataTypeNu) EndFunc Func MakByRef($DataType = "ptr") Return DllStructCreate(String($DataType & " ByRef")) EndFunc Func GetByRefValue($ByRefSt) Return DllStructGetData($ByRefSt,1) EndFunc Func SetUnionOfVariant($VariantSt,$DataType,$Value) Return DllStructSetData(DllStructCreate($DataType,DllStructGetPtr($VariantSt,"union")),1,$Value) EndFunc Func GetUnionOfVariant($VariantSt,$DataType) Return DllStructGetData(DllStructCreate($DataType,DllStructGetPtr($VariantSt,"union")),1) 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 IPictureInterface.au3 #include "InterfaceCall.au3" #include <WinAPI.au3> ;IPicture interface---------------------------------------------------------;IPicture interface ;EXTERN_C const IID IID_IPicture; ; ; ; ;#if defined(__cplusplus) && !defined(CINTERFACE) ; ; ; ; MIDL_INTERFACE("7BF80980-BF32-101A-8BBB-00AA00300CAB") ; ; IPicture : public IUnknown ; ; { ; ; public: ; ; virtual HRESULT STDMETHODCALLTYPE get_Handle( ; ; /* [out] */ OLE_HANDLE __RPC_FAR *pHandle) = 0; ; ; ; ; virtual HRESULT STDMETHODCALLTYPE get_hPal( ; ; /* [out] */ OLE_HANDLE __RPC_FAR *phPal) = 0; ; ; ; ; virtual HRESULT STDMETHODCALLTYPE get_Type( ; ; /* [out] */ SHORT __RPC_FAR *pType) = 0; ; ; ; ; virtual HRESULT STDMETHODCALLTYPE get_Width( ; ; /* [out] */ OLE_XSIZE_HIMETRIC __RPC_FAR *pWidth) = 0; ; ; ; ; virtual HRESULT STDMETHODCALLTYPE get_Height( ; ; /* [out] */ OLE_YSIZE_HIMETRIC __RPC_FAR *pHeight) = 0; ; ; ; ; virtual HRESULT STDMETHODCALLTYPE Render( ; ; /* [in] */ HDC hDC, ; ; /* [in] */ LONG x, ; ; /* [in] */ LONG y, ; ; /* [in] */ LONG cx, ; ; /* [in] */ LONG cy, ; ; /* [in] */ OLE_XPOS_HIMETRIC xSrc, ; ; /* [in] */ OLE_YPOS_HIMETRIC ySrc, ; ; /* [in] */ OLE_XSIZE_HIMETRIC cxSrc, ; ; /* [in] */ OLE_YSIZE_HIMETRIC cySrc, ; ; /* [in] */ LPCRECT pRcWBounds) = 0; ; ; ; ; virtual HRESULT STDMETHODCALLTYPE set_hPal( ; ; /* [in] */ OLE_HANDLE hPal) = 0; ; ; ; ; virtual HRESULT STDMETHODCALLTYPE get_CurDC( ; ; /* [out] */ HDC __RPC_FAR *phDC) = 0; ; ; ; ; virtual HRESULT STDMETHODCALLTYPE SelectPicture( ; ; /* [in] */ HDC hDCIn, ; ; /* [out] */ HDC __RPC_FAR *phDCOut, ; ; /* [out] */ OLE_HANDLE __RPC_FAR *phBmpOut) = 0; ; ; ; ; virtual HRESULT STDMETHODCALLTYPE get_KeepOriginalFormat( ; ; /* [out] */ BOOL __RPC_FAR *pKeep) = 0; ; ; ; ; virtual HRESULT STDMETHODCALLTYPE put_KeepOriginalFormat( ; ; /* [in] */ BOOL keep) = 0; ; ; ; ; virtual HRESULT STDMETHODCALLTYPE PictureChanged( void) = 0; ; ; ; ; virtual HRESULT STDMETHODCALLTYPE SaveAsFile( ; ; /* [in] */ LPSTREAM pStream, ; ; /* [in] */ BOOL fSaveMemCopy, ; ; /* [out] */ LONG __RPC_FAR *pCbSize) = 0; ; ; ; ; virtual HRESULT STDMETHODCALLTYPE get_Attributes( ; ; /* [out] */ DWORD __RPC_FAR *pDwAttr) = 0; ; ; ; ; }; ;IPicture interface---------------------------------------------------------;IPicture interface ;------------------------------- ;IPicture : public IUnknown ;-------------------------------- ;base class ==> IUnknown ;derived class ==> IPicture ;--------------------------------- ;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. ;--------------------------------- ;IUnknown interface---------------------------------------------------------;IUnknown interface ;#if (_MSC_VER >= 1100) && defined(__cplusplus) && !defined(CINTERFACE) ; ; EXTERN_C const IID IID_IUnknown; ; ; extern "C++" ; ; { ; ; MIDL_INTERFACE("00000000-0000-0000-C000-000000000046") ; ; IUnknown ; ; { ; ; public: ; ; BEGIN_INTERFACE ; ; virtual HRESULT STDMETHODCALLTYPE QueryInterface( ; ; /* [in] */ REFIID riid, ; ; /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject) = 0; ; ; ; ; virtual ULONG STDMETHODCALLTYPE AddRef( void) = 0; ; ; ; ; virtual ULONG STDMETHODCALLTYPE Release( void) = 0; ; ; ; ; template<class Q> ; ; HRESULT STDMETHODCALLTYPE QueryInterface(Q** pp) ; ; { ; ; return QueryInterface(__uuidof(Q), (void **)pp); ; ; } ; ; ; ; END_INTERFACE ; ; }; ;IUnknown interface---------------------------------------------------------;IUnknown interface ;------------------------------------------;Virtual Methods Table Of IPicture interface ;Virtual Methods Table Of IPicture interface ;virtual HRESULT QueryInterface() In (IUnknown interface) ==> Virtual Method Number Is 1 ;virtual ULONG AddRef() In (IUnknown interface) ==> Virtual Method Number Is 2 ;virtual ULONG Release() In (IUnknown interface) ==> Virtual Method Number Is 3 ;virtual HRESULT get_Handle() In (IPicture interface) ==> Virtual Method Number Is 4 ;virtual HRESULT get_hPal() In (IPicture interface) ==> Virtual Method Number Is 5 ;virtual HRESULT get_Type() In (IPicture interface) ==> Virtual Method Number Is 6 ;virtual HRESULT get_Width() In (IPicture interface) ==> Virtual Method Number Is 7 ;virtual HRESULT get_Height() In (IPicture interface) ==> Virtual Method Number Is 8 ;virtual HRESULT Render() In (IPicture interface) ==> Virtual Method Number Is 9 ;virtual HRESULT set_hPal() In (IPicture interface) ==> Virtual Method Number Is 10 ;virtual HRESULT get_CurDC() In (IPicture interface) ==> Virtual Method Number Is 11 ;virtual HRESULT SelectPicture() In (IPicture interface) ==> Virtual Method Number Is 12 ;virtual HRESULT get_KeepOriginalFormat() In (IPicture interface) ==> Virtual Method Number Is 13 ;virtual HRESULT put_KeepOriginalFormat() In (IPicture interface) ==> Virtual Method Number Is 14 ;virtual HRESULT PictureChanged() In (IPicture interface) ==> Virtual Method Number Is 15 ;virtual HRESULT SaveAsFile() In (IPicture interface) ==> Virtual Method Number Is 16 ;virtual HRESULT get_Attributes() In (IPicture interface) ==> Virtual Method Number Is 17 ;The Count Of Virtual Methods Is 17 ;------------------------------------------;Virtual Methods Table Of IPicture interface $IPicture = GetIPictureInterface("Image.jpg") ;-------------------------------------------------- ;-------------------------------------------------- ;////////////////////////////////////////////////// ;-------------------------------------------------- ; C++ virtual HRESULT STDMETHODCALLTYPE get_Handle(OLE_HANDLE __RPC_FAR *pHandle); ;get_Handle() Virtual Method Number Is 4 ;InterfaceCall($Inface,$ReturnType,$MethodNum,$Type1 = 0,$Param1 = 0) ;$Inface = $IPicture ;$ReturnType = "Long" Or HRESULT ;$MethodNum = 4 // Virtual Method Number ;$Type1 = "ptr*" Out Ptr ;$Param1 = 0 $Rt = InterfaceCall($IPicture,"long",4,"ptr*",0) ;Return Array Of DllCallAddress if Not @error Then $Handle = $Rt[1] MsgBox(0,"get_Handle","Image Handle Is " & $Handle) EndIf ;-------------------------------------------------- ;////////////////////////////////////////////////// ;C ++ virtual HRESULT STDMETHODCALLTYPE get_Type(SHORT __RPC_FAR *pType); ;get_Type() Virtual Method Number Is 6 ;InterfaceCall($Inface,$ReturnType,$MethodNum,$Type1 = 0,$Param1 = 0) ;$Inface = $IPicture ;$ReturnType = "Long" Or HRESULT ;$MethodNum = 6 // Virtual Method Number ;$Type1 = "SHORT*" Out SHORT ;$Param1 = 0 $Rt = InterfaceCall($IPicture,"long",6,"SHORT*",0) ;Return Array Of DllCallAddress if Not @error Then $Type = $Rt[1] MsgBox(0,"get_Type()","Image Type Is " & $Type) EndIf ;virtual HRESULT STDMETHODCALLTYPE get_Width(OLE_XSIZE_HIMETRIC __RPC_FAR *pWidth); ;get_Width() Virtual Method Number Is 7 ;InterfaceCall($Inface,$ReturnType,$MethodNum,$Type1 = 0,$Param1 = 0) ;$Inface = $IPicture ;$ReturnType = "Long" Or HRESULT ;$MethodNum = 7 // Virtual Method Number ;$Type1 = "LONG*" Out LONG Or Out OLE_XSIZE_HIMETRIC ;$Param1 = 0 $Rt = InterfaceCall($IPicture,"long",7,"LONG*",0) ;Return Array Of DllCallAddress if Not @error Then $Width = $Rt[1] $Width = MulDiv($Width,GetDeviceCaps(GetDC(0),88),2540); 88 => LOGPIXELSX MsgBox(0,"get_Width()","Image Width Is " & $Width) EndIf ;C++ virtual HRESULT STDMETHODCALLTYPE get_Height(OLE_YSIZE_HIMETRIC __RPC_FAR *pHeight) ;get_Height() Virtual Method Number Is 8 ;InterfaceCall($Inface,$ReturnType,$MethodNum,$Type1 = 0,$Param1 = 0) ;$Inface = $IPicture ;$ReturnType = "Long" Or HRESULT ;$MethodNum = 8 // Virtual Method Number ;$Type1 = "LONG*" Out LONG Or Out OLE_YSIZE_HIMETRIC ;$Param1 = 0 $Rt = InterfaceCall($IPicture,"long",8,"LONG*",0) ;Return Array Of DllCallAddress if Not @error Then $Height = $Rt[1] $Height = MulDiv($Height,GetDeviceCaps(GetDC(0),90),2540); 90 => LOGPIXELSY MsgBox(0,"get_Height()","Image Height Is " & $Height) EndIf Func GetIPictureInterface($ImageFileName) Local $nBytes $FileSize = FileGetSize($ImageFileName) + 1 if @error Then Return SetError(1,0,0) $tBuffer = DllStructCreate("byte[" & $FileSize & "]") $hFile = _WinAPI_CreateFile($ImageFileName, 2, 2) if @error Then Return SetError(2,0,0) _WinAPI_ReadFile($hFile,DllStructGetPtr($tBuffer),$FileSize,$nBytes) if @error Then Return SetError(3,0,0) _WinAPI_CloseHandle($hFile) $LPVOID = DllStructGetPtr($tBuffer) $hMem = GlobalAlloc(0x0042,$FileSize) ;$GHND = 0x0042 if @error Then SetError(4,0,0) $hLock = GlobalLock($hMem) if @error Then GlobalFree($hMem) Return SetError(5,0,0) EndIf MoveMemory($LPVOID,$hLock,$FileSize) $lpstream = CreateStreamOnHGlobal($hLock,True) if @error Then SetError(6,0,0) $riid = IIDFromString("{7BF80980-BF32-101A-8BBB-00AA00300CAB}") if @error Then SetError(7,0,0) $HRESULT = DllCall($OleAut32,"LONG","OleLoadPicture","PTR",$lpstream,"LONG", _ $FileSize,"BOOL",True,"ptr",DllStructGetPtr($riid),"PTR*",0) if @error Or $HRESULT[0] <> 0 Then GlobalUnlock($hMem) GlobalFree($hMem) Return SetError(8,0,0) EndIf GlobalUnlock($hMem) GlobalFree($hMem) $IPicture = $HRESULT[5] Return SetError(0,0,$IPicture) EndFunc Func GlobalAlloc($uFlags,$dwBytes) $HGLOBAL = DllCall("Kernel32.dll","ptr","GlobalAlloc","UINT",$uFlags,"ULONG_PTR",$dwBytes) if @error Or $HGLOBAL[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$HGLOBAL[0]) EndFunc Func GlobalLock($hMem) $LPVOID = DllCall("Kernel32.dll","ptr","GlobalLock","ptr",$hMem) if @error Or $LPVOID[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$LPVOID[0]) EndFunc Func GlobalUnlock($hMem) $BOOL = DllCall("Kernel32.dll","BOOL","GlobalUnlock","ptr",$hMem) if @error Or $BOOL[0] = 0 Then Return SetError(1,0,0) Return SetError(0,$BOOL[0]) EndFunc Func GlobalFree($hMem) $HGLOBAL = DllCall("Kernel32.dll","ULONG_PTR","GlobalFree","ptr",$hMem) if (@error Or ($HGLOBAL[0])) Then Return SetError(1,0,$HGLOBAL[0]) Return SetError(0,0,0) EndFunc Func CreateStreamOnHGlobal($hGlobal,$fDeleteOnRelease) $WINOLE = DllCall("Ole32.dll","PTR","CreateStreamOnHGlobal","ptr",$hGlobal,"BOOL",$fDeleteOnRelease _ ,"PTR*",0) if @error Or $WINOLE[0] <> 0 Then Return SetError(1,0,0) Return SetError(0,0,$WINOLE[3]) EndFunc Func MulDiv($nNumber,$nNumerator,$nDenominator) $Rt = DllCall("Kernel32.dll","int","MulDiv","int",$nNumber,"int",$nNumerator,"int",$nDenominator) Return $Rt[0] EndFunc Func GetDeviceCaps($hdc,$nIndex) $Rt = DllCall("Gdi32.dll","int","GetDeviceCaps","ptr",$hdc,"int",$nIndex) Return $Rt[0] EndFunc Func GetDC($hWnd) $HDC = DllCall("User32.dll","ptr","GetDC","ptr",$hWnd) if @error Or $HDC[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$HDC[0]) EndFunc Func MoveMemory($Source,$Destination,$Length) DllCall("Kernel32.dll","none","RtlMoveMemory","PTR",$Destination,"PTR",$Source,"INT",$Length) EndFunc IRichEditOleInterface.au3 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiRichEdit.au3> #include <SendMessage.au3> #include "InterfaceCall.au3" $hGui = GUICreate("InsertObject Example",500,390) $hRichEdit = _GUICtrlRichEdit_Create($hGui,"", 10, 10,480,300, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) $Button1 = GUICtrlCreateButton("InsertObject",10,320,200,50) GUICtrlSetFont(-1,18,600) GUISetState() InsertObject($hRichEdit,@ScriptDir & "\Image.bmp") While True $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) Exit Case $iMsg = $Button1 $var = FileOpenDialog("", @MyDocumentsDir & "\","All (*.*)", 1 + 4) if Not @error Then InsertObject($hRichEdit,$var) EndIf EndSelect WEnd ;http://msdn.microsoft.com/en-us/library/windows/desktop/dd387916%28v=vs.85%29.aspx ;Use a Rich Edit Interface ;Rich edit controls expose some of their functionality through Component Object Model ;(COM) interfaces. By obtaining an interface from a control, you gain the ability to ;work with other objects within the control. You can obtain this interface by sending ;the EM_GETOLEINTERFACE message. From the IRichEditOle interface, you can then obtain ;interfaces used in the Text Object Model. ;Another interface, IRichEditOleCallback, is implemented by applications to define the ;behavior of the control when it interacts with objects. ;Insert an Object into a Rich Edit Control ;The following code example inserts a file object into a rich edit control. If a program ;is associated with the file type on the user's machine (for example, Microsoft Excel for ;an .xls file), the contents of the file display in the control; otherwise, an icon appears. Func InsertObject($hRichEdit,$pszFileName) Local $hr = 0, $Rt = 0 , $EM_GETOLEINTERFACE = 1084 , $pRichEditOle = 0 $pRichEditOle = _SendMessage($hRichEdit,$EM_GETOLEINTERFACE,0,0,4,"wparam","ptr*") if ($pRichEditOle == 0) Then return FALSE; EndIf Local $pLockBytes = 0 $hr = DllCall("Ole32.dll","long","CreateILockBytesOnHGlobal","ptr",0,"BOOL",True,"Ptr*",0) if (@error Or $hr[0] <> 0) Then return FALSE; EndIf $pLockBytes = $hr[3] Local $pStorage = 0 $hr = DllCall("Ole32.dll","long","StgCreateDocfileOnILockBytes","ptr",$pLockBytes, _ "DWORD",BitOR(0x00000010,0x00001000,0x00000002), _ "DWORD",0,"Ptr*",0) if (@error Or $hr[0] <> 0) Then return FALSE; EndIf $pStorage = $hr[4] $tagFORMATETC = "int cfFormat;ptr ptd;DWORD dwAspect;LONG lindex;DWORD tymed" $formatEtc = DllStructCreate($tagFORMATETC) DllStructSetData($formatEtc,"cfFormat",0) DllStructSetData($formatEtc,"ptd",0) DllStructSetData($formatEtc,"dwAspect",1) DllStructSetData($formatEtc,"lindex",-1) DllStructSetData($formatEtc,"tymed",0) Local $pClientSite ;hr = pRichEditOle->GetClientSite(&pClientSite); ;GetClientSite Virtual Method Number Of GetClientSite Is 4 in (IRichEditOle interface) $hr = InterfaceCall($pRichEditOle,"long",4,"ptr*",0) if (@error Or $hr[0] <> 0) Then return FALSE; EndIf $pClientSite = $hr[1] Local $pUnk,$clsid = CLSIDFromString("{00000000-0000-0000-0000-000000000000}") Local $IID_IUnknown = IIDFromString("{00000000-0000-0000-C000-000000000046}") $hr = DllCall("Ole32.dll","long","OleCreateFromFile","ptr",DllStructGetPtr($clsid),"wstr", _ $pszFileName,"ptr",DllStructGetPtr($IID_IUnknown),"DWORD",1,"ptr",DllStructGetPtr($formatEtc) _ ,"ptr",$pClientSite,"ptr",$pStorage,"Ptr*",0) ;pClientSite->Release(); ;IOleClientSite interface inherits from the IUnknown Or IOleClientSite : public IUnknown ;Release() Virtual Method Number Of Release() Is 3 In (IOleClientSite interface) InterfaceCall($pClientSite,"long",3) if ($hr[0] <> 0) Then return FALSE; EndIf $pUnk = $hr[8] Local $pObject,$IID_IOleObject = IIDFromString("{00000112-0000-0000-C000-000000000046}") ;hr = pUnk->QueryInterface(IID_IOleObject, (void**)&pObject); ;New pUnk (IOleObject) interface inherits from the IUnknown Or IOleObject : public IUnknown ;QueryInterface() Virtual Method Number Of QueryInterface() Is 1 In (IOleObject) $hr = InterfaceCall($pUnk,"long",1,"ptr",DllStructGetPtr($IID_IOleObject),"ptr*",0) ;Release() Virtual Method Number Of Release() Is 3 In (IOleObject interface) ;pUnk->Release(); InterfaceCall($pUnk,"long",3) if ($hr[0] <> 0) Then return FALSE; EndIf $pObject = $hr[2] DllCall("Ole32.dll","long","OleSetContainedObject","ptr",$pObject,"BOOL",True) $tagREOBJECT = "DWORD cbStruct;LONG cp;ulong Data1;ushort Data2;ushort Data3;byte Data4[8]" & _ ";ptr poleobj;ptr pstg;ptr polesite;long x;long y;DWORD dvaspect;DWORD dwFlags;DWORD dwUser" $reobject = DllStructCreate($tagREOBJECT) DllStructSetData($reobject,"cbStruct",DllStructGetSize($reobject)) ;hr = pObject->GetUserClassID(&clsid); ;GetUserClassID Virtual Method Number Of GetUserClassID Is 16 in (IOleObject interface) $hr = InterfaceCall($pObject,"long",16,"ptr",DllStructGetPtr($clsid)) if (@error Or $hr[0] <> 0) Then ;pObject->Release(); ;Release() Virtual Method Number Of Release() Is 3 In (IOleObject interface) InterfaceCall($pObject,"long",3) return FALSE EndIf MoveMemory(DllStructGetPtr($clsid),DllStructGetPtr($reobject) + 8,16) ;8 ==> SizeOf "DWORD cbStruct;LONG cp;" ;16 ==> sizeOf $clsid DllStructSetData($reobject,"cp",-1) DllStructSetData($reobject,"dvaspect",1) DllStructSetData($reobject,"dwFlags",BitOR(0x00000001,0x00000002)) DllStructSetData($reobject,"dwUser",0) DllStructSetData($reobject,"poleobj",$pObject) DllStructSetData($reobject,"polesite",$pClientSite) DllStructSetData($reobject,"pstg",$pStorage) $SIZEL = DllStructCreate("long;long"); DllStructSetData($reobject,"SIZEL",DllStructGetPtr($SIZEL)) _SendMessage($hRichEdit, 0xB1, 0, -1);EM_SETSEL $Rt = _SendMessage($hRichEdit, 0xB0,0,0,-1,"DWORD*","DWORD*");EM_GETSEL Local $dwStart = $Rt[3], $dwEnd = $Rt[4] _SendMessage($hRichEdit,0xB1, $dwEnd+1, $dwEnd+1);EM_SETSEL _SendMessage($hRichEdit, 0xC2, TRUE,@CRLF,0,"BOOL","wstr");EM_REPLACESEL ;hr = pRichEditOle->InsertObject(&reobject); ;InsertObject Virtual Method Number Of InsertObject Is 8 in (IRichEditOle interface) $hr = InterfaceCall($pRichEditOle,"long",8,"ptr",DllStructGetPtr($reobject)) ;pObject->Release(); ;Release() Virtual Method Number Of Release() Is 3 In (IOleObject interface) InterfaceCall($pObject,"long",3) ;pRichEditOle->Release(); ;Release() Virtual Method Number Of Release() Is 3 In (IRichEditOle interface) InterfaceCall($pRichEditOle,"long",3) if ($hr[0] <> 0) Then return FALSE; EndIf return TRUE; EndFunc Func MoveMemory($Source,$Destination,$Length) DllCall("Kernel32.dll","none","RtlMoveMemory","PTR",$Destination,"PTR",$Source,"INT",$Length) EndFunc
    1 point
  4. Loop example: #include <array.au3> #include <File.au3> DirCreate(@DesktopDir & "\Testing") For $i = 1 To 20 _FileCreate(@DesktopDir & "\Testing\File" & $i & ".txt") Next $aFiles = _FileListToArray(@DesktopDir & "\Testing") Local $aSorted[UBound($aFiles)-1][2] For $i = 1 To UBound($aFiles)-1 $aSorted[$i-1][0]=$aFiles[$i] $aSorted[$i-1][1]=Number(StringRegExpReplace($aFiles[$i],"[^\d]","")) Next ;~ _ArrayDisplay($aSorted) _ArraySort($aSorted,0,0,0,1) ;~ _ArrayDisplay($aSorted) _FileCreate("names.txt") For $i = 0 To UBound($aSorted)-1 FileWrite("names.txt", $aSorted[$i][0] & "/") Next output would be: File1.txt/File2.txt/File3.txt/File4.txt/File5.txt/File6.txt/File7.txt/File8.txt/File9.txt/File10.txt/File11.txt/File12.txt/File13.txt/File14.txt/File15.txt/File16.txt/File17.txt/File18.txt/File19.txt/File20.txt/
    1 point
  5. Something like this? #include <array.au3> #include <File.au3> DirCreate(@DesktopDir & "\Testing") For $i = 1 To 20 _FileCreate(@DesktopDir & "\Testing\File" & $i & ".txt") Next $aFiles = _FileListToArray(@DesktopDir & "\Testing") Local $aSorted[UBound($aFiles)-1][2] For $i = 1 To UBound($aFiles)-1 $aSorted[$i-1][0]=$aFiles[$i] $aSorted[$i-1][1]=Number(StringRegExpReplace($aFiles[$i],"[^\d]","")) Next _ArraySort($aSorted,0,0,0,1) _ArrayDisplay($aSorted) output: [0]|File1.txt|1 [1]|File2.txt|2 [2]|File3.txt|3 [3]|File4.txt|4 [4]|File5.txt|5 [5]|File6.txt|6 [6]|File7.txt|7 [7]|File8.txt|8 [8]|File9.txt|9 [9]|File10.txt|10 [10]|File11.txt|11 [11]|File12.txt|12 [12]|File13.txt|13 [13]|File14.txt|14 [14]|File15.txt|15 [15]|File16.txt|16 [16]|File17.txt|17 [17]|File18.txt|18 [18]|File19.txt|19 [19]|File20.txt|20 Then you can loop through the array to do the writes.
    1 point
  6. Try this: sURL = "http://page.you.are/on/" $oIE = _IECreate($sURL,1,1);try to attach = on, window is visible = on (for testing purposes) ;maybe this will work: Local $oInputs = _IETagNameGetCollection($oIE,"input") For $oInput In $oInputs If $oInput.className = "btn-apply3" Then _IEAction($oInput, "click") Next ;otherwise this: Local $oInputs = _IETagNameGetCollection($oIE,"input") For $oInput In $oInputs If $oInput.title = "Apply" Then _IEAction($oInput, "click") Next
    1 point
  7. Here's a clue, there is no such type as ERROR_SUCCESS in DllCall
    1 point
  8. Take it from me. I started using AutoIt about 6 months ago. The only thing I knew was a little QB and VB from college 10 years ago. I dabbled with the example scripts and looked through the forums here. I even drew out on paper what I wanted one of my scripts to do. Now I have one script that was approved for use here at work and I am working on another. They are nothing huge and extraordinary, but it is better than what we had before it went live. Read, read, read and give it a try. I did a lot of learning from making mistakes with the code. Don't be afraid to ask questions. I have asked some (what I thought was really stupid) questions here and I have gotten nothing but loads of help.
    1 point
  9. Melba23

    Date.au3

    jaberwacky, Do not get too fixated on them. As GEOSoft told me when I started learning about SREs, one of the major things to learn about RegExes is when NOT to use them. M23
    1 point
  10. FaridAgl

    OOP or functional.

    I don't like to say this, but I have to. I hope it never get fixed!
    1 point
  11. sudeepa, I would subtract 10 from the y coordinate ($test[1] - 10) and use MouseClick directly. Could I recommend looking through the Help file for useful function before posting in future - it might save you a lot of time. M23
    1 point
  12. also, change While $a = 10 in While $a < 10
    1 point
  13. Starstar

    Error function RegWrite

    First Convert your script in EXE then run it as administrator.Your problem will be solved.
    1 point
  14. likevvii, Look at For...To...Step...Next in the Help file. M23
    1 point
  15. sudeepa, Try ControlGetPos to get its coordinates followed by MouseMove to move the mouse to that position. But there might be easier ways - what is this app that you are automating? M23
    1 point
  16. Is that one haiku or two? Try posting a good description in your own language. Looks like you are using Google Translate or similar which ruins your semantic.
    1 point
  17. Nothing too complicate ! Try like that : #include <String.au3> #include <Array.au3> #include "WinHttp.au3" Global $aLinks[1], $iTimeOut = 1000 Global $sTempDir = @TempDir & '\AutID' Global $sMp3iliSrc = _FileGenerateRandomName ( $sTempDir, 'src' ), $hDownload6, $smp3iliUrl _Mp3Search_Mp3ili ( "the beatles" ) _ArrayDisplay($aLinks) Func _Mp3Search_Mp3ili ( $sQuery ) $sQuery = StringLower ( StringReplace ( $sQuery, ' ', '%20' ) ) Local $sSourceCode, $aStringBetween, $sDownloadUrl, $aTitle, $sTitle, $sDuration, $aStringSplit, $iDuration Local $smp3iliUrl = 'http://mp3ili.net/skachat/' & $sQuery If Not FileExists ( $sTempDir ) Then DirCreate ( $sTempDir ) Local $hGetSourceCode_TimerInit = TimerInit ( ) $hDownload6 = InetGet ( $smp3iliUrl, $sMp3iliSrc, 1+2+8, 1 ) Do If TimerDiff ( $hGetSourceCode_TimerInit ) > 7000 Then ; if server is overloaded InetClose ( $hDownload6 ) ExitLoop EndIf Until InetGetInfo ( $hDownload6, 2 ) $sSourceCode = FileRead ( $sMp3iliSrc ) FileDelete ( $sMp3iliSrc ) $aStringBetween = _StringBetween ( $sSourceCode, '<noindex><a href="', '<div style="h' ) If Not @error Then For $i = 0 To UBound ( $aStringBetween ) -1 $sDownloadUrl = StringMid ( $aStringBetween[$i], 1, StringInStr ( $aStringBetween[$i], '"' )-1 ) If Not _AlreadyInArray ( $aLinks, $sDownloadUrl, 1, 1 ) Then $aTitle = _StringBetween ( $aStringBetween[$i], 'title="', '"><img' ) If Not @error Then $sTitle = _StringProper ( StringStripWS ( StringRegExpReplace ( _StringClean ( $aTitle[0] ), '(?i)[^a-z0-9]', ' ' ), 7 ) ) ConsoleWrite ( '+->-- [' & StringFormat ( '%03i', @ScriptLineNumber ) & '][' & @HOUR & @MIN & @SEC & '] Title : ' & $sTitle & @Crlf ) If StringLen ( $sTitle ) > 3 Then $sTitle = _StringRemoveDigitsFromStart ( $sTitle ) $sTitle = _StringRemoveFromStart ( $sTitle, '-' ) $sDuration = StringMid ( $aStringBetween[$i], StringInStr ( $aStringBetween[$i], '(', 0, -1 )+1, StringInStr ( $aStringBetween[$i], ')', 0, -1 )-StringInStr ( $aStringBetween[$i], '(', 0, -1 )-1 ) $aStringSplit = StringSplit ( $sDuration, ':', 1+2 ) If Not @error Then $iDuration = $aStringSplit[0]*60 + $aStringSplit[1] ConsoleWrite ( '-->-- [' & StringFormat ( '%03i', @ScriptLineNumber ) & '][' & @HOUR & @MIN & @SEC & '] Duration : ' & $iDuration & @Crlf ) $iSizeEx = _WinHttpGetFileSize ( $sDownloadUrl ) ConsoleWrite ( '+->-- [' & StringFormat ( '%03i', @ScriptLineNumber ) & '][' & @HOUR & @MIN & @SEC & '] Size : ' & $iSizeEx & @Crlf ) If $iSizeEx > 1048576 Then $iBitRate = _FileGetBitRate ( $iSizeEx, $iDuration ) ConsoleWrite ( '-->-- [' & StringFormat ( '%03i', @ScriptLineNumber ) & '][' & @HOUR & @MIN & @SEC & '] BitRate : ' & $iBitRate & @Crlf ) If $iBitRate > 95 Then _ArrayAdd ( $aLinks, $sDownloadUrl ) EndIf EndIf EndIf EndIf EndIf Sleep ( 10 ) Next EndIf $hDownload6 = 0 EndFunc ;==> _Mp3Search_Mp3ili () Func _FileGetBitRate ( $iSize, $iDuration ) Local $iBitRate = $iSize/1024/$iDuration*8 Switch $iBitRate Case 65 To 96 $iBitRate = 96 Case 97 To 112 $iBitRate = 112 Case 113 To 128 $iBitRate = 128 Case 129 To 160 $iBitRate = 160 Case 161 To 192 $iBitRate = 192 Case 193 To 224 $iBitRate = 224 Case 225 To 256 $iBitRate = 256 Case 257 To 320 $iBitRate = 320 Case Else $iBitRate = 0 EndSwitch Return $iBitRate EndFunc ;==> _FileGetBitRate () Func _WinHttpGetFileSize ( $sDownloadFileUrl, $sCookie='' ) Local $sUserAgent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25 (compatible; Googlebot-Mobile/2.1; +http://www.google.com/bot.html)' Local $hOpen = _WinHttpOpen ( $sUserAgent ), $iFileSize Local $aCrackedUrl = _WinHttpCrackUrl ( $sDownloadFileUrl, $ICU_DECODE ) If Not @error Then Local $sHostName = $aCrackedUrl[2] _WinHttpSetTimeouts ( $hOpen, 0, $iTimeOut, $iTimeOut, $iTimeOut ) Local $hConnect = _WinHttpConnect ( $hOpen, $sHostName ) Local $sFileName = $aCrackedUrl[6] & $aCrackedUrl[7] Local $hRequest = _WinHttpOpenRequest ( $hConnect, 'GET', $sFileName, 'HTTP/1.1', $sHostName ) _WinHttpAddRequestHeaders ( $hRequest, 'Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/msword, */*' ) _WinHttpAddRequestHeaders ( $hRequest, 'Accept-Encoding: gzip, deflate' ) _WinHttpAddRequestHeaders ( $hRequest, 'Connection: Keep-Alive' ) If $sCookie <> '' Then _WinHttpAddRequestHeaders ( $hRequest, 'Cookie: ' & $sCookie ) _WinHttpSendRequest ( $hRequest ) _WinHttpReceiveResponse ( $hRequest ) If _WinHttpQueryDataAvailable ( $hRequest ) Then $iFileSize = _WinHttpQueryHeaders ( $hRequest, $WINHTTP_QUERY_CONTENT_LENGTH ) _WinHttpCloseHandle ( $hRequest ) _WinHttpCloseHandle ( $hConnect ) EndIf _WinHttpCloseHandle ( $hOpen ) Return $iFileSize EndFunc ;==> _WinHttpGetFileSize () Func _StringRemoveFromStart ( $sString, $sStringToRemove ) While StringLeft ( StringStripWS ( $sString, 7 ), 1 ) = $sStringToRemove $sString = StringTrimLeft ( $sString, 1 ) WEnd Return StringStripWS ( $sString, 7 ) EndFunc ;==> _StringRemoveFromStart () Func _StringRemoveDigitsFromStart ( $sString ) While StringIsDigit ( StringLeft ( StringStripWS ( $sString, 7 ), 1 ) ) $sString = StringTrimLeft ( $sString, 1 ) WEnd Return $sString EndFunc ;==> _StringRemoveDigitsFromStart () Func _StringReplaceHtmlSymbolEntities ( $sString ) Return StringRegExpReplace ( $sString, '&#([[:xdigit:]]+);', Execute ( Chrw ( '0x$1' ) ) ) EndFunc ;==> _StringReplaceHtmlSymbolEntities () Func _StringReplaceUnicodeChars ( $sString ) Return Execute ( '"' & StringRegexpReplace ( $sString, '(?i)\\U([[:xdigit:]]{2,4})', '"&chrw(0x$1)&"' ) & '"' ) EndFunc ;==> _StringReplaceUnicodeChars () Func _StringReplaceCyrillicChars ( $sString ) Return StringRegExpReplace ( $sString, '[^[:alnum:]\-\s\x{0400}-\x{04FF}]', '' ) EndFunc ;==> _StringReplaceCyrillicChars () Func _StringReplaceAccent ( $sString ) $sString = StringReplace ( $sString, '°', '°' ) $sString = StringReplace ( $sString, 'ç', 'c' ) $sString = StringReplace ( $sString, 'ß', 'ss' ) $sString = StringReplace ( $sString, "’", "'" ) $sString = StringReplace ( $sString, '€', '€' ) $sString = StringRegExpReplace ( $sString, '(Ú|ê|é|è|ë|«|©|ã©|ãš|ãª|ã¨|ã«|â«|â©|è|é|ê)', 'e' ) $sString = StringRegExpReplace ( $sString, '(ç|Ç)', 'c' ) $sString = StringRegExpReplace ( $sString, '(ÃŽ|ö|ó|ô|ãŽ|ã¶|ã³|ã´|ô)', 'o' ) $sString = StringRegExpReplace ( $sString, '(û|ü|ù|ÃŒ|ú|ã»|ã¼|ã¹|ãŒ|ãº|û|ù)', 'u' ) $sString = StringRegExpReplace ( $sString, '(ï|î|ã¯|ã®|î)', 'i' ) $sString = StringRegExpReplace ( $sString, '(à |â|ä|À|ã|á|Ã¥|ã |ã¢|ã¤|ã€|ã£|ã¡|ã¥|â|ÃÂ|ãƒâ)', 'a' ) $sString = StringReplace ( $sString, 'Ã', 'a' ) Local $aPattern[7][2] = [['[àáãâáäåÁÀÄÂÅœŒÆ]', 'a'], ['[éêèéëÉÈËÊ]', 'e'], ['[íîïìÍÌÏÎ]', 'i'], ['[óõôòöÓÒÖÔøØ]', 'o'], ['[úûùüÚÙÜÛ]', 'u'], ['[ýÿÝ]', 'y'], ['[çÇ]', 'c']] For $i = 0 To 6 $sString = StringRegExpReplace ( $sString, $aPattern[$i][0], $aPattern[$i][1] ) Next Return $sString EndFunc ;==> _StringReplaceAccent () Func _StringClean ( $sString ) $sString = StringRegExpReplace ( $sString, '%([[:xdigit:]]+)', Execute ( Chr ( '0x$1' ) ) ) $sString = StringReplace ( $sString, '&quot;', '"' ) $sString = StringReplace ( $sString, '&apos;', "'" ) $sString = StringReplace ( $sString, '&amp;', '&' ) $sString = StringReplace ( $sString, '&lt;', '<' ) $sString = StringReplace ( $sString, '&gt;', '>' ) $sString = _StringReplaceHtmlSymbolEntities ( $sString ) If StringRegexp ( $sString, '(?i)U([[:xdigit:]]{2,4})' ) Then $sString = StringReplace ( $sString, ' u', '\u' ) $sString = _StringReplaceUnicodeChars ( $sString ) EndIf $sString = StringReplace ( $sString, '-', 'IIIIIII' ) $sString = StringReplace ( $sString, "'", 'JJJJJJJ' ) $sString = StringStripWS ( StringReplace ( StringReplace ( $sString, 'IIIIIII', '-' ), 'JJJJJJJ', "'" ), 7 ) If StringRight ( $sString, 1 ) = '-' Then $sString = StringTrimRight ( $sString, 1 ) If StringLeft ( $sString, 1 ) = '-' Then $sString = StringTrimLeft ( $sString, 1 ) Do $sString = StringReplace ( $sString, "''", "'" ) Until Not @extended $sString = _StringRemoveDigitsFromStart ( $sString ) While StringLeft ( StringStripWS ( $sString, 7 ), 1 ) = '-' $sString = StringTrimLeft ( $sString, 1 ) WEnd $sString = _StringReplaceCyrillicChars ( $sString ) $sString = _StringReplaceAccent ( $sString ) If StringLeft ( StringStripWS ( $sString, 7 ), 1 ) = '-' Then Do $sString = StringTrimLeft ( StringStripWS ( $sString, 7 ), 1 ) Until StringLeft ( StringStripWS ( $sString, 7 ), 1 ) <> '-' EndIf If StringRight ( StringStripWS ( $sString, 7 ), 1 ) = '-' Then Do $sString = StringTrimRight ( StringStripWS ( $sString, 7 ), 1 ) Until StringRight ( StringStripWS ( $sString, 7 ), 1 ) <> '-' EndIf $sString = StringReplace ( $sString, ' cover', '' ) Return StringStripWS ( _StringReplaceUnWantedChars ( $sString ), 7 ) EndFunc ;==> _StringClean () Func _StringReplaceUnWantedChars ( $sString ) Return StringReplace ( StringRegExpReplace ( $sString, '[/:;.,_*?!"^`&~${}<>|#%]', ' ' ), '\', ' ' ) EndFunc ;==> _StringReplaceUnWantedChars () Func _AlreadyInArray ( $aSearch, $sItem, $iStart=0, $iPartial=0 ) Local $iIndex = _ArraySearch ( $aSearch, $sItem, $iStart, 0, 0, $iPartial ) If Not @error Then Return $iIndex EndFunc ;==> _AlreadyInArray () Func _FileGenerateRandomName ( $sDirectory, $sExt ) Do Local $sTempName = '~', $sTempPath While StringLen ( $sTempName ) < 12 $sTempName = $sTempName & Chr ( Round ( Random ( 97, 122 ), 0 ) ) Wend $sTempPath = $sDirectory & '\' & $sTempName & '.' & $sExt Until Not FileExists ( $sTempPath ) Return $sTempPath EndFunc ;==> _FileGenerateRandomName ()
    1 point
  18. You can't mark the parameter as a string. Strings are sent via handles and not as literal data. The value you are printing is just one part of a handle. Try using CHAR since that is valid in DllStructs. If that doesn't work, use BYTE and change the C function parameter type to unsigned char.
    1 point
  19. LarsJ, I have rewritten that event handling function (several times LOL), so your non-working example should look more like this: #include "CUIAutomation2.au3" Opt("MustDeclareVars", 1) Global Const $S_OK = 0x00000000 Global Const $E_NOINTERFACE = 0x80004002 Global Const $sIID_IUnknown = "{00000000-0000-0000-C000-000000000046}" Global $tIUIAutomationPropertyChangedEventHandler, $oIUIAutomationPropertyChangedEventHandler Global $oUIAutomation MainFunc() Func MainFunc() $oIUIAutomationPropertyChangedEventHandler = ObjectFromTag("oIUIAutomationPropertyChangedEventHandler_", $dtagIUIAutomationPropertyChangedEventHandler, $tIUIAutomationPropertyChangedEventHandler) If Not IsObj($oIUIAutomationPropertyChangedEventHandler) Then Return $oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation) If Not IsObj($oUIAutomation) Then Return Local $pUIElement $oUIAutomation.GetRootElement($pUIElement) ; Desktop If Not $pUIElement Then Return Local $tPropertyArray = DllStructCreate("int[2]") DllStructSetData($tPropertyArray, 1, $UIA_ValueValuePropertyId, 1) DllStructSetData($tPropertyArray, 1, $UIA_ToggleToggleStatePropertyId, 2) Local $x = $oUIAutomation.AddPropertyChangedEventHandlerNativeArray($pUIElement, $TreeScope_Descendants, 0, $oIUIAutomationPropertyChangedEventHandler, $tPropertyArray, 2) HotKeySet("{ESC}", "Quit") While Sleep(100) WEnd EndFunc ;==>MainFunc Func Quit() Exit EndFunc ;==>Quit Func _UIA_getPropertyValue($obj, $id) Local $vVal $obj.GetCurrentPropertyValue($id, $vVal) Return $vVal EndFunc Func oIUIAutomationPropertyChangedEventHandler_HandlePropertyChangedEvent($pSelf, $pSender, $iPropertyId, $newValue) ; Ret: long Par: ptr;int;variant ConsoleWrite(@CRLF & "oIUIAutomationPropertyChangedEventHandler_HandlePropertyChangedEvent: $iPropertyId = " & $iPropertyId & ", $newValue = " & $newValue & @CRLF) Local $oSender = ObjCreateInterface($pSender, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) $oSender.AddRef() ConsoleWrite("Handle " & _UIA_getPropertyValue($oSender, $UIA_NativeWindowHandlePropertyId) & @CRLF) ConsoleWrite("Name " & _UIA_getPropertyValue($oSender, $UIA_NamePropertyId) & @CRLF) ConsoleWrite("Class " & _UIA_getPropertyValue($oSender, $UIA_ClassNamePropertyId) & @CRLF) ConsoleWrite("Ctrl type " & _UIA_getPropertyValue($oSender, $UIA_ControlTypePropertyId) & @CRLF) ConsoleWrite("Ctrl name " & _UIA_getPropertyValue($oSender, $UIA_LocalizedControlTypePropertyId) & @CRLF) ConsoleWrite("Value " & _UIA_getPropertyValue($oSender, $UIA_LegacyIAccessibleValuePropertyId) & @CRLF) Return $S_OK EndFunc Func oIUIAutomationPropertyChangedEventHandler_QueryInterface($pSelf, $pRIID, $pObj) ; Ret: long Par: ptr;ptr* Local $sIID = StringFromGUID($pRIID) If $sIID = $sIID_IUnknown Then ConsoleWrite("oIUIAutomationPropertyChangedEventHandler_QueryInterface: IUnknown" & @CRLF) DllStructSetData(DllStructCreate("ptr", $pObj), 1, $pSelf) Return $S_OK ElseIf $sIID = $sIID_IUIAutomationPropertyChangedEventHandler Then ConsoleWrite("oIUIAutomationPropertyChangedEventHandler_QueryInterface: IUIAutomationPropertyChangedEventHandler" & @CRLF) DllStructSetData(DllStructCreate("ptr", $pObj), 1, $pSelf) Return $S_OK Else ConsoleWrite("oIUIAutomationPropertyChangedEventHandler_QueryInterface: " & $sIID & @CRLF) Return $E_NOINTERFACE EndIf EndFunc Func oIUIAutomationPropertyChangedEventHandler_AddRef($pSelf) ; Ret: ulong ConsoleWrite("oIUIAutomationPropertyChangedEventHandler_AddRef" & @CRLF) Return 1 EndFunc Func oIUIAutomationPropertyChangedEventHandler_Release($pSelf) ; Ret: ulong ConsoleWrite("oIUIAutomationPropertyChangedEventHandler_Release" & @CRLF) Return 1 EndFunc Func StringFromGUID($pGUID) Local $aResult = DllCall("ole32.dll", "int", "StringFromGUID2", "struct*", $pGUID, "wstr", "", "int", 40) If @error Then Return SetError(@error, @extended, "") Return SetExtended($aResult[0], $aResult[2]) EndFunc Func ObjectFromTag($sFunctionPrefix, $tagInterface, ByRef $tInterface, $bIsUnknown = Default, $sIID = "{00000000-0000-0000-C000-000000000046}") ; last param is IID_IUnknown by default If $bIsUnknown = Default Then $bIsUnknown = True Local $sInterface = $tagInterface ; copy interface description Local $tagIUnknown = "QueryInterface hresult(ptr;ptr*);" & _ "AddRef dword();" & _ "Release dword();" ; Adding IUnknown methods If $bIsUnknown Then $tagInterface = $tagIUnknown & $tagInterface ; Below line is really simple even though it looks super complex. It's just written weird to fit in one line, not to steal your attention Local $aMethods = StringSplit(StringReplace(StringReplace(StringReplace(StringReplace(StringTrimRight(StringReplace(StringRegExpReplace(StringRegExpReplace($tagInterface, "\w+\*", "ptr"), "\h*(\w+)\h*(\w+\*?)\h*(\((.*?)\))\h*(;|;*\z)", "$1\|$2;$4" & @LF), ";" & @LF, @LF), 1), "object", "idispatch"), "hresult", "long"), "bstr", "ptr"), "variant", "ptr"), @LF, 3) Local $iUbound = UBound($aMethods) Local $sMethod, $aSplit, $sNamePart, $aTagPart, $sTagPart, $sRet, $sParams, $hCallback ; Allocation $tInterface = DllStructCreate("int RefCount;int Size;ptr Object;ptr Methods[" & $iUbound & "];int_ptr Callbacks[" & $iUbound & "];ulong_ptr Slots[16]") ; 16 pointer sized elements more to create space for possible private props If @error Then Return SetError(1, 0, 0) For $i = 0 To $iUbound - 1 $aSplit = StringSplit($aMethods[$i], "|", 2) If UBound($aSplit) <> 2 Then ReDim $aSplit[2] $sNamePart = $aSplit[0] $sTagPart = $aSplit[1] $sMethod = $sFunctionPrefix & $sNamePart $aTagPart = StringSplit($sTagPart, ";", 2) $sRet = $aTagPart[0] $sParams = StringReplace($sTagPart, $sRet, "", 1) $sParams = "ptr" & $sParams $hCallback = DllCallbackRegister($sMethod, $sRet, $sParams) ConsoleWrite(@error & @CRLF) DllStructSetData($tInterface, "Methods", DllCallbackGetPtr($hCallback), $i + 1) ; save callback pointer DllStructSetData($tInterface, "Callbacks", $hCallback, $i + 1) ; save callback handle Next DllStructSetData($tInterface, "RefCount", 1) ; initial ref count is 1 DllStructSetData($tInterface, "Size", $iUbound) ; number of interface methods DllStructSetData($tInterface, "Object", DllStructGetPtr($tInterface, "Methods")) ; Interface method pointers Return ObjCreateInterface(DllStructGetPtr($tInterface, "Object"), $sIID, $sInterface, $bIsUnknown) ; pointer that's wrapped into object EndFunc Func DeleteObjectFromTag(ByRef $tInterface) For $i = 1 To DllStructGetData($tInterface, "Size") DllCallbackFree(DllStructGetData($tInterface, "Callbacks", $i)) Next $tInterface = 0 EndFunc ...That's almost exact replica of c++ dll code you posted.
    1 point
  20. id="discussion-type-job" and the radio group is name="forumtype" should look something like this: _IEFormElementRadioSelect($oForm, "Job", "forumtype", 1, "byValue", 1)
    1 point
  21. you could try with WinKill While 1 If WinExists("Windows Security") Then WinKill("Windows Security") ; WinSetState("Windows Security", "", @SW_SHOW) ; WinActivate("Windows Security") ; WinWaitActive("Windows Security", "", 30) ; ControlClick("Windows Security", "", "Cancel") Exit EndIf Sleep(1000) WEnd .. good luck... bye edit: link
    1 point
  22. Clark, I have been playing with the icon problem all day and I have got a solution of sorts - but it is horribly complex and would require a huge amount of work to make it compatible with the possibility of icons in any subitem and even more to get it into a usable format to integrate it into the UDF. So reluctantly I have decided that it is a step too far and I will not be adding this functionality to the UDF. I have also been trying to combine the UDF with the _GUICtrlListView_RegisterSortCallBack function which does sort the icons as shown in the help file example - but there is obviously some conflict here as the two do not play at all nicely together. I will keep prodding at this solution - but I fear that once again getting everything into the UDF is likely to be more work that I am prepared to put in. Sorry for such a negative reply - but as MeatLoaf used to sing 2 out 3 ain't bad. M23
    1 point
  23. I explicitly disallowed that back then in hope someone would ask for it in future. (It should have been nice game that I never got to play.) Yes, it's possible. Make feature request and see what Jon says. This isn't just syntactic sugar, being able to omit second argument makes valuable difference. For example here: $c = $a ? $a : $b ... $a is evaluated twice, whereas here: $c = $a ?: $b ...only once. At first you may not realize the quality of the difference, until you gear-up and imagine what would happen if $a isn't simple variable but, for example function call. In former case, that function would possibly be called twice based on it's return. All in all, it would make nice addition to the feature
    1 point
  24. guinness

    Mouseclick

    Correct answer, learn to walk before you take on that marathon.
    1 point
  25. czardas

    HTML editor

    Probably because you're all too lazy to read the whole thread.
    1 point
  26. _GUIImageList_Create + _GUIImageList_AddIcon example
    1 point
×
×
  • Create New...