- Offizieller Beitrag
Hey,
Bin gerade dabei dieses COM Objekt in AutoIt zu implementieren:
http://www.codeproject.com/Articles/1384/…tor-OCX-Control
Laut Dokumentation wird das Control mit SetData gefüttert.
ZitatAlles anzeigenSCODE SetData(VARIANT* pData, long dwStartAddr)
Transfer data to editing.
Parameters:
pData - Contains one-dimensional SAFEARRAY of bytes (i.e. pData->vt == VT_ARRAY | VT_UI1)
dwStartAddr - Starting address value in the 'address field'. Irrespective of dwStartAddr, the data is displayed from the array's beginning.
An example of call using MFC:
COleSafeArray arr;
BYTE pbData[200] = { 1, 2, 3, 4, 5 };
arr.CreateOneDim ( VT_UI1, sizeof(pbData), pbData );
(or arr.CreateOneDim ( VT_UI1, length ) for a non-initialized array)
m_ctlHexEdit.SetData ( arr );
The modified data exists in the same array, but its length may be modified in process of editing.
Leider habe ich so gar keine Ahnung wie man ein VT_VARAINT bzw ein VT_ARRAY in AutoIt umsetzt. Ein wenig am googlen hab ich dann im Code von AutoIt Object folgende Zeilen gefunden:
[autoit]$__Au3Obj_VT_ARRAY = 0x2000
;...
Global Const $__Au3Obj_tagVARIANT = "word vt;word r1;word r2;word r3;ptr data; ptr"
Ferner habe ich auch herausgefunden was ein ARRAY/SAFEARRAY ist.
http://msdn.microsoft.com/en-us/library/…2(v=vs.85).aspx
Also habe ich folgendes ausprobiert:
Spoiler anzeigen
Opt("GUIOnEventMode", 1)
Global Const $__Au3Obj_VT_ARRAY = 0x2000
Global Const $__Au3Obj_VT_SAFEARRAY = 27
Global Const $__Au3Obj_tagVARIANT = "word vt;word r1;word r2;word r3;ptr data; ptr"
Global Const $__Au3Obj_tagSAFEARRAY = "ushort cDims;ushort fFeatures; ulong cbElements; ulong cLocks; ptr pvData;int rgsabound"
Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")
Global $oHEX = ObjCreate("HEXEDIT.HexEditCtrl.1")
Global $tVARIANT = DllStructCreate($__Au3Obj_tagVARIANT)
Global $tSAFEARRAY = DllStructCreate($__Au3Obj_tagSAFEARRAY)
Global $tData = DllStructCreate("byte data[256]")
$tSAFEARRAY.cDims = 1
;~ $tSAFEARRAY.fFeatures = 0x0400;An array of IDispatch*.
$tSAFEARRAY.fFeatures = 0x0800;An array of VARIANTs
$tSAFEARRAY.cbElements = 5;
$tData.data = "12345"
$tSAFEARRAY.pvData = DllStructGetPtr($tData)
GUICreate("..")
GUISetOnEvent(-3, "_exit")
GUICtrlCreateObj($oHEX, 8, 8, 400 - 16, 400 - 16)
GUISetState()
$tVARIANT.vt = $__Au3Obj_VT_SAFEARRAY
$tVARIANT.data = DllStructGetPtr($tSAFEARRAY)
$oHEX.ShowAscii = True;Funktioniert
$oHEX.SetData(DllStructGetPtr($tVARIANT), 0);Funktioniert nicht. 0 ist das Startbyte
#cs
;Fehlerausgabe:
wg.au3 (36) : ==> COM Error intercepted !
err.number is: 0x80020005
err.windescription: Typenkonflikt.
err.description is:
err.source is:
err.helpfile is:
err.helpcontext is:
err.lastdllerror is: 0
err.scriptline is: 36
err.retcode is: 0x00000000
#ce
While 1
Sleep(100)
WEnd
Func _exit()
Exit
EndFunc ;==>_exit
; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
; Do anything here.
ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
@TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
@TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
@TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
@TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
@TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
@TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
@TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
@TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
@TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
EndFunc ;==>_ErrFunc
Leider gibt mir das nur den Fehler "Typkonflikt" aus. Weiß jemand wie ich ein VT_ARRAY in AutoIt hinbekommen, respektive was genau das überhaupt ist?
Lieben Gruß und danke schon mal,
Spider