Icons mit _WinAPI_ExtractIconEx aus .dll, .exe etc. extrahieren

  • Ich bin mir nicht sicher, ob jemand schon ein Script dieser Art gepostet hat, aber bisher sind mir nicht gerade viele Beispiele für die _WinAPI_ExtractIconEx Funktion unter die Augen gekommen.

    Hier ist ein Beispiel wie man besagte Funktion verwendet um Icons aus einer Datei zu extrahieren und wie man dann mit den erhaltenen handles weiter verfahren kann (z.B. GDIPlus).

    Spoiler anzeigen
    [autoit]

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

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

    ; -Author: name22 (http://www.autoit.de)

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

    $iStart = 3 ;0-basierter Index des ersten Icons
    $iIcons = 5 ;Anzahl der zu extrahierenden Icons

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

    $t_ahIcons = DllStructCreate("HWND[" & $iIcons & "]") ;HWND Array um die Icons zu erhalten
    $p_ahIcons = DllStructGetPtr($t_ahIcons)

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

    _WinAPI_ExtractIconEx(@SystemDir & "\shell32.dll", $iStart, 0, $p_ahIcons, $iIcons) ;Hier wird der pSmall Parameter verwendet um kleine Icons zu extrahieren

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

    _GDIPlus_Startup()

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

    For $i = 1 To $iIcons
    $hBitmap = _GDIPlus_BitmapCreateFromHICON(DllStructGetData($t_ahIcons, 1, $i)) ;Erzeugt aus dem HICON eine GDI+ Bitmap
    _GDIPlus_ImageSaveToFile($hBitmap, @ScriptDir & StringFormat("\Icon%02d.bmp", $i)) ;Speichert die Bitmap
    _GDIPlus_BitmapDispose($hBitmap) ;Bitmap löschen
    _WinAPI_DestroyIcon(DllStructGetData($t_ahIcons, 1, $i)) ;Icon löschen
    Next

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

    _GDIPlus_Shutdown()

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

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _GDIPlus_BitmapCreateFromHICON
    ; Description ...: Creates a Bitmap object based on an icon
    ; Syntax.........: _GDIPlus_BitmapCreateFromHICON($hIcon)
    ; Parameters ....: $hIcon - Handle to an icon
    ; Return values .: Success - Returns a handle to a new Bitmap object
    ; Failure - 0 and either:
    ; |@error and @extended are set if DllCall failed
    ; |$GDIP_STATUS contains a non zero value specifying the error code
    ; Remarks .......: After you are done with the object, call _GDIPlus_ImageDispose to release the object resources
    ; Related .......: _GDIPlus_ImageDispose, _WinAPI_LoadImage, _WinAPI_LoadIcon
    ; Link ..........; @@MsdnLink@@ GdipCreateBitmapFromHICON
    ; Example .......; Yes
    ; ===============================================================================================================================
    Func _GDIPlus_BitmapCreateFromHICON($hIcon)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromHICON", "hwnd", $hIcon, "int*", 0)

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

    If @error Then Return SetError(@error, @extended, 0)
    $GDIP_STATUS = $aResult[0]
    Return $aResult[2]
    EndFunc ;==>_GDIPlus_BitmapCreateFromHICON

    [/autoit]


    Im Beispiel werden 5 Icons ab dem 3ten Index aus der shell32.dll extrahiert. Ich hoffe es kann jemand gebrauchen.
    Bei Fragen bzw. Rückmeldungen meldet euch einfach ;).

  • Soweit ich mich erinnern kann unterstützt GdipCreateBitmapFromHICON keine transparenten Icons. Ich hatte dies bzgl. irgendwo ein Workaround gebastelt.

    Gruß,
    UEZ

    Auch am Arsch geht ein Weg vorbei...

    ¯\_(ツ)_/¯

  • Da hast du Recht. Ich hab das auf die Schnelle zusammengebastelt, weil jemand in der SB danach gefragt hat. Ich bin mir nicht mehr ganz sicher wie Microsoft das handhabt, aber ich meine gelesen zu haben, dass zusätzlich zu den Farbinformationen eines Icons auch eine Alphamaske gespeichert wird. ?(

  • Coole Sache! Wäre es auch möglich Programmicons über Fenster handles zu extrahieren?

    Grüße,
    notna

  • Das ist durchaus möglich. Allerdings meine ich, dass sich nicht alle Icons von Fensterhandles auf die gleiche Art auslesen lassen... Ich müsste mir das mal genauer anschauen, es sei denn jemand weiß wie man das in AutoIt möglichst gut umsetzt ^^.
    Man könnte natürlich auch versuchen über das Fensterhandle auf die ausführbare Datei des Prozesses zuzugreifen, aber das Icon in einem Fenster muss da nicht notwendigerweise enthalten sein.

  • Ich hab mal aus den Methoden Fenstericons auszulesen die mir bekannt sind folgendes gebastelt:

    Spoiler anzeigen
    [autoit]

    #include <WindowsConstants.au3>
    #include <GUIConstants.au3>
    #include <WinAPI.au3>

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

    ;WinAPIEx.au3:
    Global Const $GCL_CBCLSEXTRA = -20
    Global Const $GCL_CBWNDEXTRA = -18
    Global Const $GCL_HBRBACKGROUND = -10
    Global Const $GCL_HCURSOR = -12
    Global Const $GCL_HICON = -14
    Global Const $GCL_HICONSM = -34
    Global Const $GCL_HMODULE = -16
    Global Const $GCL_MENUNAME = -8
    Global Const $GCL_STYLE = -26
    Global Const $GCL_WNDPROC = -24

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

    ; -Author: name22 (http://www.autoit.de)

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

    $hWnd = GUICreate("Searching...", 256, 256)
    GUISetState()

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

    $hDC_Window = _WinAPI_GetDC($hWnd)

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

    $aList = WinList()

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

    For $i = 1 To $aList[0][0]
    If BitAND(WinGetState($aList[$i][1]), 3) = 3 Then
    $hIcon = _SendMessage($aList[$i][1], $WM_GETICON, 2, 0, 0, Default, Default, "HANDLE")

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

    If Not $hIcon Then $hIcon = _SendMessage($aList[$i][1], $WM_GETICON, 0, 0, 0, Default, Default, "HANDLE")

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

    If Not $hIcon Then $hIcon = _WinAPI_GetClassLongEx($aList[$i][1], $GCL_HICON)

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

    If Not $hIcon Then $hIcon = _WinAPI_GetClassLongEx($aList[$i][1], $GCL_HICONSM)

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

    If $hIcon Then
    WinSetTitle($hWnd, "", $aList[$i][0])
    _SendMessage($hWnd, $WM_ERASEBKGND, $hDC_Window)
    _WinAPI_DrawIconEx($hDC_Window, 64, 64, $hIcon, 128, 128, 0, 0, 3)
    _WinAPI_DestroyIcon($hIcon)
    Sleep(1000)
    EndIf
    EndIf
    Next

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

    While True
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    ExitLoop
    EndSwitch
    WEnd

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

    ; #FUNCTION# ====================================================================================================================
    ; Name...........: _WinAPI_GetClassLongEx
    ; Description....: Retrieves the specified value associated with the specified window.
    ; Syntax.........: _WinAPI_GetClassLongEx ( $hWnd, $iIndex )
    ; Parameters.....: $hWnd - Handle to the window.
    ; $iIndex - The value to retrieve. This parameter can be one of the following values.
    ;
    ; $GCL_CBCLSEXTRA
    ; $GCL_CBWNDEXTRA
    ; $GCL_HBRBACKGROUND
    ; $GCL_HCURSOR
    ; $GCL_HICON
    ; $GCL_HICONSM
    ; $GCL_HMODULE
    ; $GCL_MENUNAME
    ; $GCL_STYLE
    ; $GCL_WNDPROC
    ;
    ; Return values..: Success - The requested value.
    ; Failure - 0 and sets the @error flag to non-zero.
    ; Author.........: Yashied
    ; Modified.......:
    ; Remarks........: None
    ; Related........:
    ; Link...........: @@MsdnLink@@ GetClassLong
    ; Example........: Yes
    ; ===============================================================================================================================

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

    Func _WinAPI_GetClassLongEx($hWnd, $iIndex)

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

    Local $Ret

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

    If @AutoItX64 Then
    $Ret = DllCall('user32.dll', 'ulong_ptr', 'GetClassLongPtrW', 'hwnd', $hWnd, 'int', $iIndex)
    Else
    $Ret = DllCall('user32.dll', 'ulong', 'GetClassLongW', 'hwnd', $hWnd, 'int', $iIndex)
    EndIf
    If (@error) Or (Not $Ret[0]) Then
    Return SetError(1, 0, 0)
    EndIf
    Return $Ret[0]
    EndFunc ;==>_WinAPI_GetClassLongEx

    [/autoit]


    Das Script liest die Icons aller offenen Fenster aus und zeigt sie nacheinander in einer GUI an. Dieses mal hab ich auch nach eukalyptus Vorschlag direkt per GDI32 gezeichnet (die Icons behalten also dank der Maske ihre Transparenz).
    Es ist nicht perfekt - das Icon VLC Player wird zum Beispiel nicht korrekt ausgelesen. Allerdings funktionieren sonst praktisch alle offenen Fenster (z.B. Firefox, AIMP, Windows-Calculator, Thunderbird...).
    Manche Fenster reagieren auf die WM_GETICON Nachricht, andere nicht (z.B. AutoIt GUIs)...

    • Offizieller Beitrag
    Zitat von notna

    Ich habe mal versucht das für dieses Projekt zu benutzen:
    Wechsel zwischen geöffneten Fenstern
    Hab es aber nicht geschafft die Icons auf die Buttons zu legen..
    Trotzdem danke!

    In dem Projekt sehe ich keine Buttons und ohne Code wird dir da auch keiner helfen.
    Ein Icon auf nen Button zu legen, ist keine Aktion. ;)

    [autoit]

    GUICtrlSetImage
    _GUICtrlButton_SetImage

    [/autoit]
  • Zitat

    In dem Projekt sehe ich keine Buttons und ohne Code wird dir da auch keiner helfen.

    In dem verlinkten Beitrag ist doch der gesamte code... Kann ihn aber auch gerne hier posten:

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <StaticConstants.au3>
    #include <WinAPI.au3>
    #include <Misc.au3>

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

    _Singleton("switch", 0)

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

    Opt("GUICoordMode", 0)
    Opt("TrayIconHide", 1)

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

    Global Const $GCL_CBCLSEXTRA = -20
    Global Const $GCL_CBWNDEXTRA = -18
    Global Const $GCL_HBRBACKGROUND = -10
    Global Const $GCL_HCURSOR = -12
    Global Const $GCL_HICON = -14
    Global Const $GCL_HICONSM = -34
    Global Const $GCL_HMODULE = -16
    Global Const $GCL_MENUNAME = -8
    Global Const $GCL_STYLE = -26
    Global Const $GCL_WNDPROC = -24

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

    $allwindows = WinList()
    $count = $allwindows[0][0]
    Global $relatedwindows[$count][$count]
    $rows=1
    $colums=0
    $cnt=1
    $j=1
    $mouseX=MouseGetPos(0)
    Global $thirdW=@DesktopWidth/3
    $third2=(2*$thirdW)
    $third3=@DesktopWidth
    $x1=($thirdW/2-332)
    $x2=($thirdW+$x1)
    $x3=($thirdW+$x2)
    Global $winH=@DesktopHeight
    Global $2thirdW=2*@DesktopWidth/3
    Global $maxW=@DesktopWidth
    Global $m1X=0
    Global $m2X=@DesktopWidth/3
    Global $m3X=2*@DesktopWidth/3

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

    If $mouseX<=$thirdW Then
    $guiX=$x1
    ElseIf $mouseX<=$third2 Then
    $guiX=$x2
    ElseIf $mouseX<=$third3 Then
    $guiX=$x3
    EndIf
    ;MsgBox(0, "title", Round("4,9"))
    For $i = 1 to $count
    If (BitAND(WinGetState($allwindows[$i][1]), 16) Or WinGetState($allwindows[$i][1]) = 7) AND $allwindows[$i][0] <> "Start" AND $allwindows[$i][0] <> "Program Manager" AND $allwindows[$i][0] <> "DWM Notification Window" AND $allwindows[$i][0] <> "AMD:CCC-AEMCapturingWindow" AND $allwindows[$i][0] <> "2. Client Starten" AND $allwindows[$i][0] <> "SBSDKInstance" AND $allwindows[$i][0] <> "" Then
    $relatedwindows[$j][0] = $allwindows[$i][0]
    $relatedwindows[$j][1] = $allwindows[$i][1]
    $colums = $colums+1
    ;$cnt = $cnt + 1
    $j = $j +1
    ;MsgBox(0, "title", $relatedwindows[$i][0])
    if $colums > 4 Then
    $colums = 1
    $rows = $rows+1
    EndIf
    EndIf
    Next

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

    if $j == 1 Then
    $guiW = 260
    ElseIf $j <=4 Then
    $guiW = $j*95 ;460
    Else
    $guiW = 500
    EndIf
    $guiH = ($rows * 120)
    $ygap = 120

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

    $background = GUICreate("", $guiW, $guiH, $guiX, -1, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetBkColor(0x01)
    _Gui_RoundCorners($background, 0, 0, 50, 50)
    WinSetTrans ( $background, "", 100)
    GUISetState()

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

    $winswitch = GUICreate("Switch", $guiW, $guiH, $guiX, -1, $WS_POPUP, BitOR($WS_EX_LAYERED,$WS_EX_TOPMOST))
    GUISetBkColor(0x01)
    If $j == 1 Then
    GUICtrlCreateLabel("", 20, 40, 215, 35)
    GUICtrlSetBkColor(-1, 0x757273)
    GUICtrlCreateLabel("sorry, there are no windows...", 5, 5, 230, 25)
    GUICtrlSetFont(-1, 12, 500, 0, "Segoe UI")
    GUICtrlSetColor(-1, 0xffffff)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    Else
    $kachel = Assign($relatedwindows[1][0], GUICtrlCreateButton("", 40, 15, 90, 90, BitOr($BS_MULTILINE, $BS_PUSHLIKE, $BS_ICON)))
    $tmp = _WinAPI_GetDC($kachel)
    GUICtrlSetFont(-1, 12, 400, 0, "Segoe UI")
    $cnt = $cnt + 1

    for $i = 2 to $j-1
    if $cnt = 4 Then
    $kachel = Assign($relatedwindows[$i][0], GUICtrlCreateButton($relatedwindows[$i][0], -328, -1 + $ygap, 90, 90, BitOr($BS_MULTILINE, $BS_PUSHLIKE, $BS_ICON)); BitOr($GUI_SS_DEFAULT_CHECKBOX, $BS_PUSHLIKE, $BS_ICON));, $BS_MULTILINE)
    GUICtrlSetFont(-1, 12, 400, 0, "Segoe UI")
    $cnt = 1
    Else
    $kachel = Assign($relatedwindows[$i][0], GUICtrlCreateButton("", -1 + 110, -1, 90, 90, BitOr($BS_MULTILINE, $BS_PUSHLIKE, $BS_ICON)));$BS_MULTILINE))
    GUICtrlSetFont(-1, 12, 400, 0, "Segoe UI")
    $tmp = _WinAPI_GetDC($kachel)
    $cnt = $cnt + 1
    EndIf
    Next
    EndIf
    GUISetState()
    _WinAPI_SetLayeredWindowAttributes($winswitch, 0x01, 255)
    If $j == 1 Then
    Sleep(3000)
    Exit
    EndIf

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

    While 1
    $msg = GUIGetMsg()
    WinSetOnTop($winswitch, "", 1)
    Switch $msg
    Case $GUI_EVENT_CLOSE
    Exit
    Case Else
    for $i=1 to $j -1
    if $msg = Eval($relatedwindows[$i][0]) Then
    ;WinActivate($relatedwindows[$i][0])
    ;WinFlash($relatedwindows[$i][0], "", 3, 500)
    __PopUp($relatedwindows[$i][0])
    Exit
    EndIf
    Next
    EndSwitch
    WEnd

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

    Func __PopUp($window)
    $position = GUICreate("", 338, 280, $guiX, -1, $WS_POPUP, $WS_EX_TOPMOST)
    GUISetBkColor(0x01)
    ;==> Positions
    GUICtrlCreateGroup("", 25, 25, 290, 160)
    GUICtrlSetColor(-1, 0xffffff)
    GUICtrlCreateLabel(" Action ", 15, -8, 63, 25)
    GUICtrlSetFont(-1, 12, 500, 0, "Segoe UI")
    GUICtrlSetColor(-1, 0xffffff)
    $m1 = GUICtrlCreateButton("", -1, 30, 50, 50, BitOr($BS_MULTILINE, $BS_PUSHLIKE, $BS_ICON))
    GUICtrlSetImage(-1, @ScriptDir & "\GUI\m1-gui.ico")
    $m2 = GUICtrlCreateButton("", 70, 0, 50, 50, BitOr($BS_MULTILINE, $BS_PUSHLIKE, $BS_ICON))
    GUICtrlSetImage(-1, @ScriptDir & "\GUI\m2-gui.ico")
    $m3 = GUICtrlCreateButton("", 70, 0, 50, 50, BitOr($BS_MULTILINE, $BS_PUSHLIKE, $BS_ICON))
    GUICtrlSetImage(-1, @ScriptDir & "\GUI\m3-gui.ico")
    $m12 = GUICtrlCreateButton("", 70, 0, 50, 50, BitOr($BS_MULTILINE, $BS_PUSHLIKE, $BS_ICON))
    GUICtrlSetImage(-1, @ScriptDir & "\GUI\m12-gui.ico")
    $m23 = GUICtrlCreateButton("", -210, 70, 50, 50, BitOr($BS_MULTILINE, $BS_PUSHLIKE, $BS_ICON))
    GUICtrlSetImage(-1, @ScriptDir & "\GUI\m23-gui.ico")
    $max = GUICtrlCreateButton("", 70, 0, 50, 50, BitOr($BS_MULTILINE, $BS_PUSHLIKE, $BS_ICON))
    GUICtrlSetImage(-1, @ScriptDir & "\GUI\maximize-gui.ico")
    $min = GUICtrlCreateButton("", 70, 0, 50, 50, BitOr($BS_MULTILINE, $BS_PUSHLIKE, $BS_ICON))
    GUICtrlSetImage(-1, @ScriptDir & "\GUI\minimize-gui.ico")
    $close = GUICtrlCreateButton("", 70, 0, 50, 50, BitOr($BS_MULTILINE, $BS_PUSHLIKE, $BS_ICON))
    GUICtrlSetImage(-1, @ScriptDir & "\GUI\close-gui.ico")
    $esc = GUICtrlCreateButton("cancel", -105, 90, 50, 50, BitOr($BS_MULTILINE, $BS_PUSHLIKE, $BS_ICON))
    GUICtrlSetFont(-1, 12, 400, 0, "Segoe UI")
    _Gui_RoundCorners($position, 0, 0, 50, 50)
    GUISetState(@SW_SHOW)
    While 1
    $button = GUIGetMsg()
    Switch $button
    Case $GUI_EVENT_CLOSE
    Exit
    Case $m1
    WinActivate($window, "")
    $positionX = $m1X
    $positionW = $thirdW
    WinMove($window, "", $positionX, 0, $positionW, $winH, 3)
    Exit
    Case $m2
    WinActivate($window, "")
    $positionX = $m2X
    $positionW = $thirdW
    WinMove($window, "", $positionX, 0, $positionW, $winH, 3)
    Exit
    Case $m3
    WinActivate($window, "")
    $positionX = $m3X
    $positionW = $thirdW
    WinMove($window, "", $positionX, 0, $positionW, $winH, 3)
    Exit
    Case $m12
    WinActivate($window, "")
    $positionX = $m1X
    $positionW = $2thirdW
    WinMove($window, "", $positionX, 0, $positionW, $winH, 3)
    Exit
    Case $m23
    WinActivate($window, "")
    $positionX = $m1X
    $positionW = $2thirdW
    WinMove($window, "", $positionX, 0, $positionW, $winH, 3)
    Exit
    Case $max
    WinActivate($window, "")
    $positionX = $m1X
    $positionW = $maxW
    WinMove($window, "", $positionX, 0, $positionW, $winH, 3)
    Exit
    Case $min
    WinSetState($window, "", @SW_MINIMIZE)
    Exit
    Case $close
    WinClose($window, "")
    Exit
    Case $esc
    Return
    EndSwitch
    WEnd
    EndFunc

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

    Func _Gui_RoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3)
    Local $XS_pos, $XS_ret, $XS_ret2
    $XS_pos = WinGetPos($h_win)
    $XS_ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $XS_pos[2], "long", $XS_pos[3], "long", $i_x3, "long", $i_y3)
    If $XS_ret[0] Then
    $XS_ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $XS_ret[0], "int", 1)
    EndIf
    EndFunc

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

    Func _WinAPI_GetClassLongEx($hWnd, $iIndex)

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

    Local $Ret

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

    If @AutoItX64 Then
    $Ret = DllCall('user32.dll', 'ulong_ptr', 'GetClassLongPtrW', 'hwnd', $hWnd, 'int', $iIndex)
    Else
    $Ret = DllCall('user32.dll', 'ulong', 'GetClassLongW', 'hwnd', $hWnd, 'int', $iIndex)
    EndIf
    If (@error) Or (Not $Ret[0]) Then
    Return SetError(1, 0, 0)
    EndIf
    Return $Ret[0]
    EndFunc

    [/autoit]


    Und Buttons gibts da auch, z.B.:

    [autoit]

    $kachel = Assign($relatedwindows[1][0], GUICtrlCreateButton("", 40, 15, 90, 90, BitOr($BS_MULTILINE, $BS_PUSHLIKE, $BS_ICON)))

    [/autoit]


    Ich hatte es dann in etwa so versucht:

    Spoiler anzeigen
    [autoit]


    $winswitch = GUICreate("Switch", $guiW, $guiH, $guiX, -1, $WS_POPUP, BitOR($WS_EX_LAYERED,$WS_EX_TOPMOST))
    $hDC_Window = _WinAPI_GetDC($winswitch)
    $kachel = Assign($relatedwindows[1][0], GUICtrlCreateButton("", 40, 15, 90, 90, BitOr($BS_MULTILINE, $BS_PUSHLIKE, $BS_ICON)))
    $tmp = _WinAPI_GetDC($kachel)
    $hIcon = _SendMessage($relatedwindows[1][1], $WM_GETICON, 2, 0, 0, Default, Default, "HANDLE")

    If Not $hIcon Then $hIcon = _SendMessage($relatedwindows[1][1], $WM_GETICON, 0, 0, 0, Default, Default, "HANDLE")

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

    If Not $hIcon Then $hIcon = _WinAPI_GetClassLongEx($relatedwindows[1][1], $GCL_HICON)

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

    If Not $hIcon Then $hIcon = _WinAPI_GetClassLongEx($relatedwindows[1][1], $GCL_HICONSM)

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

    If $hIcon Then
    GUICtrlSetImage($kachel, $hIcon)
    ;_WinAPI_DrawIconEx($kachel, 64, 64, $tmp);, 128, 128, 0, 0, 3) ;beides mal versucht...
    _SendMessage($winswitch, $WM_ERASEBKGND, $hDC_Window)
    _WinAPI_DestroyIcon($hIcon)
    EndIf

    [/autoit]


    GUICtrlSetImage hat also nicht funktioniert.

    • Offizieller Beitrag

    Hi.

    1. Sorry, hab das Script nicht gesehen, hatte wohl Tomaten auf den Augen. :rolleyes:
    2. Dein Script hat einen Syntaxerror, da fehlt ne Klammer.
    3. Wenn der Syntaxerror beseitigt ist, beschwert sich Autoit über eine undeklarierte Variable $guiX, diese solltest du vor der If then Auswertung deklarieren.
    4. Wenn dann endlich die GUI läuft werden die Buttons falsch angezeigt
    [Blockierte Grafik: http://m16.img-up.net/Anzeigefeh7550.PNG]
    5. Dein Codefetzen mit der Iconzuweisung ist nicht im Hauptscript eingebaut, ERGO kann ich nicht sagen wo da was schief läuft.
    Poste doch bitte mal das ganze Script, so wie es jetzt ist, dann versuch ich dir dabei zu helfen.
    Am besten machst du das aber in deinem Thread, wir wollen ja nicht den Scriptethread von name22 kapern ;)

  • Oh... Scheinbar ist da unterwegs etwas mit copy'n paste schief gegangen, oder ich habe die falsche Datei benutzt. Sorry! Um den Thread nicht zu kapern habe ich die bei mir laufenden Scripte in meinem Thread geposted (inkl. der hier vorgestellten Methoden).

    Grüße,
    notna