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

Beiträge von Bitnugger

  • ListView Groups - ein kleines Beispiel

    • Bitnugger
    • 5. Juni 2018 um 19:11
    Zitat von kra88

    Kann man Groups auch per drag an Drop in ein Zweites Listview kopieren und ausschneiden? Mit und ohne Groups?

    Generell ja, doch dafür gibt es keine nativen Funktionen in AutoIt und ich kenne auch keine AutoIt-UDF, die das ermöglicht. Mir fehlt momentan aber leider die Zeit, um mich eingehender mit dem Thema zu befassen.

    Hier Additional functions for AHK ListView controls kann man evtl. einige Stellen abkupfern.

    Zitat von kra88

    Ich möchte gerne Groups mit verschiedenen positionen in Listview 1 anlegen.

    Dafür gibt es in AutoIt auch keine direkte Möglichkeit. Als Workaround könntest du aber Groups mit leerem Titel mit _GUICtrlListView_InsertGroup einfügen. Diese müssen mindestens 1 Item enthalten, damit sie angezeigt werden.

    Um alle Groups frei zu positionieren, wirst du wohl nicht drum herum kommen, für jede Group ein eigenes ListView (ohne Header) und den Header separat zu erstellen.

    Zitat von kra88

    Danach möchte ich von Listview 1 die Group per Mouse drag in Listview 2 kopieren, dabei soll nur der Inhalt der Group kopiert werden an die Positionen wo die Mouse losgelassen wird.

    Dafür gibt es in AutoIt auch keine direkte Möglichkeit. Als Inspiration für eine eigene Funktion würde ich in der Hilfe nach *drag* suchen.

  • ListView Groups - ein kleines Beispiel

    • Bitnugger
    • 4. Juni 2018 um 20:48
    Zitat von nuts

    Hast du ne Ahnung ob man auch leere Gruppen ohne Items erstellen und anzeigen kann?

    Erstellen kannst du Groups jederzeit, aber angezeigt werden sie erst, wenn sich mindestens 1 Item in der Group befindet. Wird das letzte Item aus der Group gelöscht/verschoben, wird die Group ausgeblendet. Als Workaround kannst du aber ein Item ohne oder mit einem speziellen Text hinzufügen und das Flag für die Group dann auf $LVGS_COLLAPSED setzen, dass du wieder löscht, sobald ein weiteres Item hinzukommt.

    Die Groups kannst du in etwa mit einem Schreibblock vergleichen... was kümmert es dich, wie viele leere Blätter dieser noch enthält, solange es mehr als 0 sind? Du kannst also z. B. 200 Groups anlegen... und benutzt aber nur 25... und wenn du noch mehr brauchst, legst du einfach noch welche an. Hauptsächlich relevant ist doch nur, ob etwas in der Group ist oder nicht...

    Edit: Hier noch ein Beispiel, bei dem du sehen kannst, dass Groups erst angezeigt werden, wenn mindestens 1 Item in der Group ist... das wird hinzugefügt, wenn du den ersten Doppelklick auf einen Group-Titel machst.

    AutoIt
    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_Change2CUI=y
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    
    ;-- TIME_STAMP   2018-06-04 21:05:54   v 0.1
    
    #Region    ;************ Includes ************
    #include <GUIConstantsEx.au3>
    #include <GuiImageList.au3>
    #include <GuiListView.au3>
    #include <WindowsConstants.au3>
    ;~ #include <MsgBoxConstants.au3>;~~~
    #EndRegion ;************ Includes ************
    
    ;~ https://www.autoitscript.com/forum/topic/169182-listview-group-wm_notify-trigger/
    ;~ https://www.zabkat.com/blog/05Feb12-collapsible-listview.htm
    
    ;~    $LVGS_NORMAL               0
    ;~    $LVGS_COLLAPSED            1
    ;~    $LVGS_HIDDEN               2
    ;~    $LVGS_NOHEADER             4
    ;~    $LVGS_COLLAPSIBLE          8
    ;~    $LVGS_FOCUSED             16
    ;~    $LVGS_SELECTED            32
    ;~    $LVGS_SUBSETED            64
    ;~    $LVGS_SUBSETLINKFOCUSED  128
    
    Opt('MustDeclareVars', 1)
    
    Global $g_idListview, $g_hListView
    
    Global Const $LVN_GROUPINFO = ($LVN_FIRST - 88)
    Global Const $tagNMLVGROUP = $tagNMHDR & ";int iGroupId;uint iNewState;uint iOldState"
    
    Example()
    
    Func Example()
        Local $aInfo, $hImage, $g_idListview
    
        GUICreate("ListView Group COLLAPSIBLE", 400, 300)
    
        $g_idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
        $g_hListView = GUICtrlGetHandle($g_idListview)
        GUISetState(@SW_SHOW)
    
        ; Load images
        $hImage = _GUIImageList_Create()
        _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_idListview, 0xFF0000, 16, 16))
        _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_idListview, 0x00FF00, 16, 16))
        _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_idListview, 0x0000FF, 16, 16))
        _GUICtrlListView_SetImageList($g_idListview, $hImage, 1)
    
        ; Add columns
        _GUICtrlListView_AddColumn($g_idListview, "Column 1", 100)
        _GUICtrlListView_AddColumn($g_idListview, "Column 2", 100)
        _GUICtrlListView_AddColumn($g_idListview, "Column 3", 100)
    
        ; Add items
        _GUICtrlListView_AddItem($g_idListview,       "Row 1: Col 1", 0)
        _GUICtrlListView_AddSubItem($g_idListview, 0, "Row 1: Col 2", 1)
        _GUICtrlListView_AddSubItem($g_idListview, 0, "Row 1: Col 3", 2)
        _GUICtrlListView_AddItem($g_idListview,       "Row 2: Col 1", 1)
        _GUICtrlListView_AddSubItem($g_idListview, 1, "Row 2: Col 2", 1)
        _GUICtrlListView_AddItem($g_idListview,       "Row 3: Col 1", 2)
        _GUICtrlListView_AddItem($g_idListview,       "Row 4: Col 1", 0)
    
        ; Build groups
        _GUICtrlListView_EnableGroupView($g_idListview)
        _GUICtrlListView_InsertGroup($g_idListview, -1, 1, "Group 1", 0)
    ;~     _GUICtrlListView_SetGroupInfo($g_idListview, 1, "Group 1", 0, BitOR($LVGS_COLLAPSIBLE, $LVGS_COLLAPSED))
        _GUICtrlListView_SetGroupInfo($g_idListview, 1, "Group 1", 0, $LVGS_COLLAPSIBLE)
    
        _GUICtrlListView_InsertGroup($g_idListview, -1, 2, "Group 2")
        _GUICtrlListView_SetGroupInfo($g_idListview, 2, "Group 2 ~ 2/8", 0, BitOR($LVGS_COLLAPSIBLE, $LVGS_COLLAPSED))
        _GUICtrlListView_SetItemGroupID($g_idListview, 0, 1)
        _GUICtrlListView_SetItemGroupID($g_idListview, 1, 2)
        _GUICtrlListView_SetItemGroupID($g_idListview, 2, 2)
    
        _GUICtrlListView_InsertGroup($g_hListView, -1, 3, "Group 3", 0)
        _GUICtrlListView_SetGroupInfo($g_idListview, 3, "Group 3", 0, BitOR($LVGS_NORMAL, $LVGS_COLLAPSIBLE))
    
    ;~     Local $aGroupItems = _GUICtrlListView_GetItemsInGroups($g_idListview)
    ;~     _ArrayDisplay($aGroupItems, '$aGroupItems')
    ;~     Exit
    
        GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
    
        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
    
        GUIDelete()
    EndFunc   ;==>Example
    
    ; #FUNCTION# ====================================================================================================================
    ; Name ..........: _GUICtrlListView_GetItemsInGroups
    ; Description ...: Detects all member for a all groups
    ; Syntax ........: _GUICtrlListView_GetItemInGroups($hWnd)
    ; Parameters ....: $hWnd               - The listview handle
    ; Return values .: Success             Array with listview index of all member from all group
    ; ...............:                     [0][0] = count groups
    ; ...............:                     [1 .. n][] = Group ID (equal with array index)
    ; ...............:                     [n][0] = count item in group "n", [n][1....] = the item listview-index
    ; ...............: Failure             0  @error=1  listview has no item
    ; ...............:                        @error=2  no groups
    ; Author ........: BugFix
    ; Modified ......: Bitnugger
    ; ===============================================================================================================================
    Func _GUICtrlListView_GetItemsInGroups($hWnd)
        Local $iGroupID, $iGroupMax, $iItemMax
        Local $iCount = _GUICtrlListView_GetItemCount($hWnd)
        If Not $iCount Then Return SetError(3,0,0)
        Local $iColCount = _GUICtrlListView_GetColumnCount($hWnd)
        If $iCount = 0 Then Return SetError(1,0,0)
        Local $aGroupItems[$iCount+1][$iColCount+1], $iGroupID, $iGroupMax=0, $iItemMax = 0
        For $i = 0 To $iCount -1
            $iGroupID = _GUICtrlListView_GetItemGroupID($hWnd, $i)
            If $iGroupID < 1 Then ContinueLoop
            $iGroupMax = $iGroupID < $iGroupMax ? $iGroupMax : $iGroupID
            $aGroupItems[$iGroupID][0] += 1
            $aGroupItems[$iGroupID][ $aGroupItems[$iGroupID][0] ] = $i
            $iItemMax = $aGroupItems[$iGroupID][0] > $iItemMax ? $aGroupItems[$iGroupID][0] : $iItemMax
        Next
        If $iGroupMax = 0 Then Return SetError(2,0,0)
        $aGroupItems[0][0] = $iGroupMax
        ReDim $aGroupItems[$iGroupMax +1][$iItemMax+1]
        ConsoleWrite('$aGroupItems = ' & _ArrayToString($aGroupItems, ', ', -1, -1, ' | ') & @CRLF)
        Return $aGroupItems
    EndFunc  ;==>_GUICtrlListView_GetItemsInGroups
    
    Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
        #forceref $hWnd, $iMsg, $wParam
        Local Static $iGroup3
        Local $tInfo, $tNMHDR = DllStructCreate($tagNMHDR, $lParam), $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
        Local $iIDFrom = DllStructGetData($tNMHDR, "IDFrom"), $iCode = DllStructGetData($tNMHDR, "Code")
        Local $iIndex
        Switch $hWndFrom
            Case $g_hListView
                Switch $iCode
                    Case $LVN_GROUPINFO ; A Group was clicked
                        $tInfo = DllStructCreate($tagNMLVGROUP, $lParam)
                        Local $iState = DllStructGetData($tInfo, "iNewState"), $iGroupId = DllStructGetData($tInfo, "iGroupId")
                        Local $aGroupInfo = _GUICtrlListView_GetGroupInfo($g_hListView,$iGroupId), $sTitle = $aGroupInfo[0]
                        Local $aItemsInGroups = _GUICtrlListView_GetItemsInGroups($g_hListView)
                        If UBound($aItemsInGroups) < 4 Then _GUICtrlListView_SetItemGroupID($g_hListView, 3, 3) ; <<=====
                        $iIndex = _ArraySearch($aItemsInGroups, $iGroupId)
                        If Not @error Then
                            Switch True
                                Case BitAND($iState, $LVGS_COLLAPSED)
                                    $iState = BitAND($iState, $LVGS_COLLAPSIBLE)
                                    $sTitle &= ' ~ ' & $aItemsInGroups[$iIndex][0] & '/8'
                                Case Else
                                    $iState = BitAND($iState, BitOR($LVGS_COLLAPSIBLE, $LVGS_COLLAPSED))
                                    $sTitle = StringRegExpReplace($sTitle, '(.+) ~.+', '\1')
                            EndSwitch
                            _GUICtrlListView_SetGroupInfo($g_hListView, $iGroupId, $sTitle, 0, $iState)
                        Else
                            ConsoleWrite('! #Error: WM_NOTIFY --> _GUICtrlListView_GetItemsInGroups' & @CRLF)
                        EndIf
                        _DebugPrint("$LVN_GROUPINFO" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                                "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                                "-->Code:" & @TAB & $iCode & @CRLF & _
                                "-->GroupId:" & @TAB & DllStructGetData($tInfo, "iGroupId") & @CRLF & _
                                "-->NewState:" & @TAB & DllStructGetData($tInfo, "iNewState") & @CRLF & _
                                "-->OldState:" & @TAB & DllStructGetData($tInfo, "iOldState") & @CRLF)
    ;~                             DllStructSetData($tInfo, 'iNewState', BitOR(DllStructGetData($tInfo, 'iNewState'), $LVGS_SELECTED))
                                Local $sState, $iState = DllStructGetData($tInfo, "iNewState")
                                If $iState Then
                                If BitAND($iState, $LVGS_COLLAPSED  ) Then $sState = '$LVGS_COLLAPSED'
                                If BitAND($iState, $LVGS_HIDDEN     ) Then $sState &= ', $LVGS_HIDDEN'
                                If BitAND($iState, $LVGS_NOHEADER   ) Then $sState &= ', $LVGS_NOHEADER'
                                If BitAND($iState, $LVGS_COLLAPSIBLE) Then $sState &= ', $LVGS_COLLAPSIBLE'
                                If BitAND($iState, $LVGS_FOCUSED    ) Then $sState &= ', $LVGS_FOCUSED'
                                If BitAND($iState, $LVGS_SELECTED   ) Then $sState &= ', $LVGS_SELECTED'
                                Else
                                    $sState = '$LVGS_NORMAL'
                                EndIf
                                If StringLeft($sState, 2) = ', ' Then $sState = StringMid($sState, 3)
    ;~                             ConsoleWrite('--> $iMask  = 0x' & Hex($iMask) & @CRLF)
    ;~                             ConsoleWrite('--> GroupID = ' & DllStructGetData($tGroup, "GroupID") & @CRLF)
    ;~                             ConsoleWrite('--> cItems  = ' & DllStructGetData($tGroup, "cItems") & @CRLF)
                                ConsoleWrite('--> State   = 0x' & Hex($iState, 2) & ' (' & $sState & ')' & @CRLF)
                    Case $LVN_COLUMNCLICK ; A column was clicked    Local $sState
                        $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                        _DebugPrint("$LVN_COLUMNCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                                "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                                "-->Code:" & @TAB & $iCode & @CRLF & _
                                "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                                "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                                "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                                "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                                "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                                "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                                "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                                "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                        ; No return value
                    Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
                        $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                        _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                                "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                                "-->Code:" & @TAB & $iCode & @CRLF & _
                                "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                                "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                                "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                                "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                                "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                                "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                                "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                                "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                                "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                        ; No return value
    ;~                 Case $LVN_GETDISPINFO
    ;~                     ConsoleWrite('> Case $LVN_GETDISPINFO' & @CRLF)
                EndSwitch
        EndSwitch
        Return $GUI_RUNDEFMSG
    EndFunc   ;==>WM_NOTIFY
    
    Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
        ConsoleWrite( _
                "!===========================================================" & @CRLF & _
                "+======================================================" & @CRLF & _
                "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
                "+======================================================" & @CRLF)
    EndFunc   ;==>_DebugPrint
    Alles anzeigen
  • ListView Groups - ein kleines Beispiel

    • Bitnugger
    • 4. Juni 2018 um 19:42

    Mit einem Doppelklick auf den Titel der Gruppe kann man diese öffnen/schließen...

    AutoIt
    #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
    #AutoIt3Wrapper_Change2CUI=y
    #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
    
    ;-- TIME_STAMP   2018-06-04 19:34:13   v 0.1
    
    #Region    ;************ Includes ************
    #include <GUIConstantsEx.au3>
    #include <GuiImageList.au3>
    #include <GuiListView.au3>
    #include <WindowsConstants.au3>
    ;~ #include <MsgBoxConstants.au3>;~~~
    #EndRegion ;************ Includes ************
    
    ;~ https://www.autoitscript.com/forum/topic/169182-listview-group-wm_notify-trigger/
    ;~ https://www.zabkat.com/blog/05Feb12-collapsible-listview.htm
    
    ;~    $LVGS_NORMAL               0
    ;~    $LVGS_COLLAPSED            1
    ;~    $LVGS_HIDDEN               2
    ;~    $LVGS_NOHEADER             4
    ;~    $LVGS_COLLAPSIBLE          8
    ;~    $LVGS_FOCUSED             16
    ;~    $LVGS_SELECTED            32
    ;~    $LVGS_SUBSETED            64
    ;~    $LVGS_SUBSETLINKFOCUSED  128
    
    Opt('MustDeclareVars', 1)
    
    Global $g_idListview, $g_hListView
    
    Global Const $LVN_GROUPINFO = ($LVN_FIRST - 88)
    Global Const $tagNMLVGROUP = $tagNMHDR & ";int iGroupId;uint iNewState;uint iOldState"
    
    Example()
    
    Func Example()
        Local $aInfo, $hImage, $g_idListview
    
        GUICreate("ListView Group COLLAPSIBLE", 400, 300)
    
        $g_idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
        $g_hListView = GUICtrlGetHandle($g_idListview)
        GUISetState(@SW_SHOW)
    
        ; Load images
        $hImage = _GUIImageList_Create()
        _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_idListview, 0xFF0000, 16, 16))
        _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_idListview, 0x00FF00, 16, 16))
        _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($g_idListview, 0x0000FF, 16, 16))
        _GUICtrlListView_SetImageList($g_idListview, $hImage, 1)
    
        ; Add columns
        _GUICtrlListView_AddColumn($g_idListview, "Column 1", 100)
        _GUICtrlListView_AddColumn($g_idListview, "Column 2", 100)
        _GUICtrlListView_AddColumn($g_idListview, "Column 3", 100)
    
        ; Add items
        _GUICtrlListView_AddItem($g_idListview,       "Row 1: Col 1", 0)
        _GUICtrlListView_AddSubItem($g_idListview, 0, "Row 1: Col 2", 1)
        _GUICtrlListView_AddSubItem($g_idListview, 0, "Row 1: Col 3", 2)
        _GUICtrlListView_AddItem($g_idListview,       "Row 2: Col 1", 1)
        _GUICtrlListView_AddSubItem($g_idListview, 1, "Row 2: Col 2", 1)
        _GUICtrlListView_AddItem($g_idListview,       "Row 3: Col 1", 2)
    
        ; Build groups
        _GUICtrlListView_EnableGroupView($g_idListview)
        _GUICtrlListView_InsertGroup($g_idListview, -1, 1, "Group 1", 1)
    ;~     _GUICtrlListView_SetGroupInfo($g_idListview, 1, "Group 1", 0, BitOR($LVGS_COLLAPSIBLE, $LVGS_COLLAPSED))
        _GUICtrlListView_SetGroupInfo($g_idListview, 1, "Group 1", 0, $LVGS_COLLAPSIBLE)
        _GUICtrlListView_InsertGroup($g_idListview, -1, 2, "Group 2")
        _GUICtrlListView_SetGroupInfo($g_idListview, 2, "Group 2 ~ 2/8", 0, BitOR($LVGS_COLLAPSIBLE, $LVGS_COLLAPSED))
        _GUICtrlListView_SetItemGroupID($g_idListview, 0, 1)
        _GUICtrlListView_SetItemGroupID($g_idListview, 1, 2)
        _GUICtrlListView_SetItemGroupID($g_idListview, 2, 2)
    
    ;~     Local $aGroupItems = _GUICtrlListView_GetItemsInGroups($g_idListview)
    ;~     _ArrayDisplay($aGroupItems, '$aGroupItems')
    
        GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
    
        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
    
        GUIDelete()
    EndFunc   ;==>Example
    
    ; #FUNCTION# ====================================================================================================================
    ; Name ..........: _GUICtrlListView_GetItemsInGroups
    ; Description ...: Detects all member for a all groups
    ; Syntax ........: _GUICtrlListView_GetItemInGroups($hWnd)
    ; Parameters ....: $hWnd               - The listview handle
    ; Return values .: Success             Array with listview index of all member from all group
    ; ...............:                     [0][0] = count groups
    ; ...............:                     [1 .. n][] = Group ID (equal with array index)
    ; ...............:                     [n][0] = count item in group "n", [n][1....] = the item listview-index
    ; ...............: Failure             0  @error=1  listview has no item
    ; ...............:                        @error=2  no groups
    ; Author ........: BugFix
    ; Modified ......: Bitnugger
    ; ===============================================================================================================================
    Func _GUICtrlListView_GetItemsInGroups($hWnd)
        Local $iGroupID, $iGroupMax, $iItemMax
        Local $iCount = _GUICtrlListView_GetItemCount($hWnd)
        Local $iColCount = _GUICtrlListView_GetColumnCount($hWnd)
        If $iCount = 0 Then Return SetError(1,0,0)
        Local $aGroupItems[$iCount+1][$iColCount+1], $iGroupID, $iGroupMax=0, $iItemMax = 0
        For $i = 0 To $iCount -1
            $iGroupID = _GUICtrlListView_GetItemGroupID($hWnd, $i)
            $iGroupMax = $iGroupID < $iGroupMax ? $iGroupMax : $iGroupID
            $aGroupItems[$iGroupID][0] += 1
            $aGroupItems[$iGroupID][ $aGroupItems[$iGroupID][0] ] = $i
            $iItemMax = $aGroupItems[$iGroupID][0] > $iItemMax ? $aGroupItems[$iGroupID][0] : $iItemMax
        Next
        If $iGroupMax = 0 Then Return SetError(2,0,0)
        $aGroupItems[0][0] = $iGroupMax
        ReDim $aGroupItems[$iGroupMax +1][$iItemMax+1]
        Return $aGroupItems
    EndFunc  ;==>_GUICtrlListView_GetItemsInGroups
    
    Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
        #forceref $hWnd, $iMsg, $wParam
        Local $tInfo, $tNMHDR = DllStructCreate($tagNMHDR, $lParam), $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
        Local $iIDFrom = DllStructGetData($tNMHDR, "IDFrom"), $iCode = DllStructGetData($tNMHDR, "Code")
        Local $iIndex, $iGroupId
        Switch $hWndFrom
            Case $g_hListView
                Switch $iCode
                    Case $LVN_GROUPINFO ; A Group was clicked
                        $tInfo = DllStructCreate($tagNMLVGROUP, $lParam)
                        Local $iState = DllStructGetData($tInfo, "iNewState"), $iGroupId = DllStructGetData($tInfo, "iGroupId")
                        Local $aGroupInfo = _GUICtrlListView_GetGroupInfo($g_hListView,$iGroupId), $sTitle = $aGroupInfo[0]
                        Local $aItemsInGroups = _GUICtrlListView_GetItemsInGroups($g_hListView)
                        $iIndex = _ArraySearch($aItemsInGroups, $iGroupId)
                        If Not @error Then
                            Switch True
                                Case BitAND($iState, $LVGS_COLLAPSED)
                                    $iState = BitAND($iState, $LVGS_COLLAPSIBLE)
                                    $sTitle &= ' ~ ' & $aItemsInGroups[$iIndex][0] & '/8'
                                Case Else
                                    $iState = BitAND($iState, BitOR($LVGS_COLLAPSIBLE, $LVGS_COLLAPSED))
                                    $sTitle = StringRegExpReplace($sTitle, '(.+) ~.+', '\1')
                            EndSwitch
                            _GUICtrlListView_SetGroupInfo($g_hListView, $iGroupId, $sTitle, 0, $iState)
                        Else
                            ConsoleWrite('! #Error: WM_NOTIFY --> _GUICtrlListView_GetItemsInGroups' & @CRLF)
                        EndIf
                        _DebugPrint("$LVN_GROUPINFO" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                                "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                                "-->Code:" & @TAB & $iCode & @CRLF & _
                                "-->GroupId:" & @TAB & DllStructGetData($tInfo, "iGroupId") & @CRLF & _
                                "-->NewState:" & @TAB & DllStructGetData($tInfo, "iNewState") & @CRLF & _
                                "-->OldState:" & @TAB & DllStructGetData($tInfo, "iOldState") & @CRLF)
    ;~                             DllStructSetData($tInfo, 'iNewState', BitOR(DllStructGetData($tInfo, 'iNewState'), $LVGS_SELECTED))
                                Local $sState, $iState = DllStructGetData($tInfo, "iNewState")
                                If $iState Then
                                If BitAND($iState, $LVGS_COLLAPSED  ) Then $sState = '$LVGS_COLLAPSED'
                                If BitAND($iState, $LVGS_HIDDEN     ) Then $sState &= ', $LVGS_HIDDEN'
                                If BitAND($iState, $LVGS_NOHEADER   ) Then $sState &= ', $LVGS_NOHEADER'
                                If BitAND($iState, $LVGS_COLLAPSIBLE) Then $sState &= ', $LVGS_COLLAPSIBLE'
                                If BitAND($iState, $LVGS_FOCUSED    ) Then $sState &= ', $LVGS_FOCUSED'
                                If BitAND($iState, $LVGS_SELECTED   ) Then $sState &= ', $LVGS_SELECTED'
                                Else
                                    $sState = '$LVGS_NORMAL'
                                EndIf
                                If StringLeft($sState, 2) = ', ' Then $sState = StringMid($sState, 3)
    ;~                             ConsoleWrite('--> $iMask  = 0x' & Hex($iMask) & @CRLF)
    ;~                             ConsoleWrite('--> GroupID = ' & DllStructGetData($tGroup, "GroupID") & @CRLF)
    ;~                             ConsoleWrite('--> cItems  = ' & DllStructGetData($tGroup, "cItems") & @CRLF)
                                ConsoleWrite('--> State   = 0x' & Hex($iState, 2) & ' (' & $sState & ')' & @CRLF)
                    Case $LVN_COLUMNCLICK ; A column was clicked    Local $sState
                        $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam)
                        _DebugPrint("$LVN_COLUMNCLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                                "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                                "-->Code:" & @TAB & $iCode & @CRLF & _
                                "-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @CRLF & _
                                "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                                "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                                "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                                "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                                "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                                "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                                "-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
                        ; No return value
                    Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
                        $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam)
                        _DebugPrint("$NM_CLICK" & @CRLF & "--> hWndFrom:" & @TAB & $hWndFrom & @CRLF & _
                                "-->IDFrom:" & @TAB & $iIDFrom & @CRLF & _
                                "-->Code:" & @TAB & $iCode & @CRLF & _
                                "-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @CRLF & _
                                "-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @CRLF & _
                                "-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @CRLF & _
                                "-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @CRLF & _
                                "-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @CRLF & _
                                "-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @CRLF & _
                                "-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @CRLF & _
                                "-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @CRLF & _
                                "-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
                        ; No return value
    ;~                 Case $LVN_GETDISPINFO
    ;~                     ConsoleWrite('> Case $LVN_GETDISPINFO' & @CRLF)
                EndSwitch
        EndSwitch
        Return $GUI_RUNDEFMSG
    EndFunc   ;==>WM_NOTIFY
    
    Func _DebugPrint($s_Text, $sLine = @ScriptLineNumber)
        ConsoleWrite( _
                "!===========================================================" & @CRLF & _
                "+======================================================" & @CRLF & _
                "-->Line(" & StringFormat("%04d", $sLine) & "):" & @TAB & $s_Text & @CRLF & _
                "+======================================================" & @CRLF)
    EndFunc   ;==>_DebugPrint
    Alles anzeigen
  • ISN AutoIt Studio

    • Bitnugger
    • 4. Juni 2018 um 17:27

    Genau der bringt auch die Härtesten der Harten zum Suizid... lol... ich würde dir Eset empfehlen...

  • GroupEx.au3 -- User Group Control, vielseitig modifizierbar

    • Bitnugger
    • 2. Juni 2018 um 18:54

    So funktioniert es...

    AutoIt
    ; #FUNCTION# ====================================================================================================================
    ; Name ..........: _GuiCtrlGroup_SetState
    ; Description ...: Changes the state of a _GuiCtrlGroup_Create() created control.
    ; Syntax ........: _GuiCtrlGroup_SetState(ByRef $_structGroup, $_iState, $_aCtrlInside, $_iTxtColor, $_iBGColor)
    ; Parameters ....: $_structGroup        - Return value from _GuiCtrlGroup_Create()
    ;                  $_iState             - The new state ($GUI_SHOW, $GUI_HIDE, $GUI_ENABLE, $GUI_DISABLE)
    ;                                         If setting to DISABLE, you can set the title and background colors for this state.
    ;                                         The previous colors will returned. You can use them for ENABLE again.
    ;                                         If you use DISABLE without colors, the defaults will used (see constants on top).
    ;                  $_aCtrlInside        - When you pass an array of controls, they are set to the same state as the group itself.
    ;                  $_iTxtColor          - The title color if set to enable/disable
    ;                  $_iBGColor           - The background color if set to enable/disable
    ; Return values .: Success              - Structure with previous title and background color (if state was set to enable/disable)
    ;                                         $tCOLOR.TextPrev / $tCOLOR.BGPrev
    ;                  Failure              - returns -1, sets @error = 1
    ; Note ..........: Don't forget to catch the return, if sets the state to DISABLE. It's the easiest way to have the right colors to set back the ENABLE state.
    ; Author ........: BugFix
    ; ===============================================================================================================================
    Func _GuiCtrlGroup_SetState(ByRef $_structGroup, $_iState, $_aCtrlInside = Null, $_iTxtColor = Null, $_iBGColor = Null)
        If Not BitAND(BitOR($GUI_SHOW, $GUI_HIDE, $GUI_ENABLE, $GUI_DISABLE), $_iState) Then Return SetError(1, 0, -1)
        Local $hWndGui = _WinAPI_GetParent(GUICtrlGetHandle($_structGroup.Background))
        Local $tCOLOR = DllStructCreate('int BGPrev;int TextPrev;')
        If $_iState = $GUI_DISABLE Then
            If $_iTxtColor = Null Then $_iTxtColor = $_GROUP_DISABLE_TXTDEF
            If $_iBGColor = Null Then $_iBGColor = $_GROUP_DISABLE_BGDEF
        EndIf
        $tCOLOR.BGPrev = -1
        $tCOLOR.TextPrev = -1
        If $_iState = $GUI_SHOW Or $_iState = $GUI_HIDE Then
            GUICtrlSetState($_structGroup.Text, $_iState)
            GUICtrlSetState($_structGroup.Left, $_iState)
            GUICtrlSetState($_structGroup.TopL, $_iState)
            GUICtrlSetState($_structGroup.TopR, $_iState)
            GUICtrlSetState($_structGroup.Right, $_iState)
            GUICtrlSetState($_structGroup.Bottom, $_iState)
            GUICtrlSetState($_structGroup.Background, $_iState)
        EndIf
        If IsArray($_aCtrlInside) Then
            Local $hCtrl
            For $i = 0 To UBound($_aCtrlInside) - 1
                $hCtrl = IsHWnd($_aCtrlInside[$i]) ? $_aCtrlInside[$i] : ControlGetHandle($hWndGui, '', $_aCtrlInside[$i])
                Switch $_iState
                    Case $GUI_SHOW
                        ControlShow($hCtrl, '', '')
                    Case $GUI_HIDE
                        ControlHide($hCtrl, '', '')
                    Case $GUI_ENABLE
                        ControlEnable($hCtrl, '', '')
                    Case $GUI_DISABLE
                        ControlDisable($hCtrl, '', '')
                EndSwitch
            Next
        EndIf
        If $_iTxtColor <> Null Then
            If Not IsDeclared('WM_CTLCOLORSTATIC') Then Local Const $WM_CTLCOLORSTATIC = 0x0138
            Local $hWnd = GUICtrlGetHandle($_structGroup.Text)
            Local $hDC = _WinAPI_GetDC($hWnd)
            Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
            _WinAPI_ReleaseDC($hWnd, $hDC)
            Local $hBrush = _SendMessage($hWndGui, $WM_CTLCOLORSTATIC, $hMemDC, $hWnd)
            Local $BGR = DllCall('gdi32.dll', 'int', 'GetTextColor', 'ptr', $hMemDC)
            _WinAPI_DeleteDC($hMemDC)
            $tCOLOR.TextPrev = BitOR(BitShift(BitAND($BGR[0], 0x0000FF), -16), BitAND($BGR[0], 0x00FF00), BitShift(BitAND($BGR[0], 0xFF0000), 16))
            GUICtrlSetColor($_structGroup.Text, $_iTxtColor)
        EndIf
        If $_iBGColor <> Null Then
            Local $hWnd = GUICtrlGetHandle($_structGroup.Background)
            Local $hDC = _WinAPI_GetDC($hWnd)
            $tCOLOR.BGPrev = _WinAPI_GetPixel($hDC, 0, 0)
            _WinAPI_ReleaseDC($hWnd, $hDC)
            GUICtrlSetBkColor($_structGroup.Background, $_iBGColor)
        EndIf
        DllCall("user32.dll", "bool", "RedrawWindow", "hwnd", $hWndGui, "struct*", 0, "handle", 0, "uint", 5)
        Return $tCOLOR
    EndFunc   ;==>_GuiCtrlGroup_SetState
    Alles anzeigen
  • GroupEx.au3 -- User Group Control, vielseitig modifizierbar

    • Bitnugger
    • 2. Juni 2018 um 17:15

    Ich denke es liegt daran, weil du die Controls mit Handle (Combo) mit WinSetState bearbeitest... da gibst du als Wert @SW_* an... bei den Controls mit ID aber $GUI_*.

    ==> ControlHide, ControlShow, ControlDisable, ControlEnable

    AutoIt
    For $i = 0 To UBound($_aCtrlInside) -1
        $hCtrl = IsHWnd($_aCtrlInside[$i]) ? $_aCtrlInside[$i] : ControlGetHandle($hWndGui, '', $_aCtrlInside[$i])
        Switch $_iState
            Case $GUI_SHOW
                ControlShow($hCtrl, '', '')
            Case $GUI_HIDE
                ControlHide($hCtrl, '', '')
            Case $GUI_ENABLE
                ControlEnable($hCtrl, '', '')
            Case $GUI_DISABLE
                ControlDisable($hCtrl, '', '')
        EndSwitch
    Next
    Alles anzeigen

    Edit: Der Fehler tritt auch auf, wenn die For-Next-Schleife nicht ausgeführt wird.

    Edit: Es liegt an dieser Zeile...

    GUICtrlSetState($_structGroup.Background, $_iState)

  • GroupEx.au3 -- User Group Control, vielseitig modifizierbar

    • Bitnugger
    • 2. Juni 2018 um 14:51
    Zitat von BugFix

    Meinst du, dass das Array mit den Control-ID beim Erstellen der Group übergeben werden soll?

    Ja, genau das meinte ich. Nachträglich wird wohl nicht gehen... ok, dass geht dann also nicht. Wegen des Beispiels... das war nicht für mich gedacht.

  • GroupEx.au3 -- User Group Control, vielseitig modifizierbar

    • Bitnugger
    • 2. Juni 2018 um 02:29

    Ein paar Fragen hätte ich dazu...

    1. Kannst du die Controls, die innerhalb der Group sein sollen, nicht besser gleich in _GuiCtrlGroup_Create integrieren... denn dann hätte der User nichts mehr damit zu schaffen?
    2. Kannst du anstelle ControlMove nicht GUICtrlSetPos verwenden, wenn eine CtrlID übergeben wurde?
      Warum? Weil die geänderte Größe/Position durch ControlMove nur temporär ist und verloren geht, wenn das Fenster minimiert und danach wiederhergestellt wird, mit GUICtrlSetPos aber nicht.

    PS1: Mit ComboBox/ComboBoxEx funktioniert es wohl nicht?!

    PS2: Wäre schön, wenn du für _GuiCtrlGroup_Set noch ein Beispiel für $_aCtrlInside hinzufügen würdest.

  • Verständnisfrage zu "Local vs Global" in Bezug auf Geschwindigkeit und Ressourcenbelegung

    • Bitnugger
    • 31. Mai 2018 um 16:01

    Richtig... doch Fakt ist, du hast es nicht gesehen... und das sind dann nachher in größeren Sripten genau die Fehler, die ich keinem wünsche.

  • Verständnisfrage zu "Local vs Global" in Bezug auf Geschwindigkeit und Ressourcenbelegung

    • Bitnugger
    • 31. Mai 2018 um 13:22

    1.) Globale Variablen sollten nicht innerhalb von Funktionen deklariert werden. Genauso schlimm, finde ich, wenn sich globale Variablen nicht von lokalen unterscheiden lassen, deshalb beginnen meine globalen immer mit $g_. Ich achte aber sehr darauf, dass ich möglichst mit lokalen Variablen arbeite, zumal das bei sehr großen Scripten die Fehlerträchtigkeit deutlich minimiert. Das DllOpen ergibt jetzt bei deinen 20-30 Icons nicht wirklich einen Mehrwert, aber wirklich wichtig wird es, wenn die DLL während der Laufzeit immer wieder angesprochen wird, z. B. mit der Funktion _IsPressed. Doch es kostet ja nichts.

    2.) Die habe ich drin gelassen, damit man sehen kann, wie ich die Sachen in der Debug-Phase angehe. Später würde ich dann einfach ein Return SetError(1, 0, False) zurückgeben oder kurz eine Message einblenden.

    3.) So ähnlich... wie genau man das angeht, ist aber wohl eine Sache des persöhnlichen Geschmacks, wobei ich dann sehr darauf achte, dass die Stelle des Fehlers mithilfe des Errors leicht auffindbar ist... also nicht immer SetError( 1, 0... oder du machstes mit _Assert.

    _Assert ( $sCondition [, $bExit = True [, $iCode = 0x7FFFFFFF [, $sLine = @ScriptLineNumber]]] )

    AutoIt
    ; ...
    If @error Then _ErrorExit(77749, 2, '_WinAPI_DestroyIcon($hIcon)')
    ; ...
    
    Func _ErrorExit($iError, $iExtended, $sErrMsg, $iLineNumer = @ScriptLineNumber)
        If $iError Then ConsoleWrite(StringFormat('Debug line (%5i)  #Error: %i \t Extended: %i \t #ErrMsg: %s\n', $iLineNumer, $iError, $iExtended, $sErrMsg))
        Exit $iError
    EndFunc

    PS: In deinem zweiten Script Teil 2, was passiert denn da mit den Bitmaps? Das ist nämlich auch wieder ein Speicherleck! 8o

  • Verständnisfrage zu "Local vs Global" in Bezug auf Geschwindigkeit und Ressourcenbelegung

    • Bitnugger
    • 31. Mai 2018 um 09:43

    Ich habe hier mal was gebastelt...

    AutoIt
    ;-- TIME_STAMP   2018-05-31 09:43:20   v 0.1
    
    #Region    ;************ Includes ************
    #Include <GDIPlus.au3>
    #include <WindowsConstants.au3>
    #EndRegion ;************ Includes ************
    
    Opt('MustdeclareVars', 1)
    
    Global $g_hGUI, $g_idButton_Ico1, $g_idButton_Ico2
    Global $g_hDll = DllOpen("shell32.dll"), $g_oIconBase = ObjCreate("Scripting.Dictionary"), $g_hBmp, $g_hIcon
    
    _Main()
    
    Func _Main()
        _GDIPlus_Startup()
    
        $g_hGUI = GUICreate("Display embedded ico file in tray", 370, 100)
        GUISetBkColor(0x2F4F4F, $g_hGUI)
        $g_idButton_Ico1 = GUICtrlCreateButton("live", 10, 20, 170, 60)
        GUICtrlSetBkColor(-1, 0x778899)
        GUICtrlSetFont(-1, 14, 800)
        $g_idButton_Ico2 = GUICtrlCreateButton("lock", 190, 20, 170, 60)
        GUICtrlSetBkColor(-1, 0x778899)
        GUICtrlSetFont(-1, 14, 800)
        GUISetState()
    
        _ReadIcons()
    
        Local $iMsg, $iRet
        While 1
            $iMsg = GUIGetMsg()
            Switch $iMsg
                Case -3
                    ExitLoop
                Case $g_idButton_Ico1
                    $iRet = _WinAPI_TraySetHIcon($g_oIconBase("live"))
                    If @error Then Exit ConsoleWrite("@@ Debug line" & @TAB & @ScriptLineNumber & "   var: $iRet --> " & $iRet & @CRLF & "!@ " & @TAB & "#Error: " & @error & @TAB & "#Extended: " & @extended & @CRLF)
                    GUICtrlSetBkColor($g_idButton_Ico1, 0x228B22)
                    GUICtrlSetBkColor($g_idButton_Ico2, 0x778899)
                Case $g_idButton_Ico2
                    $iRet = _WinAPI_TraySetHIcon($g_oIconBase("lock"))
                    If @error Then Exit ConsoleWrite("@@ Debug line" & @TAB & @ScriptLineNumber & "   var: $iRet --> " & $iRet & @CRLF & "!@ " & @TAB & "#Error: " & @error & @TAB & "#Extended: " & @extended & @CRLF)
                    GUICtrlSetBkColor($g_idButton_Ico1, 0x778899)
                    GUICtrlSetBkColor($g_idButton_Ico2, 0x228B22)
            EndSwitch
        WEnd
        ; Clean up
        For $hIcon In $g_oIconBase
            $iRet = _WinAPI_DestroyIcon($hIcon)
            If @error Then ConsoleWrite("@@ Debug line" & @TAB & @ScriptLineNumber & "   var: $iRet --> " & $iRet & @CRLF & "!@ " & @TAB & "#Error: " & @error & @TAB & "#Extended: " & @extended & @CRLF)
        Next
        _GDIPlus_Shutdown()
        DllClose($g_hDll)
    EndFunc  ;==>_Main
    
    Func _WinAPI_TraySetHIcon($hIcon) ;function by Mat
        Local Const $tagNOTIFYICONDATA = _
                        "dword Size;" & _
                        "hwnd Wnd;" & _
                        "uint ID;" & _
                        "uint Flags;" & _
                        "uint CallbackMessage;" & _
                        "ptr Icon;" & _
                        "wchar Tip[128];" & _
                        "dword State;" & _
                        "dword StateMask;" & _
                        "wchar Info[256];" & _
                        "uint Timeout;" & _
                        "wchar InfoTitle[64];" & _
                        "dword InfoFlags;" & _
                        "dword Data1;word Data2;word Data3;byte Data4[8];" & _
                        "ptr BalloonIcon"
        Local Const $TRAY_ICON_GUI = WinGetHandle(AutoItWinGetTitle()), $NIM_ADD = 0, $NIM_MODIFY = 1, $NIF_MESSAGE = 1, $NIF_ICON = 2, $AUT_WM_NOTIFYICON = $WM_USER + 1, $AUT_NOTIFY_ICON_ID = 1
        Local $tNOTIFY = DllStructCreate($tagNOTIFYICONDATA)
        DllStructSetData($tNOTIFY, "Size", DllStructGetSize($tNOTIFY))
        DllStructSetData($tNOTIFY, "Wnd", $TRAY_ICON_GUI)
        DllStructSetData($tNOTIFY, "ID", $AUT_NOTIFY_ICON_ID)
        DllStructSetData($tNOTIFY, "Icon", $hIcon)
        DllStructSetData($tNOTIFY, "Flags", BitOR($NIF_ICON, $NIF_MESSAGE))
        DllStructSetData($tNOTIFY, "CallbackMessage", $AUT_WM_NOTIFYICON)
        Local $aRet = DllCall($g_hDll, "int", "Shell_NotifyIconW", "dword", $NIM_MODIFY, "ptr", DllStructGetPtr($tNOTIFY))
        If (@error) Then Return SetError(1, 0, False)
        Return $aRet[0] <> 0
    EndFunc  ;==>_WinAPI_TraySetHIcon
    
    ;Code below was generated by: 'File to Base64 String' Code Generator v1.20 Build 2015-01-20
    
    Func _CreateIcon($sName, $dIcon)
        Local $hBmp = _GDIPlus_BitmapCreateFromMemory(_WinAPI_Base64Decode($dIcon))
        If @error Then Exit ConsoleWrite("@@ Debug line" & @TAB & @ScriptLineNumber & "   var: $dIcon --> " & $dIcon & @CRLF  & "   var: $hBmp --> " & $hBmp & @CRLF & "!@ " & @TAB & "#Error: " & @error & @TAB & "#Extended: " & @extended & @CRLF)
    
        $g_oIconBase($sName) = _GDIPlus_HICONCreateFromBitmap($hBmp)
        _GDIPlus_BitmapDispose($hBmp)
    EndFunc
    
    Func _ReadIcons()
        Local $dIcon = 'AAABAAEAEBAAAAEACABoBQAAFgAAACgAAAAQAAAAIAAAAAEACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAjI7EAIiKwACIirwAhIa4AICCtAB8frAAeHqoAHR2pABwcpwAbG6UAGRmkABgYogAXF6AAFhaeABQUnAATE5oAEhKZABAQlwAPD5UA8fHxAA0NkwAMDJEACwuPAAoKjQAICIwABweKAAYGiAAFBYcABASFAAMDhAACAoMAAQGCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADxAREhQVFhcYGRobHB0eHw4PEBESFBUWFxgZGhscHR4NDg8QERIUFRYXGBkaGxwdDA0ODxAREhQVFhcYGRobHAsMDQ4PEBETExUWFxgZGhsKCwwNDg8QExMUFRYXGBkaCQoLDA0ODxMTEhQVFhcYGQgJCgsTExMTExMTExUWFxgHCAkKExMTExMTExMUFRYXBgcICQoLDBMTDxAREhQVFgUGBwgJCgsTEw4PEBESFBUEBQYHCAkKExMNDg8QERIUAwQFBgcICQoLDA0ODxAREgIDBAUGBwgJCgsMDQ4PEBEBAgMEBQYHCAkKCwwNDg8QAAECAwQFBgcICQoLDA0ODwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA='
        _CreateIcon("live", $dIcon)
    
        $dIcon = 'AAABAAEAEBAAAAEACABoBQAAFgAAACgAAAAQAAAAIAAAAAEACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAjI7EAIiKwACIirwAhIa4AICCtAB8frAAeHqoAHR2pABwcpwAbG6UAGRmkABgYogAXF6AAFhaeABQUnAATE5oAEhKZABAQlwAPD5UA8fHxAA0NkwAMDJEACwuPAAoKjQAICIwABweKAAYGiAAFBYcABASFAAMDhAACAoMAAQGCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADxAREhQVFhcYGRobHB0eHw4PEBESFBUWFxgZGhscHR4NDg8QERIUFRYXGBkaGxwdDA0ODxAREhQVFhcYGRobHAsMDQ4PEBETExUWFxgZGhsKCwwNDg8QExMUFRYXGBkaCQoLDA0ODxMTEhQVFhcYGQgJCgsMDQ4TExESFBUWFxgHCAkKCwwNExMQERIUFRYXBgcICQoLDBMTDxAREhQVFgUGBwgJCgsTEw4PEBESFBUEBQYHCAkKExMNDg8QERIUAwQFBgcICQoLDA0ODxAREgIDBAUGBwgJCgsMDQ4PEBEBAgMEBQYHCAkKCwwNDg8QAAECAwQFBgcICQoLDA0ODwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA='
        _CreateIcon("lock", $dIcon)
    EndFunc  ;==>_ReadIcons
    
    Func _WinAPI_Base64Decode($sB64String)
        Local $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0)
        If @error Or Not $aCrypt[0] Then Return SetError(1, 0, "")
        Local $bBuffer = DllStructCreate("byte[" & $aCrypt[5] & "]")
        $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "struct*", $bBuffer, "dword*", $aCrypt[5], "ptr", 0, "ptr", 0)
        If @error Or Not $aCrypt[0] Then Return SetError(2, 0, "")
        Return Binary(DllStructGetData($bBuffer, 1))
    EndFunc  ;==>_WinAPI_Base64Decode
    Alles anzeigen
  • Wie ändere ich beim erneuten Aktivieren des Scripts seine Funktion, während es bereits läuft

    • Bitnugger
    • 28. Mai 2018 um 18:27

    Hier mal eine kleine Demo aus meinem Code-Schnipsel-Archiv...

    AutoIt
    ;-- TIME_STAMP   2018-05-28 18:26:57   v 0.1
    
    #Region    ;************ Includes ************
    #include <Misc.au3>
    #include <GUIConstantsEx.au3>
    #EndRegion ;************ Includes ************
    
    If _Singleton(@ScriptName, 1) Then
        ; Juhu, ich bin allein...
        _Main()
    Else
        ; Es läuft bereits eine Instanz...
        Local $hWnd = WinGetHandle(@ScriptName), $hCtrl = ControlGetHandle($hWnd, '', '[CLASS:Static; INSTANCE:1]')
        If IsHWnd($hCtrl) Then
            ControlSetText($hCtrl, '', '', 'Verpiss dich...')
            ControlClick($hCtrl, '', '') ; Klopf, klopf... etwas Zeit zum (Lesen des neuen Textes und) Beenden des Scriots geben,
            If Not WinWaitClose($hWnd, '', 5) Then ; 5 Sekunden...  damit es evtl. noch Daten speichern kann.
                WinClose($hWnd) ; Was, der will nicht spuren? Dann eben so...
            EndIf
        EndIf
    EndIf
    
    Func _Main()
        #Region - GUI Create
        Local $hGUI = GUICreate(@ScriptName)
        GUISetBkColor(0x280000)
        Local $idLabel_Singleton = GUICtrlCreateLabel('Mich gibt es nur 1x ;-)', 10, 10, 250)
        GUICtrlSetFont(-1, 14)
        GUICtrlSetColor(-1, 0xFF0000)
        GUISetState()
        #EndRegion
    
        #Region - GUI SwitchLoop
        While True
            Switch GUIGetMsg()
                Case $GUI_EVENT_CLOSE
                    Exit
                Case $idLabel_Singleton
                    Sleep(1500)
                    GUICtrlSetData($idLabel_Singleton, 'Ja, ich gehe ja schon...')
                    Sleep(1500)
                    Exit
    ;~             Case
    ;~             Case
    ;~             Case
    ;~             Case Else
            EndSwitch
        WEnd
        #EndRegion
    EndFunc
    Alles anzeigen
  • Fenster aktivieren

    • Bitnugger
    • 28. Mai 2018 um 01:47
    Zitat von alpines

    Das liegt daran, dass du es in der Form eines Controls ansprichst.

    Das geht schon... aber dann musst du als Klasse natürlich auch die Klasse des Fensters und nicht den Titel angeben!

    Hier mal ein paar Beispiele für notepad.exe:

    AutoIt
    $hWnd = WinActivate('[CLASS:Notepad; TITLE:Unbenannt - Editor]')
    $hWnd = WinActivate('[CLASS:Notepad]')
    $hWnd = WinActivate('[TITLE:Unbenannt - Editor]')
    $hWnd = WinActivate('Unbenannt - Editor')
  • Verständnisfrage zu "Res Add Files" > Extra Icons

    • Bitnugger
    • 27. Mai 2018 um 12:54
    Zitat von Slevin

    Ist es möglich, die in die EXE inkludierten Ressourcen (icons) via ursprünglichem Dateinamen anzusprechen, oder geht das nur über deren Resource Table Position?

    Direkt, nein. Du kannst sie aber dem Quellcode entnehmen...

    Zitat von Slevin

    Und wenn nur über die Position, dann würde mich interessieren, wieso Position 1 lt. Referenz den Wert 201 hat?

    #AutoIt3Wrapper_Res_Icon_Add= ; Filename[,ResNumber[,LanguageCode]] of ICO to be added.

    ; Add extra ICO files to the resources

    ; Use full path of the ico files to be added

    ; ResNumber is a numeric value used to access the icon: TraySetIcon(@ScriptFullPath, ResNumber)

    ; If no ResNumber is specified, the added icons are numbered from 201 up

    Hier mal ein kleines Demo-Script...

    AutoIt: AutoIt3Wrapper_Res_Icon_Add
    ;-- TIME_STAMP   2018-05-27 12:49:20   v 0.1
    
    ;~ #AutoIt3Wrapper_Res_Icon_Add=                   ; Filename[,ResNumber[,LanguageCode]] of ICO to be added.
    
    ; Add icons to the file resource table
    ; As no resource names are specified, they will be set automatically to 201+
    #AutoIt3Wrapper_Res_Icon_Add=C:\Program Files (x86)\AutoIt3\Icons\au3.ico
    #AutoIt3Wrapper_Res_Icon_Add=C:\Program Files (x86)\AutoIt3\Icons\au3script_v10.ico
    #AutoIt3Wrapper_Res_Icon_Add=C:\Program Files (x86)\AutoIt3\Icons\au3script_v9.ico
    #AutoIt3Wrapper_Res_Icon_Add=C:\Program Files (x86)\AutoIt3\Icons\filetype-blank.ico
    
    #Region    ;************ Includes ************
    #include <Array.au3>
    #include <WinAPIRes.au3>
    #include <ButtonConstants.au3>
    #EndRegion ;************ Includes ************
    
    Local $hModule = StringTrimRight(@ScriptFullPath, 4) & '.exe', $aData = _WinAPI_EnumResourceTypes($hModule), $aNames, $aShow[0][2], $aIconResNames[0]
    For $i = 0 To UBound($aData) -1 Step 1
        $aNames = _WinAPI_EnumResourceNames($hModule, $aData[$i])
        _ArrayAdd($aShow, $aData[$i] & '|' & _ArrayToString($aNames, ', '))
        If $aData[$i] = 14 Then _ArrayAdd($aIconResNames, _ArrayToString($aNames, '|')) ; Icons
    Next
    _ArrayDisplay($aShow, 'Resource Types and Names', '', 0, Default, 'Types|Names')
    
    ; Now run through the added icons in the resource table
    Local $sScriptName = StringTrimRight(@ScriptFullPath, 4) & '.au3', $sIconName, $aIconNames = FileReadToArray($sScriptName)
    If @error Then Exit MsgBox(16, @ScriptName, 'Quelltext nicht gefunden!' & @CRLF & $sScriptName, 3)
    $aIconNames = StringRegExp(_ArrayToString($aIconNames, @CRLF, -1, -1, @CRLF), '#AutoIt3Wrapper_Res_Icon_Add=([^\s].+)', 3)
    ReDim $aIconNames[UBound($aIconNames) -1]
    _ArrayColInsert($aIconNames, 0)
    For $i = 0 To UBound($aIconNames) -1 Step 1
        $aIconNames[$i][0] = $i + 201
    Next
    _ArrayDisplay($aIconNames, '$aIconNames')
    
    If Not @Compiled Then Exit MsgBox(16, @ScriptName, 'Du musst das Script erst kompilieren und dann die Exe ausführen, damit der Rest des Scripts funktioniert!', 3)
    
    ; Create the GUI
    $hGUI = GUICreate("AutoIt3Wrapper_Res_Icon_Add", 400, 200)
    $idButton = GUICtrlCreateButton("", 10, 10, 100, 100, $BS_ICON)
    $idLabelID = GUICtrlCreateLabel("", 10, 125, 200, 20)
    $idLabelName = GUICtrlCreateLabel("", 10, 150, 380, 20)
    GUISetState(@SW_SHOW, $hGUI)
    
    Local $id, $rc1, $rc2, $iSleep = 5
    For $i = 0 To UBound($aIconResNames) -1 Step 1
        ; Change the tray icon
        $id = $aIconResNames[$i]
        $iIndex = _ArraySearch($aIconNames, $id)
        $sIconName = $iIndex > -1 ? $aIconNames[$iIndex][1] : '?'
        $rc1 = TraySetIcon(@ScriptFullPath, $id)
        ; Change the icon in the button
        $rc2 = GUICtrlSetImage($idButton, @ScriptFullPath, $id)
        GUICtrlSetData($idLabelID, "Icon ID: " & $id)
        GUICtrlSetData($idLabelName, "Icon Name: " & $sIconName)
    
    ;~         TrayTip("Added icon: " & $x, "TraySetIcon rc: " & $rc1 & @CRLF & "GUICtrlSetImage rc: " & $rc2, 3)
            TrayTip("Added icon: ", StringFormat('ID = %3i\nName = %s\nTraySetIcon = %i, GUICtrlSetImage = %i\n', $id, $sIconName, $rc1, $rc2), $iSleep)
    
        ; Allow time for icon to be seen
        Sleep($iSleep * 1500)
    Next
    
    ; Delete the GUI
    GUIDelete($hGUI)
    Alles anzeigen
  • Map Deklaration throws error

    • Bitnugger
    • 26. Mai 2018 um 10:43
    Zitat von alpines

    Bitnugger dann kannst du aber nicht wie bei Maps die Icons mit Bezeichnern erreichen, das war ja der ursprüngliche Plan.

    Ah, ja, hast recht... dann würde ich natürlich auch Dictionary verwenden... weil es Maps ja nicht mehr in der Prod gibt.

  • Map Deklaration throws error

    • Bitnugger
    • 26. Mai 2018 um 10:31

    Maps... wo? Sehe nirgends welche...

    Falsch:

    Global $icon[]

    Richtig:

    Global $icon[4]

    Falsch:

    For i = 1 to 10

    Richtig:

    For $i = 1 to 10

    Falsch:

    For i = 0 To UBound($icon) - 1

    Richtig:

    For $i = 0 To UBound($icon) - 1

    Ich würde es so machen...

    AutoIt
    Global $g_sIconsDir = @ScriptDir & "\Icons\"
    Global $g_aIcons = [['live', 'icon-live.ico'], ['lock', 'icon-lock.ico'], ['dot', 'icon-dot.ico'], ['dismount', 'icon-dismount.ico']]
    
    For $i = 0 To UBound($g_aIcons) - 1
        If Not FileExists($g_sIconsDir & $g_aIcons[$i][1]) Then
            Exit MsgBox(16, @ScriptFullPath, StringFormat('Error: Icon für "%s" nicht gefunden!\nPfad: %s', $g_aIcons[$i][0], $g_sIconsDir & $g_aIcons[$i][1]))
        EndIf
    Next
  • WindowPlacement

    • Bitnugger
    • 26. Mai 2018 um 10:06

    Die Funktion _WindowOnDesktop verschiebt Fenster, wenn die linke obere Ecke auf dem Desktop nicht sichtbar ist, auf den primären Monitor. In einigen Fällen wäre es mir aber lieber, dass sie auf den Monitor landen, der den Koordinaten am nähesten ist, von denen aus sie verschoben werden sollen.

    Im Anhang mal ein erster Ansatz... mit dieser Funktion kann man selbst bestimmen, wohin verschoben wird und ob das Fenster sichtbar, minimiert, maximiert und/oder die Größe angepasst werden soll.

    PS: Das Arbeitsbereich-Rechteck verringert sich nicht nur durch den Platz, den die Taskleiste benötigt, wenn diese nicht automatisch ausgeblendet wird, denn andere Anwendungen können sich auch Platz reservieren. Bei mir ist dies auf dem primären Monitor z.B. das Shelf von Winstep.

    Dateien

    _CheckWinPos_Demo.au3 8,24 kB – 406 Downloads _CheckWinPos.au3 6,46 kB – 413 Downloads
  • InetRead bzw. Inetget mit HTTPS

    • Bitnugger
    • 24. Mai 2018 um 08:31
    Zitat von Racer

    Erst als ich ein @CRLF eingefügt habe ist es Problemlos gelaufen...

    Ich bin auch kein Profi, was das Objekt-Handling angeht, aber hier mal ein kleines Test-Script aus meinem Code-Schnipsel-Archiv.

    @CRLF ... siehe Zeile 128 ;)

    Spoiler anzeigen
    AutoIt
    ;-- TIME_STAMP   2018-05-24 08:24:26   v 0.1
    
    #cs
        Die Wahl der Übertragungsmethode hängt, will man es richtig machen, nicht etwa von der Präferenz des Programmierers ab, sondern folgt eigentlich ganz einfachen Regeln:
            1. Werden durch den Request lediglich andere Daten als Antwort empfangen, so ist die GET-Methode die richtige Wahl.
            2. Werden durch den Request Daten auf dem Server verändert, ist die POST-Methode die richtige Wahl.
            3. Werden Daten für Logins, insbesondere Passwörter übermittelt, dann ist nur POST die einzig richtige Wahl.
    
            WinHttpRequest object : https://msdn.microsoft.com/de-de/library/windows/desktop/aa384106(v=vs.85).aspx
    
            File signatures      : https://en.wikipedia.org/wiki/List_of_file_signatures
    #ce
    
    Global $DEBUG = 1 ; 1 = Parameter anzeigen
    
    Global $g_Spacer = '=============================================================================================='
    
    Global Const $HTTPREQUEST_SETCREDENTIALS_FOR_SERVER = 0
    
    ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ; (.1) GET - wenn kein Benutzername/Passwort benötigt/gesendet wird
    ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ;~ _Example() ; XAMPP - Server: Apache/2.4.33 (Win32) OpenSSL/1.1.0g PHP/7.2.4
    
    ;~ _Example('ResponseText', 'GET', 'http://192.168.178.1', @ScriptDir & '\ResponseText.html') ; Router
    ;~ _Example('ResponseText', 'GET', 'http://192.168.178.31') ; HP-Server - https ;-)
    ;~ _Example('ResponseText', 'GET', 'http://192.168.178.34') ; ETH484-IO-Modul - 401 Unauthorized: Password required
    
    ;~ _Example('ResponseText', 'GET', 'https://176.32.234.152/p_h_p_i_n_f_o/inf.php', @ScriptDir & '\ip.txt', False) ; Root-Server
    ;~ _Example('ResponseBody', 'GET', 'https://176.32.234.152/p_h_p_i_n_f_o/inf.php', @ScriptDir & '\ip.txt', False) ; Root-Server
    
    ;~ _Example('ResponseText', 'GET', 'https://autoit.de/wcf/index.php', @ScriptDir & '\au3.txt', False) ; gähn... ;-)
    
    ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ; (.3) POST - wenn ein Benutzername/Passwort benötigt/gesendet wird
    ; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    ;~ _Example('ResponseBody', 'POST', 'https://176.32.234.152/i_m_a_g_e_s/favicon.ico', @ScriptDir & '\favicon.ico') ; Root-Server
    ;~ _Example('ResponseText', 'POST', 'https://176.32.234.152/p_h_p_i_n_f_o/ip.php', @ScriptDir & '\ip.html') ; Root-Server
    
    ;~ _Example('ResponseBody', 'POST', 'https://176.32.234.152/p_h_p_i_n_f_o/inf.php', @ScriptDir & '\ip.txt', False) ; Root-Server
    ;~ _Example('ResponseText', 'POST', 'https://176.32.234.152/p_h_p_i_n_f_o/inf.php', @ScriptDir & '\ip.txt', False) ; Root-Server
    
    ;~ _Example('ResponseBody', 'POST', 'https://176.32.234.152/p_h_p_i_n_f_o/resolve_ip_host.php', @ScriptDir & '\ip_host.txt', False) ; Root-Server
    ;~ _Example('ResponseText', 'POST', 'https://176.32.234.152/p_h_p_i_n_f_o/resolve_ip_host.php', @ScriptDir & '\ip_host.txt', False) ; Root-Server
    
    Func _Example($sResponse = 'ResponseText', $sMethod = 'GET', $sURI = 'http://127.0.0.1', $sFilePath = '', $bResponseHeaders = True)
        Local $vData, $sBR = @CRLF & @CRLF & @CRLF & @CRLF & @CRLF
    
        If $DEBUG Then ConsoleWrite( _
            '> Parameter' & @CRLF & _
            '> ' & $g_Spacer & @CRLF & _
            '> $sResponse        = ' & $sResponse & ($sResponse = 'ResponseBody' ? ' (Binary)' : ' (String)') & @CRLF & _
            '> $METHOD           = ' & $sMethod & @CRLF & _
            '> $sURI             = ' & $sURI & @CRLF & _
            '> $sFilePath        = ' & $sFilePath & @CRLF & _
            '> $bResponseHeaders = ' & $bResponseHeaders & @CRLF & _
            '+ ' & $g_Spacer & @CRLF & @CRLF)
    
        $vData = _GetHTTP($sResponse, $sMethod, $sURI, $bResponseHeaders)
    
        ; ************************************************************************************************************
        ; Hm, wieso liefert winhttp am Ende immer ein oder zwei 0x0A ??? Ach was, egal, ich filtere sie einfach aus...
        ; ************************************************************************************************************
        Switch True
            Case IsBinary($vData)
                $vData = StringToBinary(StringRegExpReplace(BinaryToString($vData), '[\x0A]+$', ''))
            Case IsString($vData)
                $vData = StringRegExpReplace($vData, '[\x0A]+$', '')
            Case Else
                Return False
        EndSwitch
    
        Switch $sResponse
            Case 'ResponseBody'
                Switch True
                    Case BinaryMid($vData, 1, 4) = 0x00000100, BinaryMid($vData, 1, 4) = 0x00010000 ; *.ico
                        ConsoleWrite( _
                            '> ' & $g_Spacer & @CRLF & _
                            '+ Response ok --> file signature (*.ico) : ' & BinaryMid($vData, 1, 4) & @CRLF & _
                            '+ ' & $g_Spacer & $sBR)
                    Case _IsIP($vData), _IsIP(BinaryToString($vData)) ; My external IP --> 0x38302E3133342E3138362E313837
                        If StringInStr(BinaryToString($vData), '|') Then
                            $vData = StringSplit(BinaryToString($vData), '|', 2)
                            _PrintResponse('My external IP/Host', 'Binary --> ' & StringToBinary($vData[0]) & @CRLF & '-   String --> ' & $vData[0] & @CRLF & '-   Host   --> ' & $vData[1], $sBR)
                        Else
                            _PrintResponse('My external IP', 'Binary --> ' & $vData & @CRLF & '-   String --> ' & BinaryToString($vData), $sBR)
                        EndIf
                    Case Else
    ;~                     _PrintResponse($sResponse & ' (Binary)', $vData, $sBR)
                        _PrintResponse($sResponse & ' (String)', BinaryToString($vData), $sBR)
                EndSwitch
            Case 'ResponseText'
                Switch True
                    Case _IsIP($vData) ; My external IP --> 80.134.186.187
                        If StringInStr($vData, '|') Then
                            $vData = StringSplit($vData, '|', 2)
                            _PrintResponse('My external IP/Host', 'String --> ' & $vData[0] & @CRLF & '-   Binary --> ' & StringToBinary($vData[0]) & @CRLF & '-   Host   --> ' & $vData[1], $sBR)
                        Else
                            _PrintResponse('My external IP', 'String --> ' & $vData & @CRLF & '-   Binary --> ' & StringToBinary($vData), $sBR)
                        EndIf
                    Case Else
    ;~                     _PrintResponse($sResponse & ' (Binary)', StringToBinary($vData), $sBR)
                        _PrintResponse($sResponse & ' (String)', BinaryToString($vData), $sBR)
                EndSwitch
        EndSwitch
    
        If $sFilePath Then
    ;~         Local $hFile = FileOpen($sFilePath, 18)
    ;~         FileWrite($hFile, $vData)
    ;~         FileClose($hFile)
    ;~         ShellExecute($sFilePath)
        EndIf
    EndFunc  ;==>_Example
    
    Func _GetHTTP($REQUEST, $sMethod, $sURI, $bResponseHeaders)
        Switch $sMethod
            Case 'POST', 'GET'
                Local $oErrorHandler = ObjEvent('AutoIt.Error', '_ErrFunc')
    
                Local $oHTTP = ObjCreate('winhttp.winhttprequest.5.1')
                If Not IsObj($oHTTP) Then Return SetError(2, 0, False)
                With $oHTTP
                    ; Absichtlich einen Fehler provozieren, indem eine nicht vorhandene Methode aufrufen wird
    ;~                 .MakeMyDay('*******')
    ;~                 If @error Then Return SetError(777, 0, False)
    
                    .Option(4) = 13056
                    .Open($sMethod, $sURI, $HTTPREQUEST_SETCREDENTIALS_FOR_SERVER) ; ohne @CRLF! ;-)
                    If @error Then Return SetError(3, 0, False)
                    If $sMethod = 'POST' Then
                        Local $BN = InputBox(@ScriptName, 'BenutzerName: ', '', '', 320, 120), $PW = InputBox(@ScriptName, 'Passwort: ', '', '*', 320, 120)
                        If $BN = '' Or $PW = '' Then Return SetError(4, 0, False)
    ;~                     ConsoleWrite('$BN = ' & $BN & @CRLF & '$PW = ' & $PW & @CRLF)
                        .SetCredentials($BN, $PW, 0)
                    EndIf
                    .Send()
    
                    If $bResponseHeaders Then _PrintResponseHeaders(.GetAllResponseHeaders())
    
                    Switch $REQUEST
                        Case 'ResponseBody'
                            Return .ResponseBody()
                        Case 'ResponseText'
                            Return .ResponseText()
                    EndSwitch
                EndWith
            Case Else
                Return SetError(1, 0, False)
        EndSwitch
    EndFunc  ;==>_GetHTTP
    
    Func _PrintResponseHeaders($sResponseHeaders)
        Local $aResponseHeaders = StringSplit(StringStripWS($sResponseHeaders, 2), @CRLF, 1)
        If @error Then Return False
        ConsoleWrite( _
            '> ResponseHeaders' & @CRLF & _
            '> ' & $g_Spacer & @CRLF)
        For $i = 1 To $aResponseHeaders[0] Step 1
            ConsoleWrite('-   ' & $aResponseHeaders[$i] & @CRLF)
        Next
        ConsoleWrite('+ ' & $g_Spacer & @CRLF & @CRLF)
    EndFunc  ;==>_PrintResponseHeaders
    
    Func _PrintResponse($sResponse, $vData, $sBA = '')
        ConsoleWrite( _
            '> ' & $sResponse & @CRLF & _
            '> ' & $g_Spacer & @CRLF & _
            '-   ' & $vData & @CRLF & _
            '+ ' & $g_Spacer & @CRLF & $sBA)
    EndFunc  ;==>_PrintResponse
    
    Func _IsIP($sIP)
        Local Static $STR_REGEXPMATCH = 0, $sRegExPattern = '\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b'
        Return StringRegExp($sIP, $sRegExPattern, $STR_REGEXPMATCH)
    EndFunc  ;==>_IsIP
    
    Func _ErrFunc($oError)
        ; Do anything here.
        ConsoleWrite('! ' & $g_Spacer & @CRLF & _
            @ScriptName & ' (' & $oError.scriptline & ') : ==> COM Error intercepted !' & @CRLF & _
                @TAB & 'err.number is       : ' & '0x' & Hex($oError.number) & @CRLF & _
                @TAB & 'err.windescription  : ' & $oError.windescription & @CRLF & _
                @TAB & 'err.description is  : ' & $oError.description & @CRLF & _
                @TAB & 'err.source is       : ' & $oError.source & @CRLF & _
                @TAB & 'err.helpfile is     : ' & $oError.helpfile & @CRLF & _
                @TAB & 'err.helpcontext is  : ' & $oError.helpcontext & @CRLF & _
                @TAB & 'err.lastdllerror is : ' & $oError.lastdllerror & @CRLF & _
                @TAB & 'err.scriptline is   : ' & $oError.scriptline & @CRLF & _
                @TAB & 'err.retcode is      : ' & '0x' & Hex($oError.retcode) & @CRLF & _
                '! ' & $g_Spacer & @CRLF & @CRLF)
    EndFunc  ;==>_ErrFunc
    Alles anzeigen
  • Windows Live Mail

    • Bitnugger
    • 17. Mai 2018 um 16:53

    Wenn man auf Synchronisieren geht und dann während Mails gesendet/empfangen werden, unten rechts in der Statusleiste doppelklickt, öffnet sich ein Fenster. Dieses Fenster lässt mit dem Pin-Button anpinnen, wenn man nicht möchte, dass es sich direkt nach der Übertragung automatisch schließt, um z. B. zu sehen, was schief gelaufen ist. Durch Doppelklick auf Synchronisieren öffnet sich das Statusfenster.

  • " in der Command Lline benutzbar ?

    • Bitnugger
    • 16. Mai 2018 um 16:42

    Und...

    AutoIt
    Local $sEins = "Test", $sZwei = "ExpandVarStrings", $sDrei = "StringFormat"
    
    $iDiff1 = _Print(1)
    $iDiff2 = _Print(2)
    
    ConsoleWrite('+ $iDiff1 (ExpandVarStrings) = ' & $iDiff1 & ' ms' & @CRLF & _
                 '> $iDiff2 (StringFormat)     = ' & $iDiff2 & ' ms' & @CRLF & _
                 '! ' & ($iDiff1 < $iDiff2 ? $sZwei : $sDrei) & ' ist um Faktor ' & ($iDiff1 < $iDiff2 ? $iDiff2 / $iDiff1 : $iDiff1 / $iDiff2) & ' schneller!' & @CRLF)
    
    Func _Print($iFn)
        Local $iDiff, $hTimer = TimerInit()
        For $i = 1 To 30000 Step 1
            If $iFn = 1 Then
                ConsoleWrite(_SF('+ Das ist ein "$sEins$" mit "$sZwei$".' & @CRLF))
            Else
                ConsoleWrite(StringFormat('> Das ist ein "%s" mit "%s".\r\n', $sEins, $sDrei))
            EndIf
        Next
        $iDiff = TimerDiff($hTimer)
        _ClearOutPane()
        Return $iDiff
    EndFunc
    
    Func _SF($sText)
        Local $iOpt = Opt("ExpandVarStrings", 1)
        $sText = $sText
        Opt("ExpandVarStrings", $iOpt)
        Return $sText
    EndFunc
    
    Func _ClearOutPane()
        Local Static $hOutPane = ControlGetHandle("[CLASS:SciTEWindow]", "", "Scintilla2")
        ConsoleWrite('+++')
        While StringRight(ControlGetText($hOutPane, "", ""), 3) <> '+++'
            Sleep(50)
        WEnd
    ;~     ControlSend($g_hOutPane, "", "", "+{F5}")
        ControlSetText($hOutPane, "", "", "")
    EndFunc
    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™