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. Oscar

Beiträge von Oscar

  • ListView Ctrl+A alles selektieren

    • Oscar
    • 3. September 2023 um 13:22

    Ich würde einen anderen Weg vorschlagen:

    AutoIt
    #include <GUIConstantsEx.au3>
    #include <GuiListView.au3>
    #include <ListViewConstants.au3>
    #include <WinAPISys.au3>
    
    Opt("GUIOnEventMode", 1)
    
    Global $hGui = GUICreate("Test", 320, 240)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_GUI_EVENT_CLOSE")
    
    Global $cLV_Test = GUICtrlCreateListView("Name", 5, 5, 150, 230, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS))
    Global $cLV_Test2 = GUICtrlCreateListView("Name", 160, 5, 150, 230, BitOR($LVS_REPORT, $LVS_SHOWSELALWAYS))
    For $i = 1 To 9
        _GUICtrlListView_AddItem($cLV_Test, "Item" & $i)
        _GUICtrlListView_AddItem($cLV_Test2, "Item" & $i)
    Next
    Global $cDummy = GUICtrlCreateDummy()
    GUICtrlSetOnEvent(-1, '_SelectAll')
    Global $aAccelKeys[1][2] = [["^a", $cDummy]]
    GUISetAccelerators($aAccelKeys)
    GUISetState(@SW_SHOW)
    
    While Sleep(10)
    WEnd
    
    Func _GUI_EVENT_CLOSE()
        Exit
    EndFunc   ;==>_GUI_EVENT_CLOSE
    
    Func _SelectAll()
        Local $sClassName = ControlGetFocus($hGui)
        If $sClassName <> '' Then
            Local $hActive = ControlGetHandle($hGui, '', $sClassName)
            ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hActive = ' & $hActive & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
        EndIf
    EndFunc
    Alles anzeigen
  • Datei-Anzeige

    • Oscar
    • 1. September 2023 um 14:05
    Zitat von Moombas

    Wobei ich die Funktion sogar noch so wegkürzen würde und die Gleiche Funktionalität hätte:

    Natürlich kann man _Iif auch als Funktion abbilden (war in alten Versionen ja so), aber wozu?

    Der ternäre Operator wird mit Sicherheit schneller sein, weil er in AutoIt eingebaut ist und somit nicht erst vom Interpreter zur Laufzeit ausgeführt werden muss.

  • Datei-Anzeige

    • Oscar
    • 1. September 2023 um 13:19
    Zitat von Moombas

    Ist das Gegenstück für IIf nicht einfach eine logische Verknüpfung?

    Nicht, so wie ich Iif verstehe, denn als Ergebnis bekommt man ja nicht TRUE/FALSE, sondern den Wert von A bzw. B.
    Also: $C = Iif($x > 50, $A, $B) ; wenn $x größer als 50, dann wird $A zurückgegeben, ansonsten $B.

    Zumindest war das in alten AutoIt-Versionen mit "_Iif()" so. VBA kenne ich nicht.

    In den neuen AutoIt-Versionen gibt es ja den ternären Operator: $C = $x > 50 ? $A : $B

  • Datei-Anzeige

    • Oscar
    • 1. September 2023 um 12:01
    Zitat von mumpel

    In VBA habe ich z.B. auch "IIf", was ganz hilfreich ist, ein Äquivalent dazu scheint es in AutoIt nicht zu geben.

    Such mal nach "ternary". Dass ist genau das, wonach Du suchst.

    Und was meinst Du mit mehrere ENUM? Beispielscript bitte!

  • Datei-Anzeige

    • Oscar
    • 1. September 2023 um 11:51
    Zitat von mumpel

    Wenn ich jetzt richtig verstehe, kann ich mit "False" auch sagen, dass nur die angegebenen Ordner eingelesen werden sollen!?

    Ja, das geht auch!

    Dann solltest Du aber die Konstante umbenennen, damit Du das Script später auch noch verstehst.

  • Datei-Anzeige

    • Oscar
    • 1. September 2023 um 05:16
    Zitat von mumpel

    Man müsste ja auch zur Laufzeit entfernen und hinzufügen können?

    Besser, man liest sie erst gar nicht ein:

    AutoIt
    #include <APIShellExConstants.au3>
    #include <FileConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiImageList.au3>
    #include <GuiTreeView.au3>
    #include <TreeViewConstants.au3>
    #include <WinAPIFiles.au3>
    #include <WinAPIIcons.au3>
    #include <WinAPIRes.au3>
    #include <WinAPIShellEx.au3>
    #include <WinAPIShPath.au3>
    #include <WindowsConstants.au3>
    
    Opt('GUIOnEventMode', 1)
    
    Global Const $sSearchDir = @ScriptDir ; hier das Verzeichnis mit den Dokumenten eintragen
    Global Const $sExcludeDirs = 'icon;settings;toolbar' ; hier die Unterverzeichnisse, die NICHT eingelesen werden sollen
    Global Const $sFileExtensions = '*.pdf;*.docx;*.xlsm' ; die Dateiendungen, die angezeigt werden sollen
    Global Const $bLargeIcons = False ; ob grosse oder kleine Icons benutzt werden sollen
    
    _WinAPI_FileIconInit() ; System-Imagelist initialisieren
    Global $hSystemImgList = _WinAPI_ShellGetImageList(Not $bLargeIcons) ; System-Imagelist holen
    Global $hBusyCur = _WinAPI_LoadCursorFromFile(@WindowsDir & '\Cursors\aero_busy_xl.ani') ; Busy-Animation-Cursor laden
    Global $mPathMap[] ; Map-Datentyp zum speichern des Treeview-Handle und des dazugehoerigen Pfades
    
    Global $hMainGui = GUICreate('Test', 1000, 600)
    GUISetOnEvent($GUI_EVENT_CLOSE, '_CloseMainGui')
    
    Global $idTreeview = GUICtrlCreateTreeView(10, 10, 400, 580, $GUI_SS_DEFAULT_TREEVIEW, $WS_EX_CLIENTEDGE)
    GUICtrlSetFont(-1, 10 + $bLargeIcons, 400, 0, 'Verdana')
    GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKTOP + $GUI_DOCKLEFT)
    _GUICtrlTreeView_SetNormalImageList($idTreeview, $hSystemImgList)
    
    Global $hRoot = _CreateRoot($idTreeview, $sSearchDir, $bLargeIcons) ; Root-Eintrag erstellen
    
    GUISetState(@SW_SHOW, $hMainGui)
    
    ; Fuer Mausklicks auf ein Treeview muss man WM_NOTIFY registrieren und dort auswerten
    GUIRegisterMsg($WM_NOTIFY, '_WM_NOTIFY')
    
    ; Den ganzen Verzeichnisbaum rekursiv durchsuchen und im Treeview erstellen (kann lange dauern)
    Global $hOldCur = _WinAPI_SetCursor($hBusyCur ? $hBusyCur : 9)
    _GUICtrlTreeView_BeginUpdate($idTreeview)
    _ReadDirectory($idTreeview, $hRoot, $sSearchDir, $bLargeIcons)
    _GUICtrlTreeView_EndUpdate($idTreeview)
    _WinAPI_SetCursor($hOldCur)
    
    ; zum Schluss den Root-Eintrag aufklappen
    _SendMessage(GUICtrlGetHandle($idTreeview), $TVM_EXPAND, $TVE_EXPAND, $hRoot, 0, 'wparam', 'handle')
    
    While Sleep(1000)
    WEnd
    
    Func _CloseMainGui()
        _GUIImageList_Destroy($hSystemImgList)
        If $hBusyCur Then _WinAPI_DestroyCursor($hBusyCur)
        GUIDelete($hMainGui)
        Exit
    EndFunc   ;==>_CloseMainGui
    
    Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
        #forceref $hWnd, $iMsg, $iwParam
        Local $tNMTREEVIEW, $tNMHDR, $hItem, $hWndFrom, $sPath
        Local $sSepChar = Opt('GUIDataSeparatorChar')
        $tNMTREEVIEW = DllStructCreate($tagNMTREEVIEW, $ilParam)
        $hWndFrom = DllStructGetData($tNMTREEVIEW, 'hWndFrom')
        Switch $hWndFrom
            Case GUICtrlGetHandle($idTreeview)
                Switch DllStructGetData($tNMTREEVIEW, 'Code')
                    Case $TVN_SELCHANGEDA, $TVN_SELCHANGEDW
                        $hItem = DllStructGetData($tNMTREEVIEW, 'NewhItem')
                        If $hItem Then
                            $sPath = $mPathMap[$hItem] ; den Pfad anhand des Item-Handle auslesen
                            ; In $sPath steht der Pfad zur angeklickten Datei. Damit kann dann die Anzeige aufgerufen werden.
                            ConsoleWrite('@@ Zeile: ' & @ScriptLineNumber & ' -> $sPath = ' & $sPath & @CRLF)
                        EndIf
                EndSwitch
        EndSwitch
        Return $GUI_RUNDEFMSG
    EndFunc   ;==>_WM_NOTIFY
    
    Func _CreateRoot(ByRef $idTreeview, $sPath, $bLargeIcons)
        Local $iIndex, $hItem, $sName
        $iIndex = _GUIImageList_GetFileIconIndex($sPath, $bLargeIcons, True)
        $sName = StringRegExpReplace($sPath, '.+\\(.+)', '$1')
        $hItem = _GUICtrlTreeView_AddFirst($idTreeview, 0, $sName, $iIndex, $iIndex)
        $mPathMap[$hItem] = $sPath ; den Pfad anhand des Item-Handle speichern
        Return $hItem
    EndFunc   ;==>_CreateRoot
    
    Func _ReadDirectory(ByRef $idTreeview, $hItem, $sPath, $bLargeIcons)
        Local $iIndex, $aFolder, $aFiles, $hChild = $hItem, $sName
        If StringRight($sPath, 1) <> '\' Then $sPath &= '\'
        $aFolder = _WinAPI_EnumFiles($sPath, 2, $sExcludeDirs, True) ; nur Verzeichnisse einlesen
        If Not @error Then
            For $i = 1 To $aFolder[0][0]
                If Not BitAND($aFolder[$i][6], $FILE_ATTRIBUTE_REPARSE_POINT) And _
                        Not BitAND($aFolder[$i][6], $FILE_ATTRIBUTE_HIDDEN) Then
                    $sName = StringRegExpReplace($sPath & $aFolder[$i][0], '.+\\(.+)', '$1')
                    $iIndex = _GUIImageList_GetFileIconIndex($sPath & $aFolder[$i][0], $bLargeIcons, True)
                    $hChild = _GUICtrlTreeView_AddChild($idTreeview, $hItem, $sName, $iIndex, $iIndex)
                    $mPathMap[$hChild] = $sPath & $aFolder[$i][0] ; den Pfad anhand des Item-Handle speichern
                    _ReadDirectory($idTreeview, $hChild, $sPath & $aFolder[$i][0], $bLargeIcons)
                EndIf
            Next
        EndIf
        _WinAPI_SetCursor($hBusyCur ? $hBusyCur : 9)
        $aFiles = _WinAPI_EnumFiles($sPath, 1, $sFileExtensions) ; nur Dateien einlesen
        If Not @error Then
            For $i = 1 To $aFiles[0][0]
                If Not BitAND($aFiles[$i][6], $FILE_ATTRIBUTE_HIDDEN) Then
                    $sName = StringRegExpReplace($sPath & $aFiles[$i][0], '.+\\(.+)\..+', '$1')
                    $iIndex = _GUIImageList_GetFileIconIndex($sPath & $aFiles[$i][0], $bLargeIcons, True)
                    $hChild = _GUICtrlTreeView_AddChild($idTreeview, $hItem, $sName, $iIndex, $iIndex)
                    $mPathMap[$hChild] = $sPath & $aFiles[$i][0] ; den Pfad anhand des Item-Handle speichern
                EndIf
            Next
        EndIf
    EndFunc   ;==>_ReadDirectory
    
    Func _GUIImageList_GetFileIconIndex($sFilePath, $bLargeIcons = False, $bForceLoadFromDisk = False)
        Local $tFileInfo = DllStructCreate($tagSHFILEINFO)
        Local $iFlags = BitOR($SHGFI_SYSICONINDEX, _
                $bLargeIcons ? $SHGFI_LARGEICON : $SHGFI_SMALLICON, _
                $bForceLoadFromDisk ? 0 : $SHGFI_USEFILEATTRIBUTES)
        Local $ret = _WinAPI_ShellGetFileInfo($sFilePath, $iFlags, $FILE_ATTRIBUTE_NORMAL, $tFileInfo)
        If $ret Then Return DllStructGetData($tFileInfo, 'iIcon')
        Return SetError(1, 0, -1)
    EndFunc   ;==>_GUIImageList_GetFileIconIndex
    Alles anzeigen
  • Toolbar - Icon-Namen

    • Oscar
    • 30. August 2023 um 11:54
    Zitat von mumpel

    Der Code stammt aus dem Internet.

    Ein voll funktionsfähiges Beispiel wäre sinnvoller gewesen!

    Aber das Problem liegt mit Sicherheit an "_GUIImageList_Create". Das musst Du mit "5" als dritten Parameter starten (die ersten beiden musst Du dann auch angeben).

    Die "5" besagt: "Use a 32 bit DIB section". 32 Bit ist mit Alphawert (transparenz). 24Bit ist ohne Alpha.

  • Toolbar - Icon-Namen

    • Oscar
    • 30. August 2023 um 05:13
    Zitat von mumpel

    Und die Icons aus Dlls (z.B. imageres.dll und shell32.dll) erzeugen einen schwarzen Hintergrund.

    Dann machst Du etwas falsch! Das sind 32Bit-Icons.

    Zeig mal Dein Script!

  • Datei-Anzeige

    • Oscar
    • 29. August 2023 um 07:56

    Du wolltest ja auch, dass die Dateiendungen im Treeview nicht mit angezeigt werden. In dem Fall muss man den Pfad woanders speichern.

    Da drängt sich der "neue" Map-Datentyp geradezu auf (man muss nicht durch ein Array iterieren, um den Pfad anhand des Handle zu finden).

    Ich habe so eine Version mal erstellt:

    AutoIt
    #include <APIShellExConstants.au3>
    #include <FileConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiImageList.au3>
    #include <GuiTreeView.au3>
    #include <TreeViewConstants.au3>
    #include <WinAPIFiles.au3>
    #include <WinAPIIcons.au3>
    #include <WinAPIRes.au3>
    #include <WinAPIShellEx.au3>
    #include <WinAPIShPath.au3>
    #include <WindowsConstants.au3>
    
    Opt('GUIOnEventMode', 1)
    
    Global Const $sSearchDir = @UserProfileDir & '\Documents' ; hier das Verzeichnis mit den Dokumenten eintragen
    Global Const $sFileExtensions = '*.pdf;*.docx;*.xlsm' ; die Dateiendungen, die angezeigt werden sollen
    Global Const $bLargeIcons = False ; ob grosse oder kleine Icons benutzt werden sollen
    
    _WinAPI_FileIconInit() ; System-Imagelist initialisieren
    Global $hSystemImgList = _WinAPI_ShellGetImageList(Not $bLargeIcons) ; System-Imagelist holen
    Global $hBusyCur = _WinAPI_LoadCursorFromFile(@WindowsDir & '\Cursors\aero_busy_xl.ani') ; Busy-Animation-Cursor laden
    Global $mPathMap[] ; Map-Datentyp zum speichern des Treeview-Handle und des dazugehoerigen Pfades
    
    Global $hMainGui = GUICreate('Test', 1000, 600)
    GUISetOnEvent($GUI_EVENT_CLOSE, '_CloseMainGui')
    
    Global $idTreeview = GUICtrlCreateTreeView(10, 10, 400, 580, $GUI_SS_DEFAULT_TREEVIEW, $WS_EX_CLIENTEDGE)
    GUICtrlSetFont(-1, 10 + $bLargeIcons, 400, 0, 'Verdana')
    GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKTOP + $GUI_DOCKLEFT)
    _GUICtrlTreeView_SetNormalImageList($idTreeview, $hSystemImgList)
    
    Global $hRoot = _CreateRoot($idTreeview, $sSearchDir, $bLargeIcons) ; Root-Eintrag erstellen
    
    GUISetState(@SW_SHOW, $hMainGui)
    
    ; Fuer Mausklicks auf ein Treeview muss man WM_NOTIFY registrieren und dort auswerten
    GUIRegisterMsg($WM_NOTIFY, '_WM_NOTIFY')
    
    ; Den ganzen Verzeichnisbaum rekursiv durchsuchen und im Treeview erstellen (kann lange dauern)
    Global $hOldCur = _WinAPI_SetCursor($hBusyCur ? $hBusyCur : 9)
    _GUICtrlTreeView_BeginUpdate($idTreeview)
    _ReadDirectory($idTreeview, $hRoot, $sSearchDir, $bLargeIcons)
    _GUICtrlTreeView_EndUpdate($idTreeview)
    _WinAPI_SetCursor($hOldCur)
    
    ; zum Schluss den Root-Eintrag aufklappen
    _SendMessage(GUICtrlGetHandle($idTreeview), $TVM_EXPAND, $TVE_EXPAND, $hRoot, 0, 'wparam', 'handle')
    
    While Sleep(1000)
    WEnd
    
    Func _CloseMainGui()
        _GUIImageList_Destroy($hSystemImgList)
        If $hBusyCur Then _WinAPI_DestroyCursor($hBusyCur)
        GUIDelete($hMainGui)
        Exit
    EndFunc   ;==>_CloseMainGui
    
    Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
        #forceref $hWnd, $iMsg, $iwParam
        Local $tNMTREEVIEW, $tNMHDR, $hItem, $hWndFrom, $sPath
        Local $sSepChar = Opt('GUIDataSeparatorChar')
        $tNMTREEVIEW = DllStructCreate($tagNMTREEVIEW, $ilParam)
        $hWndFrom = DllStructGetData($tNMTREEVIEW, 'hWndFrom')
        Switch $hWndFrom
            Case GUICtrlGetHandle($idTreeview)
                Switch DllStructGetData($tNMTREEVIEW, 'Code')
                    Case $TVN_SELCHANGEDA, $TVN_SELCHANGEDW
                        $hItem = DllStructGetData($tNMTREEVIEW, 'NewhItem')
                        If $hItem Then
                            $sPath = $mPathMap[$hItem] ; den Pfad anhand des Item-Handle auslesen
                            ; In $sPath steht der Pfad zur angeklickten Datei. Damit kann dann die Anzeige aufgerufen werden.
                            ConsoleWrite('@@ Zeile: ' & @ScriptLineNumber & ' -> $sPath = ' & $sPath & @CRLF)
                        EndIf
                EndSwitch
        EndSwitch
        Return $GUI_RUNDEFMSG
    EndFunc   ;==>_WM_NOTIFY
    
    Func _CreateRoot(ByRef $idTreeview, $sPath, $bLargeIcons)
        Local $iIndex, $hItem, $sName
        $iIndex = _GUIImageList_GetFileIconIndex($sPath, $bLargeIcons, True)
        $sName = StringRegExpReplace($sPath, '.+\\(.+)', '$1')
        $hItem = _GUICtrlTreeView_AddFirst($idTreeview, 0, $sName, $iIndex, $iIndex)
        $mPathMap[$hItem] = $sPath ; den Pfad anhand des Item-Handle speichern
        Return $hItem
    EndFunc   ;==>_CreateRoot
    
    Func _ReadDirectory(ByRef $idTreeview, $hItem, $sPath, $bLargeIcons)
        Local $iIndex, $aFolder, $aFiles, $hChild = $hItem, $sName
        If StringRight($sPath, 1) <> '\' Then $sPath &= '\'
        $aFolder = _WinAPI_EnumFiles($sPath, 2) ; nur Verzeichnisse einlesen
        If Not @error Then
            For $i = 1 To $aFolder[0][0]
                If Not BitAND($aFolder[$i][6], $FILE_ATTRIBUTE_REPARSE_POINT) And _
                        Not BitAND($aFolder[$i][6], $FILE_ATTRIBUTE_HIDDEN) Then
                    $sName = StringRegExpReplace($sPath & $aFolder[$i][0], '.+\\(.+)', '$1')
                    $iIndex = _GUIImageList_GetFileIconIndex($sPath & $aFolder[$i][0], $bLargeIcons, True)
                    $hChild = _GUICtrlTreeView_AddChild($idTreeview, $hItem, $sName, $iIndex, $iIndex)
                    $mPathMap[$hChild] = $sPath & $aFolder[$i][0] ; den Pfad anhand des Item-Handle speichern
                    _ReadDirectory($idTreeview, $hChild, $sPath & $aFolder[$i][0], $bLargeIcons)
                EndIf
            Next
        EndIf
        _WinAPI_SetCursor($hBusyCur ? $hBusyCur : 9)
        $aFiles = _WinAPI_EnumFiles($sPath, 1, $sFileExtensions) ; nur Dateien einlesen
        If Not @error Then
            For $i = 1 To $aFiles[0][0]
                If Not BitAND($aFiles[$i][6], $FILE_ATTRIBUTE_HIDDEN) Then
                    $sName = StringRegExpReplace($sPath & $aFiles[$i][0], '.+\\(.+)\..+', '$1')
                    $iIndex = _GUIImageList_GetFileIconIndex($sPath & $aFiles[$i][0], $bLargeIcons, True)
                    $hChild = _GUICtrlTreeView_AddChild($idTreeview, $hItem, $sName, $iIndex, $iIndex)
                    $mPathMap[$hChild] = $sPath & $aFiles[$i][0] ; den Pfad anhand des Item-Handle speichern
                EndIf
            Next
        EndIf
    EndFunc   ;==>_ReadDirectory
    
    Func _GUIImageList_GetFileIconIndex($sFilePath, $bLargeIcons = False, $bForceLoadFromDisk = False)
        Local $tFileInfo = DllStructCreate($tagSHFILEINFO)
        Local $iFlags = BitOR($SHGFI_SYSICONINDEX, _
                $bLargeIcons ? $SHGFI_LARGEICON : $SHGFI_SMALLICON, _
                $bForceLoadFromDisk ? 0 : $SHGFI_USEFILEATTRIBUTES)
        Local $ret = _WinAPI_ShellGetFileInfo($sFilePath, $iFlags, $FILE_ATTRIBUTE_NORMAL, $tFileInfo)
        If $ret Then Return DllStructGetData($tFileInfo, 'iIcon')
        Return SetError(1, 0, -1)
    EndFunc   ;==>_GUIImageList_GetFileIconIndex
    Alles anzeigen
  • Datei-Anzeige

    • Oscar
    • 28. August 2023 um 17:44

    Ok, schon gelöst, aber ich habe meine Version auch gerade erst fertig. Also hier noch eine Alternative:

    AutoIt
    #include <APIShellExConstants.au3>
    #include <FileConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiImageList.au3>
    #include <GuiTreeView.au3>
    #include <TreeViewConstants.au3>
    #include <WinAPIFiles.au3>
    #include <WinAPIIcons.au3>
    #include <WinAPIRes.au3>
    #include <WinAPIShellEx.au3>
    #include <WinAPIShPath.au3>
    #include <WindowsConstants.au3>
    
    Opt('GUIOnEventMode', 1)
    
    Global Const $sSearchDir = @UserProfileDir & '\Documents' ; hier das Verzeichnis mit den Dokumenten eintragen
    Global Const $sFileExtensions = '*.pdf;*.docx;*.xlsm' ; die Dateiendungen, die angezeigt werden sollen
    Global Const $bLargeIcons = False ; ob grosse oder kleine Icons benutzt werden sollen
    
    _WinAPI_FileIconInit() ; System-Imagelist initialisieren
    Global $hSystemImgList = _WinAPI_ShellGetImageList(Not $bLargeIcons) ; System-Imagelist holen
    Global $hBusyCur = _WinAPI_LoadCursorFromFile(@WindowsDir & '\Cursors\aero_busy_xl.ani') ; Busy-Animation-Cursor laden
    
    Global $hMainGui = GUICreate('Test', 1000, 600)
    GUISetOnEvent($GUI_EVENT_CLOSE, '_CloseMainGui')
    
    Global $idTreeview = GUICtrlCreateTreeView(10, 10, 400, 580, $GUI_SS_DEFAULT_TREEVIEW, $WS_EX_CLIENTEDGE)
    GUICtrlSetFont(-1, 10 + $bLargeIcons, 400, 0, 'Verdana')
    GUICtrlSetResizing(-1, $GUI_DOCKBOTTOM + $GUI_DOCKTOP + $GUI_DOCKLEFT)
    _GUICtrlTreeView_SetNormalImageList($idTreeview, $hSystemImgList)
    
    Global $hRoot = _CreateRoot($idTreeview, $sSearchDir, $bLargeIcons) ; Root-Eintrag erstellen
    
    GUISetState(@SW_SHOW, $hMainGui)
    
    ; Fuer Mausklicks auf ein Treeview muss man WM_NOTIFY registrieren und dort auswerten
    GUIRegisterMsg($WM_NOTIFY, '_WM_NOTIFY')
    
    ; Den ganzen Verzeichnisbaum rekursiv durchsuchen und im Treeview erstellen (kann lange dauern)
    Global $hOldCur = _WinAPI_SetCursor($hBusyCur ? $hBusyCur : 9)
    _GUICtrlTreeView_BeginUpdate($idTreeview)
    _ReadDirectory($idTreeview, $hRoot, $sSearchDir, $bLargeIcons)
    _GUICtrlTreeView_EndUpdate($idTreeview)
    _WinAPI_SetCursor($hOldCur)
    
    ; zum Schluss den Root-Eintrag aufklappen
    _SendMessage(GUICtrlGetHandle($idTreeview), $TVM_EXPAND, $TVE_EXPAND, $hRoot, 0, 'wparam', 'handle')
    
    While Sleep(1000)
    WEnd
    
    Func _CloseMainGui()
        _GUIImageList_Destroy($hSystemImgList)
        If $hBusyCur Then _WinAPI_DestroyCursor($hBusyCur)
        GUIDelete($hMainGui)
        Exit
    EndFunc   ;==>_CloseMainGui
    
    Func _WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
        #forceref $hWnd, $iMsg, $iwParam
        Local $tNMTREEVIEW, $tNMHDR, $hItem, $hWndFrom, $sPath
        Local $sSepChar = Opt('GUIDataSeparatorChar')
        $tNMTREEVIEW = DllStructCreate($tagNMTREEVIEW, $ilParam)
        $hWndFrom = DllStructGetData($tNMTREEVIEW, 'hWndFrom')
        Switch $hWndFrom
            Case GUICtrlGetHandle($idTreeview)
                Switch DllStructGetData($tNMTREEVIEW, 'Code')
                    Case $TVN_SELCHANGEDA, $TVN_SELCHANGEDW
                        $hItem = DllStructGetData($tNMTREEVIEW, 'NewhItem')
                        If $hItem Then
                            $sPath = StringReplace(_GUICtrlTreeView_GetTree($hWndFrom, $hItem), $sSepChar, '\')
                            ; In $sPath steht der Pfad zur angeklickten Datei. Damit kann dann die Anzeige aufgerufen werden.
                            ConsoleWrite('@@ Zeile: ' & @ScriptLineNumber & ' -> $sPath = ' & $sPath & @CRLF)
                        EndIf
                EndSwitch
        EndSwitch
        Return $GUI_RUNDEFMSG
    EndFunc   ;==>_WM_NOTIFY
    
    Func _CreateRoot(ByRef $idTreeview, $sFolder, $bLargeIcons)
        Local $iIndex, $hItem
        $iIndex = _GUIImageList_GetFileIconIndex($sSearchDir, $bLargeIcons, True)
        $hItem = _GUICtrlTreeView_AddFirst($idTreeview, 0, $sSearchDir, $iIndex, $iIndex)
        Return $hItem
    EndFunc   ;==>_CreateRoot
    
    Func _ReadDirectory(ByRef $idTreeview, $hItem, $sFolder, $bLargeIcons)
        Local $iIndex, $aFolder, $aFiles, $hChild = $hItem
        If StringRight($sFolder, 1) <> '\' Then $sFolder &= '\'
        $aFolder = _WinAPI_EnumFiles($sFolder, 2) ; nur Verzeichnisse einlesen
        If Not @error Then
            For $i = 1 To $aFolder[0][0]
                If Not BitAND($aFolder[$i][6], $FILE_ATTRIBUTE_REPARSE_POINT) And _
                        Not BitAND($aFolder[$i][6], $FILE_ATTRIBUTE_HIDDEN) Then
                    $iIndex = _GUIImageList_GetFileIconIndex($sFolder & $aFolder[$i][0], $bLargeIcons, True)
                    $hChild = _GUICtrlTreeView_AddChild($idTreeview, $hItem, $aFolder[$i][0], $iIndex, $iIndex)
                    _ReadDirectory($idTreeview, $hChild, $sFolder & $aFolder[$i][0], $bLargeIcons)
                EndIf
            Next
        EndIf
        _WinAPI_SetCursor($hBusyCur ? $hBusyCur : 9)
        $aFiles = _WinAPI_EnumFiles($sFolder, 1, $sFileExtensions) ; nur Dateien einlesen
        If Not @error Then
            For $i = 1 To $aFiles[0][0]
                If Not BitAND($aFiles[$i][6], $FILE_ATTRIBUTE_HIDDEN) Then
                    $iIndex = _GUIImageList_GetFileIconIndex($sFolder & $aFiles[$i][0], $bLargeIcons, True)
                    _GUICtrlTreeView_AddChild($idTreeview, $hItem, $aFiles[$i][0], $iIndex, $iIndex)
                EndIf
            Next
        EndIf
    EndFunc   ;==>_ReadDirectory
    
    Func _GUIImageList_GetFileIconIndex($sFilePath, $bLargeIcons = False, $bForceLoadFromDisk = False)
        Local $tFileInfo = DllStructCreate($tagSHFILEINFO)
        Local $iFlags = BitOR($SHGFI_SYSICONINDEX, _
                $bLargeIcons ? $SHGFI_LARGEICON : $SHGFI_SMALLICON, _
                $bForceLoadFromDisk ? 0 : $SHGFI_USEFILEATTRIBUTES)
        Local $ret = _WinAPI_ShellGetFileInfo($sFilePath, $iFlags, $FILE_ATTRIBUTE_NORMAL, $tFileInfo)
        If $ret Then Return DllStructGetData($tFileInfo, 'iIcon')
        Return SetError(1, 0, -1)
    EndFunc   ;==>_GUIImageList_GetFileIconIndex
    Alles anzeigen
  • AV-Programme: False positive

    • Oscar
    • 15. Juni 2023 um 18:51
    Zitat von mumpel

    Danke! Aber so weit bin ich noch nicht.

    Das Forum hier heißt "Hilfe & Unterstützung".

    Also, lass Dir helfen!

    Poste Dein bisheriges Script und schreib, was Du Dir anders wünscht. Ich denke, dass wir Dir da weiterhelfen können.

  • AV-Programme: False positive

    • Oscar
    • 15. Juni 2023 um 16:27
    Zitat von mumpel

    Nur schade, dass die zu klein sind, da kann man die Schrift kaum lesen.

    Dann eine eigene GUI mit InputControl erstellen. Da kannst Du die Schriftart/-größe anpassen.

  • GUI - Möglichkeit mit TAB durch die eigenen Controls zu springen

    • Oscar
    • 14. Juni 2023 um 15:32
    Zitat von Clust3r

    Da ist es aber dann leider so das die eine Combobox mit dem jeweiligen Text komplett markiert ist:

    Wenn es nur bestimmte Einträge gibt, dann am besten eine DropDownList benutzen (s.u.).

    Zitat von Clust3r

    Und die Checkbox kann leider nicht per TAB ausgewählt werden

    Bei den Label immer Länge und Höhe angeben, sonst kommt es zu merkwürdigen "Fehlern".

    AutoIt
    #include <ButtonConstants.au3>
    #include <ComboConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    
    Opt("GUIResizeMode", $GUI_DOCKALL)
    
    ;---Array enthält von allen Controls das Handle
    Global Const $MaxControls = 100
    Global $aHWND[$MaxControls][7]
    
    ;---benutzte Schriftart in den Fenstern
    Global Const $font = "Arial"
    ;---Hintergrundfarbe
    Global Const $BkColor = 0xF0F8FF
    
    CreateGUI()
    
    Func CreateGUI()
        Local $CountProgressbar
        Local $aFileContent[5]
    
        ;Variable für ID von Configgroup
        Local $Configgroup = ""
    
        Local $LastLines = 0
    
        Local $hGUI = GUICreate("Test", 850, 350, 100, 10, -1)
        GUISetBkColor($BkColor) ;Hintergrundfarbe ändern
        GUISetFont(9, 420, 0, $font) ; Schrift ändern
    
        ;---Erstelle "Menü"
        Local $idFileMenu = GUICtrlCreateMenu("Datei")
        Local $idOpenitem = GUICtrlCreateMenuItem("CSV-Datei importieren..", $idFileMenu)
        Local $idExititem = GUICtrlCreateMenuItem("Beenden", $idFileMenu)
    
        Local $bCreate = GUICtrlCreateButton("Erstelle Computer", 560, 275, 125, 35)
        Local $bClose = GUICtrlCreateButton("Beenden", 700, 275, 125, 35)
    
        Local $idLabelPXEAll = GUICtrlCreateLabel("Alle Computer für PXE aktivieren: ", 575, 250)
        Local $idCheckbox = 0
    
        GUICtrlSetState($idLabelPXEAll, $GUI_HIDE)
    
        GUICtrlCreateLabel("Hostname:", 5, 10, 100, 20)
        $aHWND[0][0] = GUICtrlCreateInput("", 5, 30, 105, 20)
    
        GUICtrlCreateLabel("MAC:", 130, 10, 100, 20)
        $aHWND[0][1] = GUICtrlCreateInput("", 130, 30, 105, 20)
    
        GUICtrlCreateLabel("Konfiguration:", 255, 10, 100, 20)
        $aHWND[0][2] = GUICtrlCreateCombo("", 255, 30, 200, 20)
    
        GUICtrlSetData($aHWND[0][2], "Test1|Test2")
    
        GUICtrlCreateLabel("Hardware Typ:", 475, 10, 100, 20)
        $aHWND[0][3] = GUICtrlCreateCombo("Desktop", 475, 30, 130, 20, BitOR($CBS_DROPDOWNLIST, $WS_TABSTOP))
        GUICtrlSetData($aHWND[0][3], "Laptop|Virtual Hardware")
        ;
    
        GUICtrlCreateLabel("Altgerät:", 625, 10, 100, 20)
        $aHWND[0][4] = GUICtrlCreateInput("", 625, 30, 105, 20)
    
        $aHWND[0][5] = GUICtrlCreateButton("...", 735, 30, 15, 15)
    
        GUICtrlCreateLabel("PXE Aktivierung:", 750, 10, 100, 20)
        $aHWND[0][6] = GUICtrlCreateCheckbox("", 780, 32, 15, 15, $BS_PUSHLIKE)
    
    
        For $counter = 1 To UBound($aHWND) - 1
            $aHWND[$counter][5] = -1
        Next
    
        GUISetState(@SW_SHOW)
        GUICtrlSetState($aHWND[0][0], $GUI_FOCUS)
        Local $nMsg
        While 1
            $nMsg = GUIGetMsg()
    
            Switch $nMsg
                Case $GUI_EVENT_CLOSE, $idExititem
                    ExitLoop
                Case $idOpenitem
                Case $bCreate
                Case $idCheckbox
                Case $bClose
                    Exit
            EndSwitch
        WEnd
    EndFunc   ;==>CreateGUI
    Alles anzeigen
  • tabellarische Reporte oder Berichte aus Autoit

    • Oscar
    • 9. Juni 2023 um 16:14
    Zitat von BlutigerAnfänger

    Mit Autoit sollen die Daten generiert werden und es muß nicht (geht auch nicht) mit Autoit ein PDF erstellt werden.

    Welche Daten werden mit AutoIt generiert (Script)?

    Und warum kann man mit AutoIt kein PDF erstellen?

  • tabellarische Reporte oder Berichte aus Autoit

    • Oscar
    • 9. Juni 2023 um 12:03

    Das hat ja offensichtlich nichts mit "Hilfe & Unterstützung" für ein AutoIt-Script zu tun. [verschoben nach Off-Topic]

  • Navigation

    • Oscar
    • 25. Mai 2023 um 16:32

    Ich benutze seit einiger Zeit die App "NUNAV" auf dem Smartphone (Android). Die ist kostenlos und benutzt ebenfalls die Google-Daten zum Straßen-"Füllstand".

    Die App hat auch eine deutsche Sprachausgabe, die dann schon rechtzeitig über die weitere Fahrtrichtung informiert, ohne dass man unbedingt auf das Display schauen muss.

    Mir gefällt die App ganz gut. Vielleicht wäre das auch etwas für Dich.

  • Win XP - alle Netzwerkadapter und Adressen auslesen ohne WMI

    • Oscar
    • 25. Mai 2023 um 09:11
    Zitat von Bebbo

    anbei der Komplette Code:

    Du solltest nicht die benutzten Funktionen aus den UDFs herauskopieren und in Dein Script einfügen, sondern mit "Include" arbeiten.

    Ich habe Dein Script mal dahingehend angepasst (und mit Tidy formatiert):

    AutoIt
    #include <Array.au3>
    #include <ComboConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GuiIPAddress.au3>
    #include <IPAddressConstants.au3>
    #include <StaticConstants.au3>
    #include <StructureConstants.au3>
    #include <WindowsConstants.au3>
    
    Global Const $oMyError = ObjEvent("AutoIt.Error", "oMyError")
    $hGUI = GUICreate("IP Test", 423, 123)
    GUISetFont(9, 400, 0, "Arial")
    TrayTip("Information", "Reading network setting. Please wait...", 10, 1)
    $aNetworkAdapters = _WMI_GetNetworkAdapterNames()
    TrayTip("", "", 0)
    $iComboBox = GUICtrlCreateCombo("", 220, 15, 180, 20, $CBS_DROPDOWN + $CBS_AUTOHSCROLL)
    Global $sNetworkAdapters, $z
    For $z = 0 To UBound($aNetworkAdapters) - 1
        $sNetworkAdapters &= $aNetworkAdapters[$z][0] & "|"
    Next
    GUICtrlSetData($iComboBox, StringTrimRight($sNetworkAdapters, 1), $aNetworkAdapters[0][0])
    $sCurrentIP = GUICtrlCreateLabel("Current IP:", 16, 18, 62, 19, $SS_RIGHT)
    $hCurrenIP = _GUICtrlIpAddress_Create($hGUI, 84, 16, 130, 21)
    _GUICtrlIpAddress_Set($hCurrenIP, $aNetworkAdapters[0][1])
    $sNewIP = GUICtrlCreateLabel("New IP:", 16, 53, 62, 19, $SS_RIGHT)
    $hNewIP = _GUICtrlIpAddress_Create($hGUI, 84, 51, 130, 21)
    _GUICtrlIpAddress_Set($hNewIP, "172.22.10.10")
    $sDefaultGateway = GUICtrlCreateLabel("Gateway:", 16, 85, 62, 19, $SS_RIGHT)
    $hDefaultGateway = _GUICtrlIpAddress_Create($hGUI, 84, 83, 130, 21)
    _GUICtrlIpAddress_Set($hDefaultGateway, "172.22.10.1")
    $iBtnOK = GUICtrlCreateButton("OK", 232, 80, 75, 25)
    GUISetState(@SW_SHOW)
    GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                GUIRegisterMsg($WM_NOTIFY, "")
                GUIDelete()
                Exit
            Case $iBtnOK
                MsgBox(0, "Einstellungen werden gesetzt.....", "Interface Name: " & $aNetworkAdapters[_ArraySearch($aNetworkAdapters, GUICtrlRead($iComboBox))][0] & @CRLF & "New IP: " & _GUICtrlIpAddress_Get($hNewIP) & @CRLF & "Default Gateway: " & _GUICtrlIpAddress_Get($hDefaultGateway))
            Case $iComboBox
                _GUICtrlIpAddress_Set($hCurrenIP, $aNetworkAdapters[_ArraySearch($aNetworkAdapters, GUICtrlRead($iComboBox))][1])
        EndSwitch
    WEnd
    Func _WMI_GetNetworkAdapterNames($sHost = ".")
        If $sHost = "." Then $sHost = @ComputerName
        Local $objWMI = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\" & $sHost & "\root\cimv2")
        Local $oItems1 = $objWMI.InstancesOf("Win32_NetworkAdapter")
        Local $oItems2, $oTokens1, $oTokens2, $aIP, $sIPAddresses, $aResult[100][2], $i = 0
        For $oTokens1 In $oItems1
            $aResult[$i][0] = $oTokens1.NetConnectionID
            $oItems2 = $objWMI.InstancesOf('Win32_NetworkAdapterConfiguration WHERE Description="' & $oTokens1.Name & '"')
            For $oTokens2 In $oItems2
                $aIP = $oTokens2.IPAddress
                For $j = 0 To UBound($aIP) - 1
                    If StringRegExp($aIP[$j], "(\d+\.\d+\.\d+\.\d+)", 0) Then $aResult[$i][1] = $aIP[$j]
                Next
                $i += 1
            Next
        Next
        If $i > 0 Then
            ReDim $aResult[$i][2]
            Return $aResult
        EndIf
        Return SetError(1, 0, 0)
    EndFunc   ;==>_WMI_GetNetworkAdapterNames
    Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
        #forceref $hWnd, $iMsg, $iwParam
        Local $hWndFrom, $iCode, $tNMHDR
        $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
        $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
        $iCode = DllStructGetData($tNMHDR, "Code")
        Switch $hWndFrom
            Case $hNewIP
                Switch $iCode
                    Case $IPN_FIELDCHANGED
                        Local $aIP = _GUICtrlIpAddress_GetArray($hNewIP)
                        $aIP[3] = "1"
                        _GUICtrlIpAddress_SetArray($hDefaultGateway, $aIP)
                EndSwitch
            Case $hDefaultGateway
                Switch $iCode
                    Case $IPN_FIELDCHANGED
                        Local $aIP = _GUICtrlIpAddress_GetArray($hDefaultGateway)
                        $aIP[3] = "1"
                        _GUICtrlIpAddress_SetArray($hDefaultGateway, $aIP)
                EndSwitch
        EndSwitch
        Return "GUI_RUNDEFMSG"
    EndFunc   ;==>WM_NOTIFY
    Func oMyError()
        ConsoleWrite(@CRLF & @CRLF & "We intercepted a COM Error !" & @CRLF & @CRLF & "err.description is: " & @TAB & $oMyError.Description & @CRLF & "err.windescription:" & @TAB & $oMyError.WinDescription & @CRLF & "err.number is: " & @TAB & Hex($oMyError.Number, 8) & @CRLF & "err.lastdllerror is: " & @TAB & $oMyError.LastDllError & @CRLF & "err.scriptline is: " & @TAB & $oMyError.Scriptline & @CRLF & "err.source is: " & @TAB & $oMyError.Source & @CRLF & "err.helpfile is: " & @TAB & $oMyError.Helpfile & @CRLF & "err.helpcontext is: " & @TAB & $oMyError.HelpContext & @CRLF & @CRLF)
    EndFunc   ;==>oMyError
    Alles anzeigen
  • MsgBox hooken und Countdown hinzufügen

    • Oscar
    • 27. April 2023 um 05:14
    Zitat von UEZ

    Ich möchte gerne einen Countdown in das Ok Button hinzufügen, das die vorgebene Zeit herunter zählt.

    Es gäbe da auch noch die Möglichkeit mittels der Timer-UDF:

    AutoIt
    #include <MsgBoxConstants.au3>
    #include <Timers.au3>
    
    Global $hDummyGui = GUICreate('dummy')
    Global $iSec = 10
    _Timer_SetTimer($hDummyGui, 1000, '_ShowSeconds')
    
    MsgBox($MB_ICONQUESTION, 'Time-Test', 'Diese MsgBox wird nach ' & $iSec & ' Sekunden geschlossen!', $iSec)
    
    _Timer_KillAllTimers($hDummyGui)
    
    Func _ShowSeconds($hWnd, $Msg, $iIDTimer, $dwTime)
        #forceref $hWnd, $Msg, $iIDTimer, $dwTime
        $iSec -= 1
        ControlSetText('Time-Test', '', '[CLASS:Button; INSTANCE:1]', 'Ok  ' & $iSec & 's')
    EndFunc
    Alles anzeigen
  • [Gelöst] GDIPlus Image hat falsche Größe

    • Oscar
    • 25. April 2023 um 13:36
    Zitat von Mars

    und ein Skript das die Bilder via _GDIPlus_GraphicsDrawImage anzeigt.

    Danke! Jetzt weiß ich wenigstens woran es liegt.

    Den Effekt mit _GDIPlus_GraphicsDrawImage hatte ich schon öfter und habe dann immer _GDIPlus_GraphicsDrawImageRect verwendet, aber bisher konnte ich die Ursache nicht entdecken.

  • [offen] wNim wListCtrl sortieren - wie?

    • Oscar
    • 21. April 2023 um 08:47
    Zitat von BugFix

    das nenn ich mal geschmeidig.

    Naja, noch nicht ganz! Die globalen Variablen stören noch.

    Ich habe das Ganze noch etwas umgebaut, sodass nur statische Variablen benötigt werden:

    Nim
    import wNim, random, winim
    randomize()
    let app = App()
    let frame = Frame(title="ListviewSort", size=(640, 520))
    let panel = Panel(frame)
    let idPlaylist = ListCtrl(panel, style=wLcReport or wBorderSimple, pos=(10, 10), size=(600, 400))
    idPlaylist.font = Font(14, faceName="Arial", weight=wFontWeightNormal)
    idPlaylist.setBackgroundColor(0x00DDDDDD)
    idPlaylist.appendColumn("Interpret", width=200, format=wListFormatLeft)
    idPlaylist.appendColumn("Titel", width=200, format=wListFormatLeft)
    idPlaylist.appendColumn("Laufzeit", width=110, format=wListFormatRight)
    
    # Ein paar Beispieldaten in das Listview eintragen
    idPlaylist.appendItem(["ZZ Down", "Gimme All", "03:53"])
    idPlaylist.appendItem(["Johnson Twins", "Bla bla", "04:16"])
    idPlaylist.appendItem(["Kniff Richard", "Yeah", "05:11"])
    idPlaylist.appendItem(["Roller Stones", "Gimme Shelter", "04:03"])
    idPlaylist.appendItem(["Ralph a Ville", "Moin", "03:46"])
    
    # Callback-Funktion zum sortieren der Eintraege
    # "item1" und "item2" sind die Indexe der zu sortierenden Eintraege
    # "data" enthaelt die Spalte zum sortieren (1-basiert). Positiv = aufwaerts, Negativ = abwaerts
    proc sortCmp(item1: int; item2: int; data: int): int =
      result = cmp(idPlaylist.getItemText(item1, abs(data) - 1), idPlaylist.getItemText(item2, abs(data) - 1))
      if data < 0: result *= -1
    
    # Funktion zum setzen/loeschen des Sortierpfeils
    proc setSortArrow(self: wListCtrl, idx: int, arrow: range[-1..1]): bool {.discardable.} =
      var hdrItem: HDITEMA
      let header = HWND SendMessage(self.mHwnd, LVM_GETHEADER, 0, 0)
      if header != 0:
        hdrItem.mask = HDI_FORMAT # Maske auf Format setzen
        if SendMessage(header, HDM_GETITEM, cast[WPARAM](idx), cast[LPARAM](&hdrItem)) != 0:
          case arrow: # je nach Uebergabewert beim Format
            of 0: # beide Pfeile entfernen
              hdrItem.fmt = hdrItem.fmt and not(HDF_SORTUP or HDF_SORTDOWN)
            of 1: # Sortdown-Pfeil setzen
              hdrItem.fmt = hdrItem.fmt and not HDF_SORTUP or HDF_SORTDOWN
            of -1: # Sortup-Pfeil setzen
              hdrItem.fmt = hdrItem.fmt and not HDF_SORTDOWN or HDF_SORTUP
          return SendMessage(header, HDM_SETITEM, cast[WPARAM](idx), cast[LPARAM](&hdrItem)) != 0
      return false
    
    # Beim Klick auf einen Spalten-Header
    idPlaylist.wEvent_ListColClick do (event: wEvent):
      var
        iSortDir {.global.}: range[-1..1] = 1 # statische Variable (Sortier-Richtung)
        iOldCol {.global.}: int = 0 # statische Variable (letzte Sortier-Spalte)
        iSortCol: int
      iSortCol = event.getColumn() + 1 # die Spalte ermitteln
      if iSortCol == iOldCol: # wenn die gleiche Spalte wie vorher
        iSortDir = -iSortDir # Sortierrichtung umdrehen
        if iSortDir < 0: iSortCol = -iSortCol # wenn abwaerts, dann negativer Spaltenwert
      else: # ansonsten
        iSortDir = 1 # Sortier-Richtung auf aufsteigend setzen
        idPlaylist.setSortArrow(iOldCol - 1, 0) # Pfeil von der alten Spalte entfernen
      iOldCol = abs(iSortCol) # die Sortier-Spalte merken
      idPlaylist.setSortArrow(iOldCol - 1, iSortDir) # je nach Sortier-Richtung den Pfeil setzen
      idPlaylist.sortItemsByIndex(sortCmp, iSortCol) # und das Listview sortieren (Callback fuer den Vergleich)
    
    frame.center()
    frame.show()
    app.mainLoop()
    Alles anzeigen

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™