.net dll in Autoit verwenden

  • Ich möchte gerne fragen, ob mir jemand erklären kann, wie ich eine Java Dll verwende, falls es überhaupt geht, da Java ja objektorientiert ist.
    Die Dll ist von der Seite:
    http://epubreader.codeplex.com/
    (opensource)

    Ich möchte dabei gerne die Dll verwenden, um einen eigenen E-Pub Reader zu erstellen.
    Ich hab mich schon mit dem Aufbau von E-Pubs auseinandergesetzt. Einzelne E-Pubs bekomme ich auch schon geöffnet, allerdings nur ohne Menü, ...
    Der Aufbau der Epubs ist allerdings recht variable, weshalb meine Funktion nur bedingt funktioniert. Deshalb wollte ich auf die Dll zurückgreifen.

    Wie ich es bisher gemacht habe (vielleicht hat jemand eine Idee, wie es besser ginge (RegExp)):

    Spoiler anzeigen
    [autoit]

    #include <array.au3>
    #include <GUIConstantsEx.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <File.au3>
    #include <String.au3>
    #include <IE.au3>
    #include "_XMLDomWrapper.au3"
    Opt("GUIOnEventMode", 1)

    [/autoit] [autoit][/autoit] [autoit]

    global $ReadGui,$ReadObj,$IE,$GlobalReadPath,$ReadObj2,$IE2
    Reader()
    _setData(FileOpenDialog("Wähle Epub",@DesktopDir,"epub (*.epub)",1,"",$ReadGui))
    GUISetOnEvent($GUI_EVENT_CLOSE, "MainGui_Close")

    [/autoit] [autoit][/autoit] [autoit]

    while 1
    sleep(100)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func Reader()
    $ReadGui = GUICreate("Reader", 800, 600-25, 0, 0,$WS_CAPTION +$WS_SYSMENU+ $WS_SIZEBOX +$WS_MINIMIZEBOX+$WS_MAXIMIZEBOX)
    $IE = _IECreateEmbedded ()
    $IE2 = _IECreateEmbedded ()
    $ReadObj = GUICtrlCreateObj($IE,90, 10, 700, 560)
    GUICtrlSetResizing(-1,1)
    _IENavigate($IE, 'about:blank')
    $ReadObj2 = GUICtrlCreateObj($IE2,90, 10, 700, 560)
    GUICtrlSetResizing(-1,1)
    GUICtrlSetState($ReadObj2,@SW_HIDE)
    _IENavigate($IE2, 'about:blank')
    GUISetState(@SW_SHOW)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _setData($pfad)
    local $spinesar[1],$manifestsar[1][3]
    _gibXmlData($manifestsar,$spinesar,$pfad,@ScriptDir&"\tempRead")
    ;_ArrayDisplay($spinesar)
    ;_ArrayDisplay($manifestsar)
    $toc=_ArraySearch($manifestsar,"toc.ncx",0,0,0,0,1,1)
    if $toc<>-1 then
    ;other captures
    $TocFile=FileRead($GlobalReadPath&""&$manifestsar[$toc][1])
    ClipPut($TocFile)
    $navsTmp=_StringBetween($TocFile,"<navPoint","</navPoint>")
    $pagesTmp=_StringBetween($TocFile,"<pageTarget","</pageTarget>")
    local $navs[UBound($navsTmp)][4]
    local $pages[UBound($pagesTmp)][4]
    for $i=0 to UBound($navsTmp)-1 step 1
    $navs[$i][0]=_StringBetween($navsTmp[$i],'playOrder="','"')[0]
    $navs[$i][1]=_StringBetween($navsTmp[$i],'<text>','</text>')[0]
    $tmp=_StringBetween($navsTmp[$i],'src="','"')[0]
    if StringInStr($tmp,"#") then
    $ar=StringSplit($tmp,"#")
    $navs[$i][2]=$ar[1]
    $navs[$i][3]="#"&$ar[2]
    else
    $navs[$i][2]=$tmp
    $navs[$i][3]=""
    endif
    next
    for $i=0 to UBound($pagesTmp)-1 step 1
    $pages[$i][0]=_StringBetween($pagesTmp[$i],'playOrder="','"')[0]
    $pages[$i][1]=_StringBetween($pagesTmp[$i],'<content src="','"/>')[0]
    $tmp=$pages[$i][1]
    if StringInStr($tmp,"#") then
    $ar=StringSplit($tmp,"#")
    $pages[$i][2]=$ar[1]
    $pages[$i][3]=$ar[2]
    else
    $pages[$i][2]=$tmp
    $pages[$i][3]=""
    endif
    next
    else
    ;my captures
    endif
    _ArrayDisplay($navsTmp)
    _ArrayDisplay($navs)
    _ArrayDisplay($pagesTmp)
    _ArrayDisplay($pages)
    ;local $idxList[UBound($spinesar)]
    $data=""
    $head=""
    for $i=0 to UBound($spinesar)-1 step 1
    ;$idxList[$i]=_ArraySearch($manifestsar,$spinesar[$i],0,0,0,0,1,0)
    $idx=_ArraySearch($manifestsar,$spinesar[$i],0,0,0,0,1,0)
    $fileData=FileRead($GlobalReadPath&""&$manifestsar[$idx][1])
    $ar=stringsplit($manifestsar[$idx][1],"")
    $pfad=$ar[UBound($ar)-1]
    $betw=_StringBetween($fileData,"<body>","</body>")
    for $j=0 to ubound($betw)-1 step 1
    $data&=$betw[$j]
    next
    if $head="" then
    $ar=_StringBetween($fileData,"<head>","</head>")
    if $ar<>0 then
    $head=$ar[0]
    endif
    endif
    if $i<>UBound($spinesar)-1 then
    ;$data&='<div style="display:none">'&$pfad&'</div>'
    $data&='<div style="display:none">'&$pfad&'</div>'
    endif
    next
    $data="<html><head>"&$head&"</head><body>"&$data&"</body></html>"
    ClipPut($data)
    ;$data=StringLeft($data,1000)

    [/autoit] [autoit][/autoit] [autoit]

    ;_IENavigate($IE,"file:///" & $GlobalReadPath);_IENavigate($IE, @ScriptDir&"\Aakeson, Kim Fupz - Taeter wie wir\OEBPS\b9783423415538_000017.xhtml")
    ;msgbox(48,"",$GlobalReadPath&""&$manifestsar[9][1])
    ;msgbox(48,"",FileRead($GlobalReadPath&""&$manifestsar[9][1]))
    ;for $i=0 to UBound($manifestsar)-1 step 1
    ; $data&=FileRead($GlobalReadPath&""&$manifestsar[$i][1])
    ;next
    ;StringReplace($GlobalReadPath&""&$manifestsar[$toc][1],"","/")
    _IENavigate($IE,"file:///" &$GlobalReadPath&""&$manifestsar[$toc][1])
    ;_IEDocWriteHTML($IE,$data)
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _gibXmlData(ByRef $manifestAr,ByRef $SpineAr,$path,$MainPath)
    _7ZipProgress(@ScriptDir&"\7zG.exe",$path, $MainPath, false)
    $path=$MainPath&"\META-INF\container.xml"
    $file=FileOpen($path)
    $content=FileRead($file)
    FileClose($file)
    $sc1=StringSplit($content,'<rootfile full-path="',1)
    if $sc1[0]<2 then
    return -1
    else
    $sc1=StringSplit($sc1[2],'"',1)
    $sc1[1]=StringReplace($sc1[1],"/","")
    ;global Path
    $splittedPath=StringSplit($MainPath&""&$sc1[1],"")
    for $i=1 to UBound($splittedPath)-3 step 1
    $GlobalReadPath&=$splittedPath[$i]&""
    next
    $GlobalReadPath&=$splittedPath[UBound($splittedPath)-2]
    ;global path end
    $fileData=FileRead($MainPath&""&$sc1[1])
    $fileManifestData=_StringBetween($fileData,"<manifest","</manifest")
    $fileManifestData=_StringBetween($fileManifestData[0],"<item",">")
    local $fileManifestDataArray[UBound($fileManifestData)][3]
    for $i=0 to UBound($fileManifestData)-1 step 1
    $fileManifestDataArray[$i][0]=_StringBetween($fileManifestData[$i],'id="','"')[0]
    $fileManifestDataArray[$i][1]=_StringBetween($fileManifestData[$i],'href="','"')[0]
    $fileManifestDataArray[$i][2]=_StringBetween($fileManifestData[$i],'media-type="','"')[0]
    next
    $fileSpineData=_StringBetween($fileData,"<spine","</spine")
    $fileSpineData=_StringBetween($fileSpineData[0],"<itemref",">")
    for $i=0 to UBound($fileSpineData)-1 step 1
    $fileSpineData[$i]=_StringBetween($fileSpineData[$i],'idref="','"')[0]
    next
    ReDim $manifestAr[UBound($fileManifestDataArray)][3]
    ReDim $SpineAr[UBound($fileSpineData)]
    for $i=0 to UBound($fileManifestDataArray)-1 step 1
    $manifestAr[$i][0]=$fileManifestDataArray[$i][0]
    $manifestAr[$i][1]=$fileManifestDataArray[$i][1]
    $manifestAr[$i][2]=$fileManifestDataArray[$i][2]
    next
    for $i=0 to UBound($fileSpineData)-1 step 1
    $SpineAr[$i]=$fileSpineData[$i]
    next
    endif
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func MainGui_Close()
    DirRemove (@ScriptDir&"\tempRead",1)
    exit
    EndFunc

    [/autoit] [autoit][/autoit] [autoit]

    Func _7ZipProgress($s7ZipEXE, $sSource, $sDestination = @TempDir, $fPack = True, $sPackType = '7z', $iPackLv = 5, $sAdditionalCommands = '', $sFuncToCall = '', $iMinPercentage = 0, $iMaxPercentage = 100, $iUpdateRate = 50)
    Local $sCommand, $iSize, $hTimeBefore, $iPID, $aProcessStats, $iPercentage
    If Not FileExists($s7ZipEXE) Or Not FileExists($sSource) Or $sDestination = '' Then
    Return SetError(1, Default, 0)
    EndIf
    If $iPackLv < 1 Or $iPackLv > 9 Or Not StringRegExp($sPackType, '7z|zip|wim|tar') Then
    Return SetError(2, Default, 0)
    EndIf
    If $sAdditionalCommands <> '' Then
    $sAdditionalCommands = ' ' & $sAdditionalCommands
    EndIf
    If $fPack Then
    $sCommand = ' a "' & $sDestination & '" "' & $sSource & '" -t' & $sPackType & ' -mx=' & $iPackLv & $sAdditionalCommands
    Else
    $sCommand = ' x -o"' & $sDestination & '" "' & $sSource & '"' & $sAdditionalCommands
    EndIf
    If StringInStr(FileGetAttrib($sSource), 'D') Then
    $iSize = DirGetSize($sSource)
    Else
    $iSize = FileGetSize($sSource)
    EndIf
    $hTimeBefore = TimerInit()
    $iPID = Run($s7ZipEXE & ' ' & $sCommand, @TempDir, @SW_HIDE)
    While ProcessExists($iPID)
    $aProcessStats = ProcessGetStats($iPID, 1)
    If $aProcessStats = 0 Then
    SetError(3, Default, 0)
    EndIf
    Sleep($iUpdateRate)
    WEnd
    Return SetExtended(TimerDiff($hTimeBefore), $s7ZipEXE & ' ' & $sCommand)
    EndFunc

    [/autoit]
  • Was ist denn eine Java-DLL? :huh:


    • Java ist von Haus aus nicht für die Verwendung von Microsofts Dynamic Link Libraries vorgesehen. Das, was von vielen Java-Programmierern immer an ihrer Sprache angepriesen wird, ist die Plattformunabhängigkeit (andere Diskussions-Baustelle), welche aber mit einer Bindung an Windows NT deutlich leiden würde. Deswegen kann Java zwar prinzipiell - wenn auch umständlich - mit DLLs umgehen, aber gewiss nicht selber welche erzeugen.

    • Zitat von der oben verlinkten Seite: "The library written in C# 4.0"
      C# ist ganz gewiss nicht Java ! ! !
      In C# ist es nebenbei auch möglich, DLLs zu erstellen.

    • Klick mich!
      Eventuell hilft dir das weiter, ich habe es selbst noch nie getestet.

    Gruß

    • Offizieller Beitrag

    Hey,

    Ich weiß auch gar nicht wie du auf Java kommst :D Sogar das Tut ist in c# geschrieben. Da Dies aber eine DotNet DLL ist und AutoIt damit nicht umgehen kann, musst du dir wohl eine andere DLL suchen.

    Und zum tollen Plattformunabhängingen Programmieren fällt mir immer folgendes Zitat ein ;)

    Zitat

    Saying that Java is good because it works on all platforms is like saying anal sex is good because it works on all genders.

    Gruß,
    Spider

  • So. Hab jetzt versucht, die erste Möglichkeit umzusetzen, scheitere jedoch daran, dass ich mehrere .cs dateien habe, sodass ich nicht weiß, welche ich verwenden muss.
    Ein weiteres problem wäre, dass ich mich noch nicht mit DLLCall() auseinandergesetzt habe. Aber da kann ich mich dann hoffentlich durchschlagen :)

    Könnte mir jemand helfen, die Bibliotheksdatei zu erstellen? Eventuell auch, wie sie verwendet wird?
    (Im Anhang befinden sich alle Dateien, die dafür benötigt werden)