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. Bloody Beginner

Beiträge von Bloody Beginner

  • (Anfänger)Frage zur Funktion "_WinAPI_ShellNotifyIconGetRect"

    • Bloody Beginner
    • 12. Januar 2026 um 10:45

    Schade

  • (Anfänger)Frage zur Funktion "_WinAPI_ShellNotifyIconGetRect"

    • Bloody Beginner
    • 4. Januar 2026 um 18:39

    Guten Abend Schnuffel,

    auch Dir Danke für Deine Antwort.

    Ich hatte die Hoffnung, dass mir jemand (bestenfalls anfängerverständlich) beantworten/erklären kann, ob - und wenn ja - wie ich mit der Funktion "_WinAPI_ShellNotifyIconGetRect" die Koordinaten aller meiner Traysymbole erfassen kann, da sich das Beispiel in der Hilfe lediglich auf das Tray-Symbol eines zugehörigen (offenen) AutoIt-Fensters bezieht, die meisten (meiner) Traysymbole aber eben nicht auf einem offenen Fenster basieren.

    Ein Beispiel - idealtypisch mit kurzer Kommentierung - ist für Anfänger immer eine tolle Sache, ich bin hier jedoch nicht auf der Suche nach / in der Erwartung von fertigen Lösungen und wollte mit meiner Frage auch keinesfalls diese Intention erwecken! "Mein Weg" funktioniert ja, ist aber eben deutlich umfangreicher als die schlanke Funktion "_WinAPI_ShellNotifyIconGetRect" ...

    MfG BB

    AutoIt
    $Number_of_Icons = _SysTrayIconCount()
    
    For $i = 0 To $Number_of_Icons - 1
    
    	$Icon_Name = _SysTrayIconTooltip($i)
    	$Icon_Pos = _SysTrayIconPos($i)
    
    	ConsoleWrite("$Icon_Name = " & $Icon_Name & @CR)
    	ConsoleWrite("$Icon_Pos: x = " & $Icon_Pos[0] & ", y = " & $Icon_Pos[1] & @CR)
    	ConsoleWrite("-------------------------------" & @CR)
    
    Next
    
    
    ; #########################################################################################################
    ; ----------------------------------------------------------------------------
    ;
    ; Author:         Tuape
    ; Modified:       Erik Pilsits
    ;
    ; Script Function:
    ;   Systray UDF - Functions for reading icon info from system tray / removing
    ;   any icon.
    ;
    ; Last Update: 5/13/2013
    ;
    ; ----------------------------------------------------------------------------
    
    Func _SysTrayIconCount($iWin = 1)
        Local Const $TB_BUTTONCOUNT = 1048
        Local $hWnd = _FindTrayToolbarWindow($iWin)
        If $hWnd = -1 Then Return -1
        Local $count = DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $hWnd, "uint", $TB_BUTTONCOUNT, "wparam", 0, "lparam", 0)
        If @error Then Return -1
        Return $count[0]
    EndFunc   ;==>_SysTrayIconCount
    
    
    Func _SysTrayGetButtonInfo($iIndex, $iWin = 1, $iInfo = 1)
        Local Const $TB_GETBUTTON = 1047
    ;~  Local Const $TB_GETBUTTONTEXT = 1099
    ;~  Local Const $TB_GETBUTTONINFO = 1089
        Local Const $TB_GETITEMRECT = 1053
        Local Const $ACCESS = BitOR(0x0008, 0x0010, 0x0400) ; VM_OPERATION, VM_READ, QUERY_INFORMATION
        Local $TBBUTTON
        If @OSArch = "X86" Then
            $TBBUTTON = DllStructCreate("int iBitmap;int idCommand;byte fsState;byte fsStyle;byte bReserved[2];dword dwData;int iString")
        Else ; X64
            $TBBUTTON = DllStructCreate("int iBitmap;int idCommand;byte fsState;byte fsStyle;byte bReserved[6];uint64 dwData;int64 iString")
        EndIf
        Local $TRAYDATA
        If @OSArch = "X86" Then
            $TRAYDATA = DllStructCreate("hwnd hwnd;uint uID;uint uCallbackMessage;dword Reserved[2];handle hIcon")
        Else
            $TRAYDATA = DllStructCreate("uint64 hwnd;uint uID;uint uCallbackMessage;dword Reserved[2];uint64 hIcon")
        EndIf
        Local $trayHwnd = _FindTrayToolbarWindow($iWin)
        If $trayHwnd = -1 Then Return SetError(1, 0, -1)
        Local $return, $err = 0
        Local $ret = DllCall("user32.dll", "dword", "GetWindowThreadProcessId", "hwnd", $trayHwnd, "dword*", 0)
        If @error Or Not $ret[2] Then SetError(2, 0, -1)
        Local $pId = $ret[2]
        Local $procHandle = DllCall("kernel32.dll", "handle", "OpenProcess", "dword", $ACCESS, "bool", False, "dword", $pId)
        If @error Or Not $procHandle[0] Then Return SetError(3, 0, -1)
        Local $lpData = DllCall("kernel32.dll", "ptr", "VirtualAllocEx", "handle", $procHandle[0], "ptr", 0, "ulong", DllStructGetSize($TBBUTTON), "dword", 0x1000, "dword", 0x04)
        If Not @error And $lpData[0] Then
            $ret = DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $trayHwnd, "uint", $TB_GETBUTTON, "wparam", $iIndex, "lparam", $lpData[0])
            If Not @error And $ret[0] Then
                DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", $procHandle[0], "ptr", $lpData[0], "struct*", $TBBUTTON, "ulong", DllStructGetSize($TBBUTTON), "ulong*", 0)
                Switch $iInfo
                    Case 2
                        ; TRAYDATA structure
                        DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", $procHandle[0], "ptr", DllStructGetData($TBBUTTON, 6), "struct*", $TRAYDATA, "ulong", DllStructGetSize($TRAYDATA), "ulong*", 0)
                        $return = $TRAYDATA
                    Case 3
                        ; tooltip
                        $return = ""
                        If BitShift(DllStructGetData($TBBUTTON, 7), 16) <> 0 Then
                            Local $intTip = DllStructCreate("wchar[1024]")
                            ; we have a pointer to a string, otherwise it is an internal resource identifier
                            DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", $procHandle[0], "ptr", DllStructGetData($TBBUTTON, 7), "struct*", $intTip, "ulong", DllStructGetSize($intTip), "ulong*", 0)
                            $return = DllStructGetData($intTip, 1)
                        ;else internal resource
                        EndIf
                    Case 4
                        ; icon position
                        If Not BitAND(DllStructGetData($TBBUTTON, 3), 8) Then ; 8 = TBSTATE_HIDDEN
                            Local $pos[2], $RECT = DllStructCreate("int;int;int;int")
                            DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $trayHwnd, "uint", $TB_GETITEMRECT, "wparam", $iIndex, "lparam", $lpData[0])
                            DllCall("kernel32.dll", "bool", "ReadProcessMemory", "handle", $procHandle[0], "ptr", $lpData[0], "struct*", $RECT, "ulong", DllStructGetSize($RECT), "ulong*", 0)
                            $ret = DllCall("user32.dll", "int", "MapWindowPoints", "hwnd", $trayHwnd, "ptr", 0, "struct*", $RECT, "uint", 2)
                            $pos[0] = DllStructGetData($RECT, 1)
                            $pos[1] = DllStructGetData($RECT, 2)
                            $return = $pos
                        Else
                            $return = -1
                        EndIf
                    Case Else
                        ; TBBUTTON
                        $return = $TBBUTTON
                EndSwitch
            Else
                $err = 5
            EndIf
            DllCall("kernel32.dll", "bool", "VirtualFreeEx", "handle", $procHandle[0], "ptr", $lpData[0], "ulong", 0, "dword", 0x8000)
        Else
            $err = 4
        EndIf
        DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $procHandle[0])
        If $err Then
            Return SetError($err, 0, -1)
        Else
            Return $return
        EndIf
    EndFunc   ;==>_SysTrayGetButtonInfo
    
    
    Func _SysTrayIconTooltip($iIndex, $iWin = 1)
        Local $ret = _SysTrayGetButtonInfo($iIndex, $iWin, 3)
        If @error Then
            Return SetError(@error, 0, -1)
        Else
            Return $ret
        EndIf
    EndFunc   ;==>_SysTrayIconTooltip
    
    
    Func _FindTrayToolbarWindow($iWin = 1)
        Local $hwnd, $ret = -1
        If $iWin = 1 Then
            $hWnd = DllCall("user32.dll", "hwnd", "FindWindow", "str", "Shell_TrayWnd", "ptr", 0)
            If @error Then Return -1
            $hWnd = DllCall("user32.dll", "hwnd", "FindWindowEx", "hwnd", $hWnd[0], "hwnd", 0, "str", "TrayNotifyWnd", "ptr", 0)
            If @error Then Return -1
            If @OSVersion <> "WIN_2000" Then
                $hWnd = DllCall("user32.dll", "hwnd", "FindWindowEx", "hwnd", $hWnd[0], "hwnd", 0, "str", "SysPager", "ptr", 0)
                If @error Then Return -1
            EndIf
            $hWnd = DllCall("user32.dll", "hwnd", "FindWindowEx", "hwnd", $hWnd[0], "hwnd", 0, "str", "ToolbarWindow32", "ptr", 0)
            If @error Then Return -1
            $ret = $hwnd[0]
        ElseIf $iWin = 2 Then
            ; NotifyIconOverflowWindow for Windows 7
            $hWnd = DllCall("user32.dll", "hwnd", "FindWindow", "str", "NotifyIconOverflowWindow", "ptr", 0)
            If @error Then Return -1
            $hWnd = DllCall("user32.dll", "hwnd", "FindWindowEx", "hwnd", $hWnd[0], "hwnd", 0, "str", "ToolbarWindow32", "ptr", 0)
            If @error Then Return -1
            $ret = $hwnd[0]
        EndIf
        Return $ret
    EndFunc   ;==>_FindTrayToolbarWindow
    
    
    Func _SysTrayIconPos($iIndex, $iWin = 1)
        Local $ret = _SysTrayGetButtonInfo($iIndex, $iWin, 4)
        If @error Then
            Return SetError(@error, 0, -1)
        Else
            If $ret = -1 Then
                Return SetError(-1, 0, -1)
            Else
                Return $ret
            EndIf
        EndIf
    EndFunc   ;==>_SysTrayIconPos
    Alles anzeigen
  • (Anfänger)Frage zur Funktion "_WinAPI_ShellNotifyIconGetRect"

    • Bloody Beginner
    • 3. Januar 2026 um 21:23

    Sorry, habe ein bißchen gekränkelt ...

    funkey: Erstmal besten Dank! Ich glaube, dass ich mich nicht ganz sauber ausgedrückt habe, ich hatte "Hardware entfernen" nur als Beispiel benannt, möchte aber letztendlich die Koordinaten aller meiner Symbole im Tray erfassen (zum Sortieren / Anordnen).

    Ich glaube, ich habe mittlerweile soviel verstanden, dass sich die Funktion "_WinAPI_ShellNotifyIconGetRect" immer auf das Fenster bezieht, dass für das Tray-Icon "verantwortlich" ist, wenn ich dass mal so stümperhaft beschreiben darf. Momentan nehme ich für meine oben beschriebene Intention einen recht großen Umweg über div. Funktionen und Schleifen aus dem Projekt "Systray UDF". Hatte die Hoffnung, dies vereinfachen / abkürzen zu können, als ich über die Funktion "_WinAPI_ShellNotifyIconGetRect" gestolpert bin ...

  • (Anfänger)Frage zur Funktion "_WinAPI_ShellNotifyIconGetRect"

    • Bloody Beginner
    • 25. Dezember 2025 um 15:19

    Herzliche Weihnachtsgrüße an die AutoIt-Profis/Community!

    (Anfänger)Frage zur Funktion "_WinAPI_ShellNotifyIconGetRect"

    Was muss ich tun, um z.B. die Koordinaten des TrayIcons "Hardware sicher entfernen" zu bekommen (statt statt wie in der Beispielfunktion "AutoItWinGetTitle") ?

    C
    #include <MsgBoxConstants.au3>
    #include <WinAPIGdi.au3>
    #include <WinAPIShellEx.au3>
    #include <WinAPISys.au3>
    
    Local $tRECT = _WinAPI_ShellNotifyIconGetRect(WinGetHandle(AutoItWinGetTitle()), 1)
    
    Local $aPos
    If Not @error Then
        $aPos = _WinAPI_GetPosFromRect($tRECT)
        MouseMove($aPos[0] + 12, $aPos[1] + 12)
        MouseClick('left')
        While 1
            Sleep(1000)
        WEnd
    EndIf
    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™