1. Dashboard
  2. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
    3. Team
    4. Mitgliedersuche
  3. Forenregeln
  4. Forum
    1. Unerledigte Themen
  • Anmelden
  • Registrieren
  • Suche
Alles
  • Alles
  • Artikel
  • Seiten
  • Forum
  • Erweiterte Suche
  1. AutoIt.de - Das deutschsprachige Forum.
  2. Mitglieder
  3. Diggidie

Beiträge von Diggidie

  • StdoutRead und DirCreate

    • Diggidie
    • 11. Dezember 2022 um 21:18

    Problem gelöst :rock:

    Die Zeilenumbrüche waren es:

    StringStripCR ($adbSerialNumber) hatte nicht funktioniert.

    Also hab ich den Weg über StringReplace versucht:

    StringReplace ($adbSerialNumber, @CRLF, "") - ging nicht

    StringReplace ($adbSerialNumber, @CR, "") - ging auch nicht

    StringReplace ($adbSerialNumber, @LF, "") - und siehe da, es funktioniert, Verzeichnis wurde erstellt


    Danke BugFix für den Stoß in die richtige Richtung.

    MfG Diggidie

  • StdoutRead und DirCreate

    • Diggidie
    • 11. Dezember 2022 um 20:09

    Hallo BugFix

    Die Seriennummer besteht nur aus Großbuchstaben und Zahlen und händisch einen Ordner mit

    der Seriennummer geht auch ohne weiteres (SN-Bsp: G0213H07240507A8)

    Habe mal

    $adbSerialNumber = StringStripCR($adbSerialNumber)

    vor dem DirCreate eingefügt

    Das Ergebnis ist wie zuvor, leider auch keinen Erfolg

  • StdoutRead und DirCreate

    • Diggidie
    • 11. Dezember 2022 um 19:37

    Einen wunderschönen guten Abend

    Ich habe ein Problem und bin grad total ratlos.

    Ich habe mehrere FireTV Sticks und würde mir gern Backups einiger Daten auf meinem Laptop speichern.

    Dazu soll ein Verzeichnis erstellt werden, welches die 16stellige Seriennummer des jeweiligen Sticks sein soll.

    Das Auslesen der Seriennummer mit adb klappt wunderbar, allerdings kann ich kein Directory mit dem

    zurückgegebenen String der Seriennummer erstellen, das schreiben der Seriennummer in ein Textfile

    allerdings klappt tadellos.


    Hier mal ein Example der Funktion:

    Code
    #include <AutoItConstants.au3>
    
    _Example()
    
    Func _Example()
        $adbPID = Run ('adb.exe shell getprop ro.serialno', '', @SW_HIDE, $STDOUT_CHILD)
        ProcessWaitClose ($adbPID)
        $adbSerialNumber = StdoutRead ($adbPID)
        MsgBox (0, '', $adbSerialNumber)
        DirCreate (@ScriptDir & '\myAFTVs\' & $adbSerialNumber)
    EndFunc
    Alles anzeigen

    In der MsgBox wird die korrekte Seriennummer angezeigt, aber beim erstellen des Directories wird das Verzeichnis

    aus dem String mit der Seriennummer nicht erstellt, wohl aber das myAFTVs Verzeichnis!?

    Wäre für jede Hilfe dankbar

    MfG Diggidie

  • Arbeitsbereich (Client Area) Problem mit GuiCreate

    • Diggidie
    • 26. November 2013 um 12:50

    Schön finde ich das mit dem WinMove nicht gerade, aber funktioniert bei mir...
    Wäre jetzt noch schön zu erfahren, ob es auch bei Usern mit geändertem
    Windows-Designs einwandfrei funktioniert!? Bitte um Rückmeldungen...

    [autoit]

    #include <WindowsConstants.au3>

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

    $Gui = GUICreate("Test-Gui", 400, 200, -1, -1, $WS_SYSMENU + $WS_MINIMIZEBOX)
    $Client = WinGetClientSize("Test-Gui")
    MsgBox(0, "", "Arbeitsbereich vor WinMove = " & $Client[0] & " x " & $Client[1] & " Pixel")
    $Diff_H = 400 - $Client[0]
    $Diff_V = 200 - $Client[1]
    WinMove("Test-Gui","", -1, -1, 400 + $Diff_H, 200 + $Diff_V)
    $Client = WinGetClientSize("Test-Gui")
    MsgBox(0, "", "Arbeitsbereich nach WinMove = " & $Client[0] & " x " & $Client[1] & " Pixel")

    [/autoit]
  • Arbeitsbereich (Client Area) Problem mit GuiCreate

    • Diggidie
    • 26. November 2013 um 05:35

    Da ich vorher z.B. die Rahmenbreite des jeweiligen Windows-Designs nicht weiß,
    hilft mir WinMove auch nicht wirklich weiter...
    Bei meiner Standart Win 7 Design Einstellung ergibt sich immer eine Differenz von
    6 Pixeln in der Breite, wie auch in dem erwähnten Thread, und das, obwohl die Rahmenbreite
    auf einer Seite schon mehr als 6 Pixel hat ?(?(?(

  • Arbeitsbereich (Client Area) Problem mit GuiCreate

    • Diggidie
    • 26. November 2013 um 04:56

    Hallo Leute
    Ich habe folgendes Problem:

    Ich möchte in meiner Gui, mit Minimieren und Close Button, eine feste Größe im Client-Bereich haben...
    Wenn ich bei GuiCreate z.B. 400 x 200 eingebe, erhalte ich bei mir aber nur einen Arbeitsbereich
    von 394 x 172 (mit WinGetClientSize ausgelesen)

    [autoit]

    #include <WindowsConstants.au3>
    $Gui = GUICreate("Test-Gui", 400, 200, -1, -1, $WS_SYSMENU + $WS_MINIMIZEBOX)
    $Client = WinGetClientSize("Test-Gui")
    MsgBox(0, "", "Arbeitsbereich = " & $Client[0] & " x " & $Client[1] & " Pixel")

    [/autoit]


    Bin bei meiner Suche über diesen Uralt-Thread gestoßen:
    Verständnisproblem bei faktischer Breite einer GUI
    Der Thread hat mir aber keine Lösung näher gebracht, nur die Erkenntnis, das es mit den Rändern usw. zu tun hat...

    Wie kann ich nun, egal bei welchen Windows-Design-Einstellungen, oder wie auch immer, den Client-Bereich
    so einstellen, das er immer den von mir angegebenen Wert, hier also 400 x 200, erhält?

    MfG Diggidie

  • Möglichkeit gesucht, um VOR einer Datei zu schreiben...

    • Diggidie
    • 24. April 2013 um 01:07

    Überschreiben wäre ja kein Problem, wenn man den Pointer mit FileSetPos auf 0 setzt...
    Nur darf die 4GB Datei nicht verändert werden...
    Also bleibt wohl nur der Weg, die Datei komplett neu anzulegen...

  • Möglichkeit gesucht, um VOR einer Datei zu schreiben...

    • Diggidie
    • 24. April 2013 um 00:21

    Ich suche eine Möglichkeit ca. 1MB Daten VOR eine ca. 4GB großen Datei zu bekommen...

    Ich könnte zwar die 4GB mit FileOpen (DATEI, 1 + 16) neu an die 1MB anhängen, aber das
    dauert mir vieeeel zu lange und auf einem z.B. Usb Stick mit begrenztem Speicherplatz kaum realisierbar...

    Ist so etwas überhaupt möglich?

    MfG Diggidie

  • Netzwerk Problem

    • Diggidie
    • 18. April 2013 um 16:35

    @ _mk_ : funktioniert, glaube ich, nur auf dem eigenen Rechner im Netzwerk (andere konnte ich nicht ansprechen)...
    @ James1337 : FileSelectFolder und FileFindFirstFile sollten nur zur Veranschaulichung des Problems dienen...

    Aber das Problem scheint gelöst!? Auf jeden Fall kann ich jetzt alle relevante Daten beziehen...

    Schritt 1 - Ermitteln welche Computer/Server im Netzwerk vorhanden sind :

    Spoiler anzeigen
    [autoit]

    ;http://www.autoitscript.com/forum/topic/91…post__p__655253

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

    #include <Array.au3>
    Global Const $SV_TYPE_WORKSTATION = 0x1
    Global Const $SV_TYPE_SERVER = 0x2
    Global Const $SV_TYPE_SQLSERVER = 0x4
    Global Const $SV_TYPE_DOMAIN_CTRL = 0x8
    Global Const $SV_TYPE_DOMAIN_BAKCTRL = 0x10
    Global Const $SV_TYPE_TIME_SOURCE = 0x20
    Global Const $SV_TYPE_AFP = 0x40
    Global Const $SV_TYPE_NOVELL = 0x80
    Global Const $SV_TYPE_DOMAIN_MEMBER = 0x100
    Global Const $SV_TYPE_PRINTQ_SERVER = 0x200
    Global Const $SV_TYPE_DIALIN_SERVER = 0x400
    Global Const $SV_TYPE_XENIX_SERVER = 0x800
    Global Const $SV_TYPE_NT = 0x1000
    Global Const $SV_TYPE_WFW = 0x2000
    Global Const $SV_TYPE_SERVER_MFPN = 0x4000
    Global Const $SV_TYPE_SERVER_NT = 0x8000
    Global Const $SV_TYPE_POTENTIAL_BROWSER = 0x10000
    Global Const $SV_TYPE_BACKUP_BROWSER = 0x20000
    Global Const $SV_TYPE_MASTER_BROWSER = 0x40000
    Global Const $SV_TYPE_DOMAIN_MASTER = 0x80000
    Global Const $SV_TYPE_WINDOWS = 0x400000
    Global Const $SV_TYPE_CLUSTER_NT = 0x1000000
    Global Const $SV_TYPE_TERMINALSERVER = 0x2000000
    Global Const $SV_TYPE_CLUSTER_VS_NT = 0x4000000
    Global Const $SV_TYPE_LOCAL_LIST_ONLY = 0x40000000
    Global Const $SV_TYPE_DOMAIN_ENUM = 0x80000000
    Global Const $SV_TYPE_ALL = 0xFFFFFFFF

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

    $aCompList = _NetServerEnum($SV_TYPE_WORKSTATION)

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

    _ArrayDisplay($aCompList)

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

    Func _NetServerEnum ($iSrvType = -1, $sDomain = '')
    Local $uBufPtr = DllStructCreate("ptr;int;int"), $res[1]=[0], $i
    Local $uRecord = DllStructCreate("dword;ptr"), $iRecLen = DllStructGetSize($uRecord)
    Local $uString = DllStructCreate("char[16]")
    Local $uDomain = DllStructCreate("byte[32]"), $pDomain = 0
    If Not ($sDomain='' Or $sDomain='*') Then
    DllStructSetData($uDomain, 1, StringToBinary($sDomain,2))
    $pDomain = DllStructGetPtr($uDomain)
    EndIf
    Local $ret = DllCall ("netapi32.dll", "int", "NetServerEnum", _
    "ptr", 0, "int", 100, _
    "ptr", DllStructGetPtr($uBufPtr,1), "int", -1, _
    "ptr", DllStructGetPtr($uBufPtr,2), _
    "ptr", DllStructGetPtr($uBufPtr,3), _
    "int", $iSrvType, "ptr", $pDomain, "int", 0 )
    If $ret[0] Then Return SetError(1, $ret[0], '')
    Local $res[DllStructGetData($uBufPtr,3)+1]=[DllStructGetData($uBufPtr,3)]
    For $i=1 To DllStructGetData($uBufPtr,3)
    Local $uRecord = DllStructCreate("dword;ptr", DllStructGetData($uBufPtr,1)+($i-1)*$iRecLen)
    Local $sNBName = DllStructCreate("byte[32]", DllStructGetData($uRecord,2))
    DllStructSetData($uString,1,BinaryToString(DllStructGetData($sNBName,1),2))
    $res[$i] = DllStructGetData($uString,1)
    Next
    $ret = DllCall ("netapi32.dll", "int", "NetApiBufferFree", "ptr", DllStructGetData($uBufPtr,1))
    Return $res
    EndFunc

    [/autoit]


    Schritt 2 - Die Freigegebenen Laufwerke/Ordner ermittel: (Hier statt @ComputerName, einen aus $aCompList ausgelesenen Wert übergeben)

    Spoiler anzeigen
    [autoit]

    #include <NetShare.au3>
    #include <Array.au3>

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

    Local $sFoundDrive

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

    $aInfo = _Net_Share_ShareEnum (@ComputerName)

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

    For $i = 1 To $aInfo[0][0]
    If _Net_Share_ResourceStr ($aInfo[$i][1]) = "Disk drive" Then $sFoundDrive &= $aInfo[$i][0] & "|"
    Next

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

    $aDrives = StringSplit(StringTrimRight($sFoundDrive, 1), "|")
    _ArrayDisplay($aDrives)

    [/autoit]

    Alles was danach als Ordner oder Dateien kommt, kann normal mit den File-Befehlen bearbeitet werden...

    Fall natürlich jemand einen besseren Weg hat, bitte her damit...

    MfG Diggidie

  • Netzwerk Problem

    • Diggidie
    • 18. April 2013 um 01:36

    Hallo @All...

    Ich habe ein Problem beim ermitteln von Laufwerken??? bzw. Ordnern???
    und quäl mich schon den ganzen Abend damit herum...
    Auch meine intensive Suche hat mir, bis auf einen unbeantworteten Post
    von BugFix, nicht geholfen... Hier der Post von BugFix : Klick mich
    Aber das Script zeigt bei mir auch keine Ergebnisse...

    Was ich genau möchte? ich versuchs mal zu beschreiben:

    Wenn ich folgendes eingebe:

    [autoit]

    FileSelectFolder("", @LogonServer)

    [/autoit]


    wird mir ja das Netzwerk meines PC's geöffnet angezeigt, also z.B mit
    folgenden Laufwerken??? bzw. Ordnern???: Bilder, Musik, usw...

    [autoit]

    $find = FileFindFirstFile(@LogonServer & "\Bilder\*.*")

    [/autoit]


    gibt 1 zurück, also alles Ok, und ich könnte z,B. die Verzeichnisstruktur einlesen...

    [autoit]

    $find = FileFindFirstFile(@LogonServer & "\*.*")

    [/autoit]


    gibt aber -1 aus, aber GENAU diese Laufwerke??? Ordner??? brauche ich,
    weil ich ja nie weiß, welche Laufwerke??? Ordner??? bei anderen Usern vorhanden sind (am besten in einem Array)...

    Knapp: Ich brauche genau das, was unter dem geöffneten Netzwerk bei FileSelectFolder steht in einem Array...

    Vielleicht hat BugFix ja trotz des unbeantworteten Post ne Lösung für mich...

    Vielen Dank schon mal im vorraus für Eure Lösungsvorschläge...

    MfG Diggidie

  • [Beispiel] Update 13.03.13 FTP-Downloader (rekursiv mit allen Unterverzeichnissen)

    • Diggidie
    • 13. März 2013 um 16:45

    Echt COOL und ein dickes DANKE dafür...

    Hab es gerade getestet und funktioniert...

    Was jedoch ein wenig irretierend ist, ist das "|0" hinter den Verzeichnisnamen, welches man
    im ArrayDisplay angezeigt bekommt, wenn $bFolders=False auf "True" gesetzt ist...

    Was natürlich auch noch sehr fein wäre, wenn man bei $bFolders noch die Möglichkeit hätte,
    nur Verzeichnisse ausgeben zu lassen...

    Meine Hoffnung besteht ja immer noch darin, das mal ein vernünftiger FTP-Explorer in AutoIt
    programmiert wird... habe bis jetzt leider keinen gefunden :( Falls jemand einen kennt, bitte
    raus mit der Sprache... Mir würde es ja schon reichen zu wissen, wie ich jetzt das erstellte
    Array in ein TreeView (mit Ansicht aller Verzeichnisse und Dateien) mit der entsprechenden
    Navigation einbauen kann, um dann mit Mausklick auf einer Datei, entsprechende Datei-Operationen
    ausführen zu können... z.B. Rename, Delete, Copy usw.

    Mfg Diggidie und nach mal Danke autoBert...

  • [Beispiel] Update 13.03.13 FTP-Downloader (rekursiv mit allen Unterverzeichnissen)

    • Diggidie
    • 13. März 2013 um 02:20

    @all, Sorry für's Ausgraben des etwas älteren Threads

    Hallo autoBert...

    Klasse Script, genau so etwas in der Art habe ich gesucht :)

    Eine Frage, bzw einen Erweiterungvorschlag, habe ich dennoch...
    Ist es evtl. noch machbar (bestimmt, nur hab ich da kein Plan von, und könnte es sehr gut gebrauchen)
    eine einstellbare Pfadtiefe (als z.B. "lese nur die ersten drei Ebenen ein") mit einzubauen?

    Mfg Diggidie

  • Hilfe bei GDIPlus gesucht

    • Diggidie
    • 9. Februar 2013 um 15:16

    Könntest Du mir zeigen, wie ich es in meinem Script einzubauen habe? Steige da nicht durch :(
    Lg Diggidie

  • Hilfe bei GDIPlus gesucht

    • Diggidie
    • 9. Februar 2013 um 14:50

    Möchte das Thema nochmal öffnen, weil ich noch eine weitere Funktion benötige, und ein
    neues Thema evtl. nicht angebracht wäre...

    Wie stelle ich es an, nachdem die Gui aufgebaut ist und die Grafik angezeigt wird, und
    ich dann mit dem Mauszeiger über die Grafik fahre, das die Grafik in doppelter Größe
    angezeigt wird???

    Kurz: Mauszeiger auf Grafik --> Grafik vergrößert sich --> Mauszeiger von Grafik --> Grafik verkleinert sich wieder
    (und da kommt bestimmt wieder GDIPlus ins Spiel, wo ich gar nicht durchsteige)

    Hier noch mal das Script und die Testdatei:
    (Der Anhang ist keine 7zip Datei, muß also nicht entpackt werden, upload wollte eine Dateiendung haben...
    Die angehängte Datei enthält nur 0x00'en und ein eingebettetes PNG-Bild, welches mit _HexRead ausgelesen wird...
    Kann gern mit einem Hex-Editor überprüft werden...)

    Spoiler anzeigen
    [autoit]

    #include <WinAPI.au3>
    #include <GUIConstantsEx.au3>
    #include <GDIPlus.au3>
    #include <Memory.au3>
    Global Const $IMAGE_BITMAP = 0
    Global Const $STM_SETIMAGE = 0x0172

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

    $PNG_Lesen = _HexRead (@ScriptDir & "\TestDatei.7z", 0x110A, 0x0165); 0x110A = Position des PNG, 0x0165 = Länge der PNG-Datei in der TestDatei.blabla

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

    $GUI = GUICreate("PNG", 160, 100)
    $ShowPNG = GUICtrlCreatePic ("", 48, 18)
    _Display_PNG ()
    GUISetState()

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

    do
    until GUIGetMsg() = $GUI_EVENT_CLOSE

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

    Func _Display_PNG ()
    _GDIPlus_Startup ()
    $PNG_from_Mem = Load_BMP_From_Mem($PNG_Lesen, True)
    _WinAPI_DeleteObject(GUICtrlSendMsg($ShowPNG, $STM_SETIMAGE, $IMAGE_BITMAP, $PNG_from_Mem))
    _GDIPlus_Shutdown ()
    EndFunc

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

    ;======================================================================================
    ; Function Name: Load_BMP_From_Mem
    ; Description: Loads an image which is saved as a binary string and converts it to a bitmap or hbitmap
    ;
    ; Parameters: $bImage: the binary string which contains any valid image which is supported by GDI+
    ; Optional: $hHBITMAP: if false a bitmap will be created, if true a hbitmap will be created
    ;
    ; Remark: hbitmap format is used generally for GUI internal images, $bitmap is more a GDI+ image format
    ; Don't forget _GDIPlus_Startup() and _GDIPlus_Shutdown()
    ;
    ; Requirement(s): GDIPlus.au3, Memory.au3 and _WinAPI_BitmapCreateDIBFromBitmap() from WinAPIEx.au3
    ; Return Value(s): Success: handle to bitmap (GDI+ bitmap format) or hbitmap (WinAPI bitmap format),
    ; Error: 0
    ; Error codes: 1: $bImage is not a binary string
    ; 2: unable to create stream on HGlobal
    ; 3: unable to create bitmap from stream
    ;
    ; Author(s): UEZ
    ; Additional Code: thanks to progandy for the MemGlobalAlloc and tVARIANT lines and
    ; Yashied for _WinAPI_BitmapCreateDIBFromBitmap() from WinAPIEx.au3
    ; Version: v0.98 Build 2012-08-29 Beta
    ;=======================================================================================
    Func Load_BMP_From_Mem($bImage, $hHBITMAP = False)
    If Not IsBinary($bImage) Then Return SetError(1, 0, 0)
    Local $aResult
    Local Const $memBitmap = Binary($bImage) ;load image saved in variable (memory) and convert it to binary
    Local Const $len = BinaryLen($memBitmap) ;get length of image
    Local Const $hData = _MemGlobalAlloc($len, $GMEM_MOVEABLE) ;allocates movable memory ($GMEM_MOVEABLE = 0x0002)
    Local Const $pData = _MemGlobalLock($hData) ;translate the handle into a pointer
    Local $tMem = DllStructCreate("byte[" & $len & "]", $pData) ;create struct
    DllStructSetData($tMem, 1, $memBitmap) ;fill struct with image data
    _MemGlobalUnlock($hData) ;decrements the lock count associated with a memory object that was allocated with GMEM_MOVEABLE
    $aResult = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $pData, "int", True, "ptr*", 0) ;Creates a stream object that uses an HGLOBAL memory handle to store the stream contents
    If @error Then Return SetError(2, 0, 0)
    Local Const $hStream = $aResult[3]
    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $hStream, "int*", 0) ;Creates a Bitmap object based on an IStream COM interface
    If @error Then Return SetError(3, 0, 0)
    Local Const $hBitmap = $aResult[2]
    Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr")
    DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $hStream, "dword", 8 + 8 * @AutoItX64, _
    "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT)) ;release memory from $hStream to avoid memory leak
    $tMem = 0
    $tVARIANT = 0
    If $hHBITMAP Then
    Local Const $hHBmp = _WinAPI_BitmapCreateDIBFromBitmap($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap)
    Return $hHBmp
    EndIf
    Return $hBitmap
    EndFunc ;==>Load_BMP_From_Mem

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

    Func _WinAPI_BitmapCreateDIBFromBitmap($hBitmap) ;create 32-bit bitmap v5 (alpha channel supported)
    Local $tBIHDR, $aRet, $tData, $pBits, $hResult = 0
    $aRet = DllCall($ghGDIPDll, 'uint', 'GdipGetImageDimension', 'ptr', $hBitmap, 'float*', 0, 'float*', 0)
    If (@error) Or ($aRet[0]) Then Return 0
    $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $aRet[2], $aRet[3], $GDIP_ILMREAD, $GDIP_PXF32ARGB)
    $pBits = DllStructGetData($tData, 'Scan0')
    If Not $pBits Then Return 0
    $tBIHDR = DllStructCreate( 'dword bV5Size;long bV5Width;long bV5Height;word bV5Planes;word bV5BitCount;dword bV5Compression;' & _ ;http://msdn.microsoft.com/en-us/library/…1(v=vs.85).aspx
    'dword bV5SizeImage;long bV5XPelsPerMeter;long bV5YPelsPerMeter;dword bV5ClrUsed;dword bV5ClrImportant;' & _
    'dword bV5RedMask;dword bV5GreenMask;dword bV5BlueMask;dword bV5AlphaMask;dword bV5CSType;' & _
    'int bV5Endpoints[3];dword bV5GammaRed;dword bV5GammaGreen;dword bV5GammaBlue;dword bV5Intent;' & _
    'dword bV5ProfileData;dword bV5ProfileSize;dword bV5Reserved')
    DllStructSetData($tBIHDR, 'bV5Size', DllStructGetSize($tBIHDR))
    DllStructSetData($tBIHDR, 'bV5Width', $aRet[2])
    DllStructSetData($tBIHDR, 'bV5Height', $aRet[3])
    DllStructSetData($tBIHDR, 'bV5Planes', 1)
    DllStructSetData($tBIHDR, 'bV5BitCount', 32)
    DllStructSetData($tBIHDR, 'bV5Compression', 0) ; $BI_BITFIELDS = 3, $BI_RGB = 0, $BI_RLE8 = 1, $BI_RLE4 = 2, $RGBA = 0x41424752
    DllStructSetData($tBIHDR, 'bV5SizeImage', $aRet[3] * DllStructGetData($tData, 'Stride'))
    DllStructSetData($tBIHDR, 'bV5AlphaMask', 0xFF000000)
    DllStructSetData($tBIHDR, 'bV5RedMask', 0x00FF0000)
    DllStructSetData($tBIHDR, 'bV5GreenMask', 0x0000FF00)
    DllStructSetData($tBIHDR, 'bV5BlueMask', 0x000000FF)
    DllStructSetData($tBIHDR, 'bV5CSType', 2) ; LCS_WINDOWS_COLOR_SPACE = 2
    DllStructSetData($tBIHDR, 'bV5Intent', 4) ; $LCS_GM_IMA
    $hResult = DllCall('gdi32.dll', 'ptr', 'CreateDIBSection', 'hwnd', 0, 'ptr', DllStructGetPtr($tBIHDR), 'uint', 0, 'ptr*', 0, 'ptr', 0, 'dword', 0)
    If (Not @error) And ($hResult[0]) Then
    DllCall('gdi32.dll', 'dword', 'SetBitmapBits', 'ptr', $hResult[0], 'dword', $aRet[2] * $aRet[3] * 4, 'ptr', DllStructGetData($tData, 'Scan0'))
    $hResult = $hResult[0]
    Else
    $hResult = 0
    EndIf
    _GDIPlus_BitmapUnlockBits($hBitmap, $tData)
    $tData = 0
    $tBIHDR = 0
    Return $hResult
    EndFunc ;==>_WinAPI_BitmapCreateDIBFromBitmap

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

    Func _HexRead($FilePath, $Offset, $Length)
    Local $Buffer, $ptr, $fLen, $hFile, $Result, $Read, $err, $Pos
    If Not FileExists($FilePath) Then Return SetError(1, @error, 0)
    $fLen = FileGetSize($FilePath)
    If $Offset > $fLen Then Return SetError(2, @error, 0)
    If $fLen < $Offset + $Length Then Return SetError(3, @error, 0)
    $Buffer = DllStructCreate("byte[" & $Length & "]")
    $ptr = DllStructGetPtr($Buffer)
    $hFile = _WinAPI_CreateFile($FilePath, 2, 2, 0)
    If $hFile = 0 Then Return SetError(5, @error, 0)
    $Pos = $Offset
    $Result = _WinAPI_SetFilePointer($hFile, $Pos)
    $err = @error
    If $Result = 0xFFFFFFFF Then
    _WinAPI_CloseHandle($hFile)
    Return SetError(6, $err, 0)
    EndIf
    $Read = 0
    $Result = _WinAPI_ReadFile($hFile, $ptr, $Length, $Read)
    $err = @error
    If Not $Result Then
    _WinAPI_CloseHandle($hFile)
    Return SetError(7, $err, 0)
    EndIf
    _WinAPI_CloseHandle($hFile)
    If Not $Result Then Return SetError(8, @error, 0)
    $Result = DllStructGetData($Buffer, 1)
    Return $Result
    EndFunc

    [/autoit]

    MfG Diggidie

    Dateien

    TestDatei.7z 5,93 kB – 375 Downloads
  • Hilfe bei GDIPlus gesucht

    • Diggidie
    • 5. Februar 2013 um 13:07
    Zitat von UEZ

    Die Datei im Anhang ist korrupt.

    Gruß,
    UEZ

    Hallo UEZ,

    die Datei ist nicht korrupt ;)
    Hatte extra unter dem Spoiler in Post 2 folgendes geschrieben:

    Der Anhang ist keine 7zip Datei, muß also nicht entpackt werden, upload wollte eine Dateiendung haben...

    Die angehängte Datei enthält nur 0x00'en und ein eingebettetes PNG-Bild, welches mit _HexRead ausgelesen wird...

    Kann gern mit einem Hex-Editor überprüft werden...

    MfG Diggidie

  • Hilfe bei GDIPlus gesucht

    • Diggidie
    • 5. Februar 2013 um 02:10

    Nochmals Danke UEZ (Sorry für's A statt dem E vorhin :whistling: )

    Dein erstes Beispiel hat mir die Lösung gebracht... :thumbup: (hoffe ich zumindest)

    Hier das fertige Beispiel, sollte so funktionieren... (Anhang aus Post 2 wird benötigt... )

    Spoiler anzeigen
    [autoit]

    #include <WinAPI.au3>
    #include <GUIConstantsEx.au3>
    #include <GDIPlus.au3>
    #include <Memory.au3>
    Global Const $IMAGE_BITMAP = 0
    Global Const $STM_SETIMAGE = 0x0172

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

    $PNG_Lesen = _HexRead (@ScriptDir & "\TestDatei.7z", 0x110A, 0x0165); 0x110A = Position des PNG, 0x0165 = Länge der PNG-Datei in der TestDatei.blabla

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

    $GUI = GUICreate("PNG", 160, 100)
    $ShowPNG = GUICtrlCreatePic ("", 48, 18)
    _Display_PNG ()
    GUISetState()

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

    do
    until GUIGetMsg() = $GUI_EVENT_CLOSE

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

    Func _Display_PNG ()
    _GDIPlus_Startup ()
    $PNG_from_Mem = Load_BMP_From_Mem($PNG_Lesen, True)
    _WinAPI_DeleteObject(GUICtrlSendMsg($ShowPNG, $STM_SETIMAGE, $IMAGE_BITMAP, $PNG_from_Mem))
    _GDIPlus_Shutdown ()
    EndFunc

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

    ;======================================================================================
    ; Function Name: Load_BMP_From_Mem
    ; Description: Loads an image which is saved as a binary string and converts it to a bitmap or hbitmap
    ;
    ; Parameters: $bImage: the binary string which contains any valid image which is supported by GDI+
    ; Optional: $hHBITMAP: if false a bitmap will be created, if true a hbitmap will be created
    ;
    ; Remark: hbitmap format is used generally for GUI internal images, $bitmap is more a GDI+ image format
    ; Don't forget _GDIPlus_Startup() and _GDIPlus_Shutdown()
    ;
    ; Requirement(s): GDIPlus.au3, Memory.au3 and _WinAPI_BitmapCreateDIBFromBitmap() from WinAPIEx.au3
    ; Return Value(s): Success: handle to bitmap (GDI+ bitmap format) or hbitmap (WinAPI bitmap format),
    ; Error: 0
    ; Error codes: 1: $bImage is not a binary string
    ; 2: unable to create stream on HGlobal
    ; 3: unable to create bitmap from stream
    ;
    ; Author(s): UEZ
    ; Additional Code: thanks to progandy for the MemGlobalAlloc and tVARIANT lines and
    ; Yashied for _WinAPI_BitmapCreateDIBFromBitmap() from WinAPIEx.au3
    ; Version: v0.98 Build 2012-08-29 Beta
    ;=======================================================================================
    Func Load_BMP_From_Mem($bImage, $hHBITMAP = False)
    If Not IsBinary($bImage) Then Return SetError(1, 0, 0)
    Local $aResult
    Local Const $memBitmap = Binary($bImage) ;load image saved in variable (memory) and convert it to binary
    Local Const $len = BinaryLen($memBitmap) ;get length of image
    Local Const $hData = _MemGlobalAlloc($len, $GMEM_MOVEABLE) ;allocates movable memory ($GMEM_MOVEABLE = 0x0002)
    Local Const $pData = _MemGlobalLock($hData) ;translate the handle into a pointer
    Local $tMem = DllStructCreate("byte[" & $len & "]", $pData) ;create struct
    DllStructSetData($tMem, 1, $memBitmap) ;fill struct with image data
    _MemGlobalUnlock($hData) ;decrements the lock count associated with a memory object that was allocated with GMEM_MOVEABLE
    $aResult = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $pData, "int", True, "ptr*", 0) ;Creates a stream object that uses an HGLOBAL memory handle to store the stream contents
    If @error Then Return SetError(2, 0, 0)
    Local Const $hStream = $aResult[3]
    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $hStream, "int*", 0) ;Creates a Bitmap object based on an IStream COM interface
    If @error Then Return SetError(3, 0, 0)
    Local Const $hBitmap = $aResult[2]
    Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr")
    DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $hStream, "dword", 8 + 8 * @AutoItX64, _
    "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT)) ;release memory from $hStream to avoid memory leak
    $tMem = 0
    $tVARIANT = 0
    If $hHBITMAP Then
    Local Const $hHBmp = _WinAPI_BitmapCreateDIBFromBitmap($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap)
    Return $hHBmp
    EndIf
    Return $hBitmap
    EndFunc ;==>Load_BMP_From_Mem

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

    Func _WinAPI_BitmapCreateDIBFromBitmap($hBitmap) ;create 32-bit bitmap v5 (alpha channel supported)
    Local $tBIHDR, $aRet, $tData, $pBits, $hResult = 0
    $aRet = DllCall($ghGDIPDll, 'uint', 'GdipGetImageDimension', 'ptr', $hBitmap, 'float*', 0, 'float*', 0)
    If (@error) Or ($aRet[0]) Then Return 0
    $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $aRet[2], $aRet[3], $GDIP_ILMREAD, $GDIP_PXF32ARGB)
    $pBits = DllStructGetData($tData, 'Scan0')
    If Not $pBits Then Return 0
    $tBIHDR = DllStructCreate( 'dword bV5Size;long bV5Width;long bV5Height;word bV5Planes;word bV5BitCount;dword bV5Compression;' & _ ;http://msdn.microsoft.com/en-us/library/…1(v=vs.85).aspx
    'dword bV5SizeImage;long bV5XPelsPerMeter;long bV5YPelsPerMeter;dword bV5ClrUsed;dword bV5ClrImportant;' & _
    'dword bV5RedMask;dword bV5GreenMask;dword bV5BlueMask;dword bV5AlphaMask;dword bV5CSType;' & _
    'int bV5Endpoints[3];dword bV5GammaRed;dword bV5GammaGreen;dword bV5GammaBlue;dword bV5Intent;' & _
    'dword bV5ProfileData;dword bV5ProfileSize;dword bV5Reserved')
    DllStructSetData($tBIHDR, 'bV5Size', DllStructGetSize($tBIHDR))
    DllStructSetData($tBIHDR, 'bV5Width', $aRet[2])
    DllStructSetData($tBIHDR, 'bV5Height', $aRet[3])
    DllStructSetData($tBIHDR, 'bV5Planes', 1)
    DllStructSetData($tBIHDR, 'bV5BitCount', 32)
    DllStructSetData($tBIHDR, 'bV5Compression', 0) ; $BI_BITFIELDS = 3, $BI_RGB = 0, $BI_RLE8 = 1, $BI_RLE4 = 2, $RGBA = 0x41424752
    DllStructSetData($tBIHDR, 'bV5SizeImage', $aRet[3] * DllStructGetData($tData, 'Stride'))
    DllStructSetData($tBIHDR, 'bV5AlphaMask', 0xFF000000)
    DllStructSetData($tBIHDR, 'bV5RedMask', 0x00FF0000)
    DllStructSetData($tBIHDR, 'bV5GreenMask', 0x0000FF00)
    DllStructSetData($tBIHDR, 'bV5BlueMask', 0x000000FF)
    DllStructSetData($tBIHDR, 'bV5CSType', 2) ; LCS_WINDOWS_COLOR_SPACE = 2
    DllStructSetData($tBIHDR, 'bV5Intent', 4) ; $LCS_GM_IMA
    $hResult = DllCall('gdi32.dll', 'ptr', 'CreateDIBSection', 'hwnd', 0, 'ptr', DllStructGetPtr($tBIHDR), 'uint', 0, 'ptr*', 0, 'ptr', 0, 'dword', 0)
    If (Not @error) And ($hResult[0]) Then
    DllCall('gdi32.dll', 'dword', 'SetBitmapBits', 'ptr', $hResult[0], 'dword', $aRet[2] * $aRet[3] * 4, 'ptr', DllStructGetData($tData, 'Scan0'))
    $hResult = $hResult[0]
    Else
    $hResult = 0
    EndIf
    _GDIPlus_BitmapUnlockBits($hBitmap, $tData)
    $tData = 0
    $tBIHDR = 0
    Return $hResult
    EndFunc ;==>_WinAPI_BitmapCreateDIBFromBitmap

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

    Func _HexRead($FilePath, $Offset, $Length)
    Local $Buffer, $ptr, $fLen, $hFile, $Result, $Read, $err, $Pos
    If Not FileExists($FilePath) Then Return SetError(1, @error, 0)
    $fLen = FileGetSize($FilePath)
    If $Offset > $fLen Then Return SetError(2, @error, 0)
    If $fLen < $Offset + $Length Then Return SetError(3, @error, 0)
    $Buffer = DllStructCreate("byte[" & $Length & "]")
    $ptr = DllStructGetPtr($Buffer)
    $hFile = _WinAPI_CreateFile($FilePath, 2, 2, 0)
    If $hFile = 0 Then Return SetError(5, @error, 0)
    $Pos = $Offset
    $Result = _WinAPI_SetFilePointer($hFile, $Pos)
    $err = @error
    If $Result = 0xFFFFFFFF Then
    _WinAPI_CloseHandle($hFile)
    Return SetError(6, $err, 0)
    EndIf
    $Read = 0
    $Result = _WinAPI_ReadFile($hFile, $ptr, $Length, $Read)
    $err = @error
    If Not $Result Then
    _WinAPI_CloseHandle($hFile)
    Return SetError(7, $err, 0)
    EndIf
    _WinAPI_CloseHandle($hFile)
    If Not $Result Then Return SetError(8, @error, 0)
    $Result = DllStructGetData($Buffer, 1)
    Return $Result
    EndFunc

    [/autoit]

    MfG Diggidie

  • Hilfe bei GDIPlus gesucht

    • Diggidie
    • 4. Februar 2013 um 23:09

    Danke UAZ...
    Bekomme Dein Script zwar nicht zum laufen, aber beim durchsehen Deiner Source
    bin ich auf die "Load_BMP_From_Mem"-Funktion gestoßen :)
    Funktioniert, aber weiß nicht genau, ob das PNG nach dem anzeigen wieder
    aus dem Speicher gelöscht wird... (wie gesagt, kein Plan von GDIPlus)
    Könnte mir auch sehr gut vorstellen, das ich überflüssige Dinge mir eingebaut habe :(
    Könnte evtl. jemand das Script mal durchsehen und vielleicht auch dementsprechend anpassen?

    Hier das lauffähige Script, wo das PNG aus dem Speicher angezeigt wird, Anhang aus Post 2 wird benötigt...

    Spoiler anzeigen
    [autoit]

    #include <WinAPI.au3>
    #include <GUIConstantsEx.au3>
    #include <GDIPlus.au3>
    #include <Memory.au3>
    $PNG_Lesen = _HexRead (@ScriptDir & "\TestDatei.7z", 0x110A, 0x0165); 0x110A = Position des PNG, 0x0165 = Länge der PNG-Datei in der TestDatei.blabla

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

    $GUI = GUICreate("PNG", 160, 100)
    $ShowPNG = GUICtrlCreatePic ("", 48, 18)
    _Display_PNG ()
    GUISetState()

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

    do
    until GUIGetMsg() = $GUI_EVENT_CLOSE

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

    Func _Display_PNG ()
    Local Const $STM_SETIMAGE = 0x0172
    _GDIPlus_Startup ()
    $PNG_from_Mem = Load_BMP_From_Mem($PNG_Lesen)
    Local $ImageHandle = _GDIPlus_BitmapCreateHBITMAPFromBitmap ($PNG_from_Mem)
    GUICtrlSendMsg ($ShowPNG, $STM_SETIMAGE, 0, $ImageHandle)
    _WinAPI_DeleteObject ($ImageHandle)
    _GDIPlus_Shutdown ()
    EndFunc

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

    ;======================================================================================
    ; Function Name: Load_BMP_From_Mem
    ; Description: Loads an image which is saved as a binary string and converts it to a bitmap or hbitmap
    ;
    ; Parameters: $bImage: the binary string which contains any valid image which is supported by GDI+
    ; Optional: $hHBITMAP: if false a bitmap will be created, if true a hbitmap will be created
    ;
    ; Remark: hbitmap format is used generally for GUI internal images, $bitmap is more a GDI+ image format
    ; Don't forget _GDIPlus_Startup() and _GDIPlus_Shutdown()
    ;
    ; Requirement(s): GDIPlus.au3, Memory.au3 and _WinAPI_BitmapCreateDIBFromBitmap() from WinAPIEx.au3
    ; Return Value(s): Success: handle to bitmap (GDI+ bitmap format) or hbitmap (WinAPI bitmap format),
    ; Error: 0
    ; Error codes: 1: $bImage is not a binary string
    ; 2: unable to create stream on HGlobal
    ; 3: unable to create bitmap from stream
    ;
    ; Author(s): UEZ
    ; Additional Code: thanks to progandy for the MemGlobalAlloc and tVARIANT lines and
    ; Yashied for _WinAPI_BitmapCreateDIBFromBitmap() from WinAPIEx.au3
    ; Version: v0.98 Build 2012-08-29 Beta
    ;=======================================================================================
    Func Load_BMP_From_Mem($bImage, $hHBITMAP = False)
    If Not IsBinary($bImage) Then Return SetError(1, 0, 0)
    Local $aResult
    Local Const $memBitmap = Binary($bImage) ;load image saved in variable (memory) and convert it to binary
    Local Const $len = BinaryLen($memBitmap) ;get length of image
    Local Const $hData = _MemGlobalAlloc($len, $GMEM_MOVEABLE) ;allocates movable memory ($GMEM_MOVEABLE = 0x0002)
    Local Const $pData = _MemGlobalLock($hData) ;translate the handle into a pointer
    Local $tMem = DllStructCreate("byte[" & $len & "]", $pData) ;create struct
    DllStructSetData($tMem, 1, $memBitmap) ;fill struct with image data
    _MemGlobalUnlock($hData) ;decrements the lock count associated with a memory object that was allocated with GMEM_MOVEABLE
    $aResult = DllCall("ole32.dll", "int", "CreateStreamOnHGlobal", "handle", $pData, "int", True, "ptr*", 0) ;Creates a stream object that uses an HGLOBAL memory handle to store the stream contents
    If @error Then Return SetError(2, 0, 0)
    Local Const $hStream = $aResult[3]
    $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromStream", "ptr", $hStream, "int*", 0) ;Creates a Bitmap object based on an IStream COM interface
    If @error Then Return SetError(3, 0, 0)
    Local Const $hBitmap = $aResult[2]
    Local $tVARIANT = DllStructCreate("word vt;word r1;word r2;word r3;ptr data; ptr")
    DllCall("oleaut32.dll", "long", "DispCallFunc", "ptr", $hStream, "dword", 8 + 8 * @AutoItX64, _
    "dword", 4, "dword", 23, "dword", 0, "ptr", 0, "ptr", 0, "ptr", DllStructGetPtr($tVARIANT)) ;release memory from $hStream to avoid memory leak
    $tMem = 0
    $tVARIANT = 0
    If $hHBITMAP Then
    Local Const $hHBmp = _WinAPI_BitmapCreateDIBFromBitmap($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap)
    Return $hHBmp
    EndIf
    Return $hBitmap
    EndFunc ;==>Load_BMP_From_Mem

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

    Func _WinAPI_BitmapCreateDIBFromBitmap($hBitmap) ;create 32-bit bitmap v5 (alpha channel supported)
    Local $tBIHDR, $aRet, $tData, $pBits, $hResult = 0
    $aRet = DllCall($ghGDIPDll, 'uint', 'GdipGetImageDimension', 'ptr', $hBitmap, 'float*', 0, 'float*', 0)
    If (@error) Or ($aRet[0]) Then Return 0
    $tData = _GDIPlus_BitmapLockBits($hBitmap, 0, 0, $aRet[2], $aRet[3], $GDIP_ILMREAD, $GDIP_PXF32ARGB)
    $pBits = DllStructGetData($tData, 'Scan0')
    If Not $pBits Then Return 0
    $tBIHDR = DllStructCreate( 'dword bV5Size;long bV5Width;long bV5Height;word bV5Planes;word bV5BitCount;dword bV5Compression;' & _ ;http://msdn.microsoft.com/en-us/library/…1(v=vs.85).aspx
    'dword bV5SizeImage;long bV5XPelsPerMeter;long bV5YPelsPerMeter;dword bV5ClrUsed;dword bV5ClrImportant;' & _
    'dword bV5RedMask;dword bV5GreenMask;dword bV5BlueMask;dword bV5AlphaMask;dword bV5CSType;' & _
    'int bV5Endpoints[3];dword bV5GammaRed;dword bV5GammaGreen;dword bV5GammaBlue;dword bV5Intent;' & _
    'dword bV5ProfileData;dword bV5ProfileSize;dword bV5Reserved')
    DllStructSetData($tBIHDR, 'bV5Size', DllStructGetSize($tBIHDR))
    DllStructSetData($tBIHDR, 'bV5Width', $aRet[2])
    DllStructSetData($tBIHDR, 'bV5Height', $aRet[3])
    DllStructSetData($tBIHDR, 'bV5Planes', 1)
    DllStructSetData($tBIHDR, 'bV5BitCount', 32)
    DllStructSetData($tBIHDR, 'bV5Compression', 0) ; $BI_BITFIELDS = 3, $BI_RGB = 0, $BI_RLE8 = 1, $BI_RLE4 = 2, $RGBA = 0x41424752
    DllStructSetData($tBIHDR, 'bV5SizeImage', $aRet[3] * DllStructGetData($tData, 'Stride'))
    DllStructSetData($tBIHDR, 'bV5AlphaMask', 0xFF000000)
    DllStructSetData($tBIHDR, 'bV5RedMask', 0x00FF0000)
    DllStructSetData($tBIHDR, 'bV5GreenMask', 0x0000FF00)
    DllStructSetData($tBIHDR, 'bV5BlueMask', 0x000000FF)
    DllStructSetData($tBIHDR, 'bV5CSType', 2) ; LCS_WINDOWS_COLOR_SPACE = 2
    DllStructSetData($tBIHDR, 'bV5Intent', 4) ; $LCS_GM_IMA
    $hResult = DllCall('gdi32.dll', 'ptr', 'CreateDIBSection', 'hwnd', 0, 'ptr', DllStructGetPtr($tBIHDR), 'uint', 0, 'ptr*', 0, 'ptr', 0, 'dword', 0)
    If (Not @error) And ($hResult[0]) Then
    DllCall('gdi32.dll', 'dword', 'SetBitmapBits', 'ptr', $hResult[0], 'dword', $aRet[2] * $aRet[3] * 4, 'ptr', DllStructGetData($tData, 'Scan0'))
    $hResult = $hResult[0]
    Else
    $hResult = 0
    EndIf
    _GDIPlus_BitmapUnlockBits($hBitmap, $tData)
    $tData = 0
    $tBIHDR = 0
    Return $hResult
    EndFunc ;==>_WinAPI_BitmapCreateDIBFromBitmap

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

    Func _HexRead($FilePath, $Offset, $Length)
    Local $Buffer, $ptr, $fLen, $hFile, $Result, $Read, $err, $Pos
    If Not FileExists($FilePath) Then Return SetError(1, @error, 0)
    $fLen = FileGetSize($FilePath)
    If $Offset > $fLen Then Return SetError(2, @error, 0)
    If $fLen < $Offset + $Length Then Return SetError(3, @error, 0)
    $Buffer = DllStructCreate("byte[" & $Length & "]")
    $ptr = DllStructGetPtr($Buffer)
    $hFile = _WinAPI_CreateFile($FilePath, 2, 2, 0)
    If $hFile = 0 Then Return SetError(5, @error, 0)
    $Pos = $Offset
    $Result = _WinAPI_SetFilePointer($hFile, $Pos)
    $err = @error
    If $Result = 0xFFFFFFFF Then
    _WinAPI_CloseHandle($hFile)
    Return SetError(6, $err, 0)
    EndIf
    $Read = 0
    $Result = _WinAPI_ReadFile($hFile, $ptr, $Length, $Read)
    $err = @error
    If Not $Result Then
    _WinAPI_CloseHandle($hFile)
    Return SetError(7, $err, 0)
    EndIf
    _WinAPI_CloseHandle($hFile)
    If Not $Result Then Return SetError(8, @error, 0)
    $Result = DllStructGetData($Buffer, 1)
    Return $Result
    EndFunc

    [/autoit]

    MfG Diggidie

  • Hilfe bei GDIPlus gesucht

    • Diggidie
    • 3. Februar 2013 um 22:26

    Hier mal ein lauffähiges Script zum nachvollziehen (benötigt die "TestDatei.7z" aus dem Anhang im Script-Verzeichnis)

    Spoiler anzeigen
    [autoit]

    ;############################################################################################################
    ;## Schritt 1 = _HexRead extrahiert das PNG aus der Test-Datei und speichert es in der Variable $PNG_Lesen ##
    ;## Schritt 2 = Das PNG-Bild, also die Variable $PNG_Lesen, wird gespeichert ##
    ;## Schritt 3 = Das PNG-Bild wird geladen und angezeigt mit _Display_PNG ##
    ;## Problem = Möchte das speichern und einlesen vermeiden, sondern direkt die Variable $PNG_Lesen nutzen ##
    ;############################################################################################################

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

    #include <WinAPI.au3>
    #include <GUIConstantsEx.au3>
    #include <GDIPlus.au3>

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

    $PNG_Lesen = _HexRead (@ScriptDir & "\TestDatei.7z", 0x110A, 0x0165); 0x110A = Position des PNG, 0x0165 = Länge der PNG-Datei in der TestDatei.blabla
    $PNG_Datei = FileOpen (@ScriptDir & "\Test.png", 14); möchte ich umgehen
    FileWrite ($PNG_Datei, $PNG_Lesen); möchte ich umgehen
    FileClose ($PNG_Datei); möchte ich umgehen

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

    $GUI = GUICreate("PNG", 160, 100)
    $ShowPNG = GUICtrlCreatePic ("", 48, 18)
    _Display_PNG ()
    GUISetState()

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

    do
    until GUIGetMsg() = $GUI_EVENT_CLOSE

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

    Func _Display_PNG ()
    Local Const $STM_SETIMAGE = 0x0172
    _GDIPlus_Startup ()
    Local $ImageLoad = _GDIPlus_BitmapCreateFromFile (@ScriptDir & "\Test.png"); Hier würde ich gern irgendwie die $PNG_Lesen Variable nutzen
    Local $ImageHandle = _GDIPlus_BitmapCreateHBITMAPFromBitmap ($ImageLoad)
    GUICtrlSendMsg ($ShowPNG, $STM_SETIMAGE, 0, $ImageHandle)
    _WinAPI_DeleteObject ($ImageHandle)
    _GDIPlus_BitmapDispose ($ImageLoad)
    _GDIPlus_Shutdown ()
    EndFunc

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

    Func _HexRead($FilePath, $Offset, $Length)
    Local $Buffer, $ptr, $fLen, $hFile, $Result, $Read, $err, $Pos
    If Not FileExists($FilePath) Then Return SetError(1, @error, 0)
    $fLen = FileGetSize($FilePath)
    If $Offset > $fLen Then Return SetError(2, @error, 0)
    If $fLen < $Offset + $Length Then Return SetError(3, @error, 0)
    $Buffer = DllStructCreate("byte[" & $Length & "]")
    $ptr = DllStructGetPtr($Buffer)
    $hFile = _WinAPI_CreateFile($FilePath, 2, 2, 0)
    If $hFile = 0 Then Return SetError(5, @error, 0)
    $Pos = $Offset
    $Result = _WinAPI_SetFilePointer($hFile, $Pos)
    $err = @error
    If $Result = 0xFFFFFFFF Then
    _WinAPI_CloseHandle($hFile)
    Return SetError(6, $err, 0)
    EndIf
    $Read = 0
    $Result = _WinAPI_ReadFile($hFile, $ptr, $Length, $Read)
    $err = @error
    If Not $Result Then
    _WinAPI_CloseHandle($hFile)
    Return SetError(7, $err, 0)
    EndIf
    _WinAPI_CloseHandle($hFile)
    If Not $Result Then Return SetError(8, @error, 0)
    $Result = DllStructGetData($Buffer, 1)
    Return $Result
    EndFunc

    [/autoit]


    Der Anhang ist keine 7zip Datei, muß also nicht entpackt werden, upload wollte eine Dateiendung haben...
    Die angehängte Datei enthält nur 0x00'en und ein eingebettetes PNG-Bild, welches mit _HexRead ausgelesen wird...

    Mir geht es nun darum die Variable $PNG_Lesen direkt anzeigen zu lassen,
    also ohne den Umweg, wie im Script, mit dem speichern und neu einlesen des PNG...
    Der Weg wie im Script mit dem speichern klappt ja, benötige nur dringend eine Variante ohne speichern des PNG...

    Lg Diggidie

  • Hilfe bei GDIPlus gesucht

    • Diggidie
    • 3. Februar 2013 um 22:03

    Hallo...

    Weiß jemand, wie man eine PNG-Datei auf einer Gui darstellt,
    wenn das PNG vorher in einer Variable abgelegt ist?

    Das Anzeigen klappt wunderbar, wenn das PNG als Datei vorliegt.
    Also z.b. so: (hatte ich irgendwo aus dem Forum her)

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <GDIPlus.au3>

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

    $GUI = GUICreate("PNG", 160, 100)
    $ShowPNG = GUICtrlCreatePic ("", 48, 18)
    _Display_PNG ()
    GUISetState()

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

    do
    until GUIGetMsg() = $GUI_EVENT_CLOSE

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

    Func _Display_PNG ()
    Local Const $STM_SETIMAGE = 0x0172
    _GDIPlus_Startup ()
    Local $ImageLoad = _GDIPlus_BitmapCreateFromFile (@ScriptDir & "\Test.png")
    Local $ImageHandle = _GDIPlus_BitmapCreateHBITMAPFromBitmap ($ImageLoad)
    GUICtrlSendMsg ($ShowPNG, $STM_SETIMAGE, 0, $ImageHandle)
    _WinAPI_DeleteObject ($ImageHandle)
    _GDIPlus_BitmapDispose ($ImageLoad)
    _GDIPlus_Shutdown ()
    EndFunc

    [/autoit]

    Ich lese das PNG aus einem Profil aus (mit _HexRead, hab ich aus dem englischen Forum, wo es eingebettet ist...
    Würde mir den Umweg gern ersparen, das PNG erst zu speichern (liegt ja bereits als Variable vor)
    und es dann wieder einzulesen...

    Müßte doch evtl. mit GDIPlus möglich sein, die Variable direkt zu nutzen... Oder?

    Kenne mich mir GDIPlus nicht aus, und wäre über eure Hilfe sehr erfreut..

    MfG Diggidie

  • GUI anpassen

    • Diggidie
    • 31. Januar 2013 um 13:25

    Da die wenigsten Leute wohl die "Die Lesbarkeit auf dem Bildschirm erleichtern" verändern
    und meine Gui's immer eine feste Größe haben (also nicht veränderbar sein sollen), hab
    ich es mit der Schriftgröße für mich folgendermaßen gelöst:

    Ich lese die aktuelle DPI-Größe der Bildschirmauflösung mit

    [autoit]

    $DPI = RegRead("HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics", "AppliedDPI")

    [/autoit]


    aus, und errechne, vor dem Gui-Aufbau, den Multiplikator für andere Werte als 96 DPI (100% Bildschirmlesbarkeit):

    [autoit]

    If $DPI = 96 Then
    $DPI = 1
    Else
    $DPI = 96 / $DPI
    EndIf

    [/autoit]


    und setze die Schriftgröße in der Gui dann z.B. so:

    [autoit]

    GUISetFont(8.5 * $DPI, 400, -1, "Arial")

    [/autoit]


    So bleibt alles so, wie ich es in meinen Programmen haben will....
    Müssen die Leute mit erhöhter Lesbarkeit halt die Augen ein wenig mehr anstrengen ;)

    Bin natürlich auch an einer eleganteren Lösung interessiert, aber unsere Profi's hier, werden es schon richten :thumbup:

    MfG Diggidie

Spenden

Jeder Euro hilft uns, Euch zu helfen.

Download

AutoIt Tutorial
AutoIt Buch
Onlinehilfe
AutoIt Entwickler
  1. Datenschutzerklärung
  2. Impressum
  3. Shoutbox-Archiv
Community-Software: WoltLab Suite™