Hi ich probiere schon den ganzen tag herum aber ich schaffe es einfach nicht...
Ich hab mir hier: http://www.autoitscript.com/forum/index.php?showtopic=13704&st=0
Die folgende Funktionen herausgesucht:
Spoiler anzeigen
; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.1 Beta
; Author: Tuape
;
; Script Function:
; Systray UDF - Functions for reading icon info from system tray / removing
; any icon.
;
; Last Update: 7/14/05
; Requirements: AutoIt3 Beta - tested on WindowsXP, might also work in win2000
;
; Functions:
; _SysTrayIconCount() - Get count of all systray icons
; _SysTrayIconTitles() - Get titles of all programs that have icon on systray
; _SysTrayIconProcesses() - Get list of all process names that have icon in systray (hidden or visible)
; _SysTrayIconPids() - Get list of all parent process id's that own an icon in systray (hidden or visible)
; _SysTrayIconRemove($index) - Remove icon (removes completely, not just hide)
; ($wintitle or $process) - Get icon index based on process name or wintitle
; _SysTrayIconTooltip($index) - Get tooltip text of an icon based on index
;
; Notes:
; Some systray icons are actually hidden, so _SysTrayIconCount will probably return more than you see on systray.
; Some icons don't have window title on them. However, _SysTrayIconPids() & _SysTrayIconProcesses
; do return correct (parent) pid or process name
; ----------------------------------------------------------------------------
#NoTrayIcon
Const $TB_DELETEBUTTON = 1046
Const $TB_GETBUTTON = 1047
Const $TB_BUTTONCOUNT = 1048
Const $TB_GETBUTTONTEXT = 1099
Const $TB_GETBUTTONINFO = 1089
Const $TB_HIDEBUTTON = 1028 ; WM_USER +4
Const $TB_GETITEMRECT = 1053
Const $TB_MOVEBUTTON = 1106 ; WM_USER +82
Const $WM_GETTEXT = 13 ; Included in GUIConstants
Const $PROCESS_ALL_ACCESS = 2035711
Const $NO_TITLE = "---No title---" ; text that is used when icon window has no title
;===============================================================================
;
; Function Name: _SysTrayIconVisible($flag, $index)
; Description: Hides / unhides any icon on systray
;
; Parameter(s): $flag = hide (1) or show (0) icon
; $index = icon index. Can be queried with _SysTrayIconIndex()
;
; Requirement(s): AutoIt3 Beta
; Return Value(s): On Success - Returns 1 if operation was successfull / 0 if
; icon was already hidden/unhidden
; On Failure - If invalid parameters, returns -1 and sets error
; to 1
;
; Author(s): Tuape
;
;===============================================================================
Func _SysTrayIconVisible($flag, $index)
If $flag < 0 or $flag > 1 or Not IsInt($flag) Then
SetError(1)
return -1
EndIf
Local $hWnd = _FindTrayToolbarWindow()
Local $return
Local $str = "int;int;byte;byte;byte[2];dword;int";char[128]"
Dim $TBBUTTON = DllStructCreate($str)
Dim $TBBUTTON2 = DllStructCreate($str)
Local $pId
Local $text
Local $procHandle
Local $bytesRead
Local $info
Local $lpData
Local $ret = DLLCall("user32.dll","int","GetWindowThreadProcessId", "hwnd", $hWnd, "int*", -1)
If Not @error Then
$pId = $ret[2]
Else
ConsoleWrite("Error: Could not find toolbar process id, " & @error & @LF)
$TBBUTTON = 0
$TBBUTTON2 = 0
Return -1
EndIf
$procHandle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', $PROCESS_ALL_ACCESS, 'int', False, 'int', $pId)
If @error Then
ConsoleWrite("Error: Could not read toolbar process memory, " & @error & @LF)
$TBBUTTON = 0
$TBBUTTON2 = 0
return -1
EndIf
$lpData = DLLCall("kernel32.dll","int","VirtualAllocEx", "int", $procHandle[0], "int", 0, "int", DllStructGetSize ( $TBBUTTON ), "int", 0x1000, "int", 0x04)
If @error Then
ConsoleWrite("VirtualAllocEx Error" & @LF)
$TBBUTTON = 0
$TBBUTTON2 = 0
Return -1
Else
DLLCall("user32.dll","int","SendMessage", "hwnd", $hWnd, "int", $TB_GETBUTTON, "int", $index, "ptr",$lpData[0]);e(hwnd, TB_GETBUTTON, index, (LPARAM)lpData);
DllCall('kernel32.dll', 'int', 'ReadProcessMemory', 'int', $procHandle[0], 'int', $lpData[0], 'ptr', DllStructGetPtr($TBBUTTON2), 'int', DllStructGetSize( $TBBUTTON), 'int', $bytesRead)
$return = DLLCall("user32.dll","int","SendMessage", "hwnd", $hWnd, "int", $TB_HIDEBUTTON, "int", DllStructGetData($TBBUTTON2,2), "long", $flag)
;ConsoleWrite(@CRLF & "Return: " & $return[0])
DLLCall("kernel32.dll","int","VirtualFreeEx", "int", $procHandle[0], "ptr", $lpData[0], "int", 0, "int", 0x8000) ;DllStructGetSize ( $TBBUTTON ), "int", 0x8000)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $procHandle[0])
[/autoit] [autoit][/autoit] [autoit]EndIf
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]$TBBUTTON = 0
$TBBUTTON2 = 0
return $return[0]
EndFunc
;===============================================================================
;
; Function Name: _SysTrayIconIndex($name, $mode=0)
; Description: Get list of all processes id's that have systray icon
; Parameter(s): $name = process name / window title text
; $mode 0 = get index by process name (default)
; 1 = get index by window title
; 2 = get index by icon's tooltip text
; Requirement(s): AutoIt3 Beta
; Return Value(s): On Success - Returns index of found icon
; On Failure - Returns -1 if icon for given process/wintitle
; was not found.
; - Sets error to 1 and returns -1 in case of bad
; arguments
; Author(s): Tuape
;
;===============================================================================
Func _SysTrayIconIndex($name, $mode=0)
Local $index = -1
Local $process
Local $i
If $mode < 0 or $mode > 2 or Not IsInt($mode) Then
SetError(1)
return -1
EndIf
If $mode = 0 Then
$process = _SysTrayIconProcesses()
Else
$process = _SysTrayIconTitles()
EndIf
For $i = 0 to Ubound($process)-1
If $process[$i] = $name Then
$index = $i
EndIf
Next
return $index
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit]Die sollten ja reichen oder?
Nur komme ich jetzt nicht dahinter wie das programm ausgewählt wird von dem das icon versteckt werden soll.
Meine Systray_test.au3:
[autoit]#include "SysTray_UDF.au3"
[/autoit][autoit][/autoit][autoit]; -- Example 3 --
$st_process = "Opera.exe"; change this if needed
_SysTrayIconVisible(1, _SysTrayIconIndex($st_process))
; Note that the icon is hidden
Sleep(1000)
_SysTrayIconVisible(0, _SysTrayIconIndex($st_process))
Fehlt mir da noch was oder muss ich da nur noch die variablen richtig anpassen?