apollo13 Posted September 11, 2012 Share Posted September 11, 2012 Hi, i have a problem using Systray_UDF in order to remove icon from systray of my two programs that i don't want to show icon. When i run: #NoTrayIcon #include <systray_udf.au3> _SysTrayIconRemove(_SysTrayIconIndex($Program), 1) The icon are removed but in system tray always there is in the same position of icon removed a blank icon. I have discovered that using in the end of script this command, the blank icon disappear Opt("TrayIconHide", 0) The problem that i can't solve is that using Windows with programs that have icon removed on background and in addiction other programs that i want show their icon in tray, after little time the system area present lots blank space that are added near left clock and the dimension of this blank space is very big and in this condition all program that i open and normally they put their icon in this system area as "Windows Task Manger" their icon are not showed. I must close programs and disconnect user to solve. I'm using SYSTRAY_UDF with Last Update 1/13/11 for AutoIT 3.3.1.2 There is some more recent update ?? My version of AutoIT is 3.3.8.1 Someone have the same problem that i have found and can give me some suggestion? Thanks Link to comment Share on other sites More sharing options...
apollo13 Posted September 11, 2012 Author Share Posted September 11, 2012 Nobody have solutions ?? :-( Link to comment Share on other sites More sharing options...
FireFox Posted September 11, 2012 Share Posted September 11, 2012 (edited) Hi, I may be wrong, but I think this is a Windows's bug, you just need to hover the icons to make them disappear. Br, FireFox. Edited September 11, 2012 by FireFox Link to comment Share on other sites More sharing options...
dany Posted September 11, 2012 Share Posted September 11, 2012 Yea, XP had that buggy behavior and WIn 7 has similar issues. You could hover the icons from AutoIt. [center]Spiderskank Spiderskank[/center]GetOpt Parse command line options UDF | AU3Text Program internationalization UDF | Identicon visual hash UDF Link to comment Share on other sites More sharing options...
apollo13 Posted September 11, 2012 Author Share Posted September 11, 2012 Thanks for answer No also if i hover the icon the problem persists. I solve using Opt("TrayIconHide", 0) but after few minutes using other program if i have removed tray icon of my background program the system area dimension is crazy ... with more blank space near clock. I'm using Win7 Ultimate x64 Sp1 :-/ Link to comment Share on other sites More sharing options...
apollo13 Posted September 12, 2012 Author Share Posted September 12, 2012 I have proved again but when i remove tray icon of my two programs and then i normally use my PC the tray area crazy. I explain better: I use SysTray_UD and function removes in the correct way the Tray icon but remain a blank space near clock. For this reason i'm using Opt("TrayIconHide", 0) and i solve the problem. Unfortunately using the computer (after 10-20 minutes) the tray area at a moment crazy and its dimension increase horizontal to half screen (as there was 10-15 blank icons near clock) and if i run new program, the tray icon of these programs are not showed. When this condition are presented I have proved add again Opt("TrayIconHide", 0 ) but nothing to do. I have proved to hover with mouse the area: nothing to do. Sometimes running program "IF" and only "IF" their icon are showed on tray area (rare) the problem for that moment are solved because the dimension of tray area come back to original dimension... The only way is "logout user" and Login new session without rebooting. What do you think about ? Link to comment Share on other sites More sharing options...
somdcomputerguy Posted September 12, 2012 Share Posted September 12, 2012 (edited) I recall a script/some code being used to remove 'dead icons' from the systray. Search thru the Example Scripts category, or maybe even this whole forum. Edited September 12, 2012 by somdcomputerguy - Bruce /*somdcomputerguy */Â If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
KaFu Posted September 12, 2012 Share Posted September 12, 2012 Add this to the top of the Systray.au3 Global $__hWnd_Shell_TrayWnd = DllCall("user32.dll", "hwnd", "FindWindow", "str", "Shell_TrayWnd", "ptr", 0) $__hWnd_Shell_TrayWnd = $__hWnd_Shell_TrayWnd[0] and this DllCall("user32.dll", "int", "SendMessageW", "hwnd", $__hWnd_Shell_TrayWnd, "uint", $WM_SETTINGCHANGE, "wparam", 0, "lparam", 0) directly after this $ret = DllCall("user32.dll", "int", "SendMessageW", "hwnd", $trayHwnd, "uint", $TB_HIDEBUTTON, "wparam", DllStructGetData($TBBUTTON, 2), "lparam", $iHide) Â OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13)Â BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16)Â ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
apollo13 Posted September 12, 2012 Author Share Posted September 12, 2012 Excuse me to explain me better: Open systray and on top i insert 1- Global..... 2- $ret... (After this you wrote)... 3- Dllcall ..... I will wait your answer. Thanks Link to comment Share on other sites More sharing options...
KaFu Posted September 12, 2012 Share Posted September 12, 2012 Upsa, adjustments made on my heavily customized version ... Add this to the top of the Systray.au3 Global $__hWnd_Shell_TrayWnd = DllCall("user32.dll", "hwnd", "FindWindow", "str", "Shell_TrayWnd", "ptr", 0) $__hWnd_Shell_TrayWnd = $__hWnd_Shell_TrayWnd[0] and this DllCall("user32.dll", "int", "SendMessageW", "hwnd", $__hWnd_Shell_TrayWnd, "uint", 0x001A, "wparam", 0, "lparam", 0) ; $WM_SETTINGCHANGE = 0x001A directly after this call in Func _SysTrayIconRemove( DLLCall("user32.dll","int","SendMessage", "hwnd", $hWnd, "int", $TB_DELETEBUTTON, "int", $index, "int", 0) masvil 1 Â OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13)Â BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16)Â ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
apollo13 Posted September 12, 2012 Author Share Posted September 12, 2012 Hi, the program shows me error: "Line 168 Variable used without being declared" and don't run. Can you reply post with attached your systray_udf.au3 modified ?? I have inserted as you wrote me: Opening SYSTRAY_UDF.Au3 on 1st row: Global $__hWnd_Shell_TrayWnd = DllCall("user32.dll", "hwnd", "FindWindow", "str", "Shell_TrayWnd", "ptr", 0) $__hWnd_Shell_TrayWnd = $__hWnd_Shell_TrayWnd[0] DllCall("user32.dll", "int", "SendMessageW", "hwnd", $__hWnd_Shell_TrayWnd, "uint", 0x001A, "wparam", 0, "lparam", 0) ; $WM_SETTINGCHANGE = 0x001A #include-once ; ---------------------------------------------------------------------------- ; ; AutoIt Version: 3.3.1.2 ; Author: Tuape ; Modified: Erik Pilsits ; ; Script Function: ; Systray UDF - Functions for reading icon info from system tray / removing ; any icon. ; ; Last Update: 1/13/11 ; ; ; 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) ; _SysTrayIconIndex($wintitle or $process) - Get icon index based on process name or wintitle ; _SysTrayIconTooltip($index) - Get tooltip text of an icon based on index ; _SysTrayIconPos(_SysTrayIconIndex($st_process)) = $pos ; - Get coordinate "x" $pos[0] e "y" $pos[1] ........etc.... & add after the text that you have wrote: Func _SysTrayIconRemove($index, $iWin = 1) DLLCall("user32.dll","int","SendMessage", "hwnd", $hWnd, "int", $TB_DELETEBUTTON, "int", $index, "int", 0) Local Const $TB_DELETEBUTTON = 1046 If $index < 0 Or $index > _SysTrayIconCount($iWin) - 1 Then Return -1 Local $hWnd = _FindTrayToolbarWindow($iWin) If $hwnd = -1 Then Return -1 Local $ret = DllCall("user32.dll", "int", "SendMessageW", "hwnd", $hWnd, "uint", $TB_DELETEBUTTON, "wparam", $index, "lparam", 0) If @error Or Not $ret[0] Then Return -1 Return $ret[0] EndFunc ;==>_SysTrayIconRemove Where is errors ?? Link to comment Share on other sites More sharing options...
BigDod Posted September 12, 2012 Share Posted September 12, 2012 I do not know if this is what you want. expandcollapse popup; =================================================================== ; Function written by Valik ; ; _RefreshSystemTray($nDealy = 1000) ; ; Removes any dead icons from the notification area. ; Parameters: ; $nDelay - IN/OPTIONAL - The delay to wait for the notification area to expand with Windows XP's ; "Hide Inactive Icons" feature (In milliseconds). ; Returns: ; Sets @error on failure: ; 1 - Tray couldn't be found. ; 2 - DllCall error. ; =================================================================== Func _RefreshSystemTray($nDelay = 1000) ; Save Opt settings Local $oldMatchMode = Opt("WinTitleMatchMode", 4) Local $oldChildMode = Opt("WinSearchChildren", 1) Local $error = 0 Do; Pseudo loop Local $hWnd = WinGetHandle("classname=TrayNotifyWnd") If @error Then $error = 1 ExitLoop EndIf Local $hControl = ControlGetHandle($hWnd, "", "Button1") ; We're on XP and the Hide Inactive Icons button is there, so expand it If $hControl <> "" And ControlCommand($hWnd, "", $hControl, "IsVisible") Then ControlClick($hWnd, "", $hControl) Sleep($nDelay) EndIf Local $posStart = MouseGetPos() Local $posWin = WinGetPos($hWnd) Local $y = $posWin[1] While $y < $posWin[3] + $posWin[1] Local $x = $posWin[0] While $x < $posWin[2] + $posWin[0] DllCall("user32.dll", "int", "SetCursorPos", "int", $x, "int", $y) If @error Then $error = 2 ExitLoop 3; Jump out of While/While/Do EndIf $x = $x + 8 WEnd $y = $y + 8 WEnd DllCall("user32.dll", "int", "SetCursorPos", "int", $posStart[0], "int", $posStart[1]) ; We're on XP so we need to hide the inactive icons again. If $hControl <> "" And ControlCommand($hWnd, "", $hControl, "IsVisible") Then ControlClick($hWnd, "", $hControl) EndIf Until 1 ; Restore Opt settings Opt("WinTitleMatchMode", $oldMatchMode) Opt("WinSearchChildren", $oldChildMode) SetError($error) EndFunc ;==>_RefreshSystemTray Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
apollo13 Posted September 12, 2012 Author Share Posted September 12, 2012 I want that function "SystrayIconRemove" Runs without cause problems that i have wrote on my first post. ...."Crazy and casual systrayArea dimension and block to show other new program in tray"... The fix for this problem is been posted from user KaFu (thanks) I have added these 4 rows counciled in the exact position that he has explained, but script NOW causes an error. The error message showed: Line 168 Variable used without being declared" and don't run. KaFu can you reply again to me please ?! Thank you Link to comment Share on other sites More sharing options...
BrewManNH Posted September 12, 2012 Share Posted September 12, 2012 Post your script and by the way, you never said what was on line 168 so how are we supposed to help? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator Link to comment Share on other sites More sharing options...
apollo13 Posted September 12, 2012 Author Share Posted September 12, 2012 (edited) line 168 is report to systray_udf.au3 after adding the lines script of KaFu. My script is only few rows! Do you want all script _SystrayUDF.au3 modified with Fix of KaFu ?? OK i immediately post ;---------My script------------ #NoTrayIcon #include <systray_udf.au3> $Program="Test.exe" If processexists($Program) then exit Run($Program) while not _SysTrayIconTooltip(_SysTrayIconIndex($Program))="Action" sleep (10) wend _SysTrayIconRemove(_SysTrayIconIndex($Program)) ;---------End My script------------ ;---------Systray_UDF.au3 Begin------------<p> ; added from council KaFu Global $__hWnd_Shell_TrayWnd = DllCall("user32.dll", "hwnd", "FindWindow", "str", "Shell_TrayWnd", "ptr", 0) $__hWnd_Shell_TrayWnd = $__hWnd_Shell_TrayWnd[0] DllCall("user32.dll", "int", "SendMessageW", "hwnd", $__hWnd_Shell_TrayWnd, "uint", 0x001A, "wparam", 0, "lparam", 0) ; $WM_SETTINGCHANGE = 0x001A ; End added from council KaFu #include-once ; ---------------------------------------------------------------------------- ; ; AutoIt Version: 3.3.1.2 ; Author: Tuape ; Modified: Erik Pilsits ; ; Script Function: ; Systray UDF - Functions for reading icon info from system tray / removing ; any icon. ; ; Last Update: 1/13/11 ; ; ; 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) ; _SysTrayIconIndex($wintitle or $process) - Get icon index based on process name or wintitle ; _SysTrayIconTooltip($index) - Get tooltip text of an icon based on index ; _SysTrayIconPos(_SysTrayIconIndex($st_process)) = $pos ; - Get coordinate "x" $pos[0] e "y" $pos[1] ; ; ; 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 ; ; ---------------------------------------------------------------------------- ;=============================================================================== ; ; Function Name: _SysTrayIconCount($iWin = 1) ; Description: Returns number of icons on systray ; Note: Hidden icons are also reported ; Parameter(s): $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; ; Requirement(s): ; Return Value(s): On Success - Returns number of icons found ; On Failure - Returns -1 ; ; Author(s): Tuape, Erik Pilsits ; ;=============================================================================== Func _SysTrayIconCount($iWin = 1) Local Const $TB_BUTTONCOUNT = 1048 Local $hWnd = _FindTrayToolbarWindow($iWin) If $hWnd = -1 Then Return -1 Local $count = DllCall("user32.dll", "int", "SendMessageW", "hwnd", $hWnd, "uint", $TB_BUTTONCOUNT, "wparam", 0, "lparam", 0) If @error Then Return -1 Return $count[0] EndFunc ;==>_SysTrayIconCount ;=============================================================================== ; ; Function Name: _SysTrayIconTitles($iWin = 1) ; Description: Get list of all window titles that have systray icon ; Parameter(s): $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; Requirement(s): ; Return Value(s): On Success - Returns an array with all window titles ; On Failure - Returns -1 ; ; Author(s): Tuape, Erik Pilsits ; ;=============================================================================== Func _SysTrayIconTitles($iWin = 1) Local $count = _SysTrayIconCount($iWin) If $count <= 0 Then Return -1 Local $titles[$count] ; Get icon owner window"s title For $i = 0 To $count - 1 $titles[$i] = WinGetTitle(_SysTrayIconHandle($i, $iWin)) Next Return $titles EndFunc ;==>_SysTrayIconTitles ;=============================================================================== ; ; Function Name: _SysTrayIconPids($iWin = 1) ; Description: Get list of all processes id's that have systray icon ; Parameter(s): $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; Requirement(s): ; Return Value(s): On Success - Returns an array with all process id's ; On Failure - Returns -1 ; ; Author(s): Tuape, Erik Pilsits ; ;=============================================================================== Func _SysTrayIconPids($iWin = 1) Local $count = _SysTrayIconCount($iWin) If $count <= 0 Then Return -1 Local $processes[$count] For $i = 0 To $count - 1 $processes[$i] = WinGetProcess(_SysTrayIconHandle($i, $iWin)) Next Return $processes EndFunc ;==>_SysTrayIconPids ;=============================================================================== ; ; Function Name: _SysTrayIconProcesses($iWin = 1) ; Description: Get list of all processes that have systray icon ; Parameter(s): $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; Requirement(s): ; Return Value(s): On Success - Returns an array with all process names ; On Failure - Returns -1 ; ; Author(s): Tuape, Erik Pilsits ; ;=============================================================================== Func _SysTrayIconProcesses($iWin = 1) Local $pids = _SysTrayIconPids($iWin) If Not IsArray($pids) Then Return -1 Local $processes[uBound($pids)] ; List all processes Local $list = ProcessList() For $i = 0 To UBound($pids) - 1 For $j = 1 To $list[0][0] If $pids[$i] = $list[$j][1] Then $processes[$i] = $list[$j][0] ExitLoop EndIf Next Next Return $processes EndFunc ;==>_SysTrayIconProcesses ;=============================================================================== ; ; Function Name: _SysTrayIconIndex($test, $mode = 0, $iWin = 1) ; Description: Get list of all processes id"s that have systray icon ; Parameter(s): $test - process name / window title text / process PID ; $mode ; | 0 - get index by process name (default) ; | 1 - get index by window title ; | 2 - get index by process PID ; $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; Requirement(s): ; Return Value(s): On Success - Returns index of found icon ; On Failure - Returns -1 ; ; Author(s): Tuape, Erik Pilsits ; ;=============================================================================== Func _SysTrayIconIndex($test, $mode = 0, $iWin = 1) Local $ret = -1, $compare = -1 If $mode < 0 Or $mode > 2 Or Not IsInt($mode) Then Return -1 Switch $mode Case 0 $compare = _SysTrayIconProcesses($iWin) Case 1 $compare = _SysTrayIconTitles($iWin) Case 2 $compare = _SysTrayIconPids($iWin) EndSwitch If Not IsArray($compare) Then Return -1 For $i = 0 To UBound($compare) - 1 If $compare[$i] = $test Then $ret = $i ExitLoop EndIf Next Return $ret EndFunc ;==>_SysTrayIconIndex ; INTERNAL ===================================================================== ; ; Function Name: _SysTrayGetButtonInfo($iIndex = 0, $iWin = 1, $iInfo = 0) ; Description: Gets Tray Button Info ; Parameter(s): $iIndex - icon index (Note: starting from 0) ; $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; $iInfo - Info to return ; | 0 - TBBUTTON structure ; | 1 - owner handle ; | 2 - button tooltip ; | 3 - icon position ; | 4 - icon visibility ; $iHide - extra param to hide/show a button ; | 0 - show button ; | 1 - hide button ; Requirement(s): ; Return Value(s): On Success - Returns requested info ; On Failure - Returns -1 in error situations ; ; Author(s): Erik Pilsits, Tuape ; ;=============================================================================== Func _SysTrayGetButtonInfo($iIndex, $iWin = 1, $iInfo = 0, $iHide = -1) ;========================================================= ; Create the struct _TBBUTTON ; struct { ; int iBitmap; ; int idCommand; ; BYTE fsState; ; BYTE fsStyle; ; ; #ifdef _WIN64 ; BYTE bReserved[6] // padding for alignment ; #elif defined(_WIN32) ; BYTE bReserved[2] // padding for alignment ; #endif ; DWORD_PTR dwData; ; INT_PTR iString; ; } ;========================================================= Local Const $TB_GETBUTTON = 1047 ;~ Local Const $TB_GETBUTTONTEXT = 1099 ;~ Local Const $TB_GETBUTTONINFO = 1089 Local Const $TB_HIDEBUTTON = 1028 ; WM_USER +4 Local Const $TB_GETITEMRECT = 1053 Local $taglocalTBBUTTON If @OSArch = "X86" Then $taglocalTBBUTTON = "int iBitmap;int idCommand;byte fsState;byte fsStyle;byte bReserved[2];uint dwData;int iString" Else ; X64 $taglocalTBBUTTON = "int iBitmap;int idCommand;byte fsState;byte fsStyle;byte bReserved[6];uint64 dwData;int64 iString" EndIf Local Const $ACCESS = BitOR(0x0008, 0x0010, 0x0400) ; VM_OPERATION, VM_READ, QUERY_INFORMATION Local $TBBUTTON = DllStructCreate($taglocalTBBUTTON) Local $ExtraData = DllStructCreate("hwnd[2]") Local $trayHwnd = _FindTrayToolbarWindow($iWin) Local $return = -1 If $trayHwnd = -1 Then Return -1 Local $ret = DllCall("user32.dll", "dword", "GetWindowThreadProcessId", "hwnd", $trayHwnd, "dword*", 0) If @error Or Not $ret[2] Then Return -1 Local $pId = $ret[2] Local $procHandle = DllCall("kernel32.dll", "ptr", "OpenProcess", "dword", $ACCESS, "int", False, "dword", $pId) If @error Or Not $procHandle[0] Then Return -2 Local $lpData = DllCall("kernel32.dll", "ptr", "VirtualAllocEx", "ptr", $procHandle[0], "ptr", 0, "ulong", DllStructGetSize($TBBUTTON), "dword", 0x1000, "dword", 0x04) If Not @error And $lpData[0] Then DllCall("user32.dll", "int", "SendMessageW", "hwnd", $trayHwnd, "uint", $TB_GETBUTTON, "wparam", $iIndex, "lparam", $lpData[0]) DllCall("kernel32.dll", "int", "ReadProcessMemory", "ptr", $procHandle[0], "ptr", $lpData[0], "ptr", DllStructGetPtr($TBBUTTON), "ulong", DllStructGetSize($TBBUTTON), "ulong*", 0) Switch $iInfo Case 0 ; TBBUTTON / hide If $iHide <> -1 Then ;hide/show button Local $visible = Not BitAND(DllStructGetData($TBBUTTON, 3), 8) ;TBSTATE_HIDDEN If ($iHide And Not $visible) Or (Not $iHide And $visible) Then $return = 0 Else $ret = DllCall("user32.dll", "int", "SendMessageW", "hwnd", $trayHwnd, "uint", $TB_HIDEBUTTON, "wparam", DllStructGetData($TBBUTTON, 2), "lparam", $iHide) If @error Or Not $ret[0] Then $return = -1 Else $return = $ret[0] EndIf EndIf Else ; return structure $return = $TBBUTTON EndIf Case 1 ; owner handle DllCall("kernel32.dll", "int", "ReadProcessMemory", "ptr", $procHandle[0], "ptr", DllStructGetData($TBBUTTON, 6), "ptr", DllStructGetPtr($ExtraData), "ulong", DllStructGetSize($ExtraData), "ulong*", 0) $return = DllStructGetData($ExtraData, 1, 1) Case 2 ; 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", "int", "ReadProcessMemory", "ptr", $procHandle[0], "ptr", DllStructGetData($TBBUTTON, 7), "ptr", DllStructGetPtr($intTip), "ulong", DllStructGetSize($intTip), "ulong*", 0) $return = DllStructGetData($intTip, 1) If $return = "" Then $return = "No tooltip text." ;else internal resource EndIf Case 3 ; 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", "int", "SendMessageW", "hwnd", $trayHwnd, "uint", $TB_GETITEMRECT, "wparam", $iIndex, "lparam", $lpData[0]) DllCall("kernel32.dll", "int", "ReadProcessMemory", "ptr", $procHandle[0], "ptr", $lpData[0], "ptr", DllStructGetPtr($RECT), "ulong", DllStructGetSize($RECT), "ulong*", 0) $ret = DllCall("user32.dll", "int", "MapWindowPoints", "hwnd", $trayHwnd, "int", 0, "ptr", DllStructGetPtr($RECT), "int", 2) $pos[0] = DllStructGetData($RECT, 1) $pos[1] = DllStructGetData($RECT, 2) $return = $pos Else $return = -1 EndIf Case 4 ; is visible $return = Not BitAND(DllStructGetData($TBBUTTON, 3), 8) ;TBSTATE_HIDDEN EndSwitch DllCall("kernel32.dll", "int", "VirtualFreeEx", "ptr", $procHandle[0], "ptr", $lpData[0], "ulong", 0, "dword", 0x8000) Else $return = -3 EndIf DllCall("kernel32.dll", "int", "CloseHandle", "ptr", $procHandle[0]) Return $return EndFunc ;==>_SysTrayGetButtonInfo ;=============================================================================== ; ; Function Name: _SysTrayIconHandle($iIndex, $iWin = 1) ; Description: Gets hwnd of window associated with systray icon of given index ; Parameter(s): $iIndex - icon index (Note: starting from 0) ; $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; ; Requirement(s): ; Return Value(s): On Success - Returns hwnd of found icon ; On Failure - Returns -1 ; ; Author(s): Tuape, Erik Pilsits ; ;=============================================================================== Func _SysTrayIconHandle($iIndex, $iWin = 1) Return _SysTrayGetButtonInfo($iIndex, $iWin, 1) EndFunc ;==>_SysTrayIconHandle ;=============================================================================== ; ; Function Name: _SysTrayIconTooltip($iIndex, $iWin = 1) ; Description: Gets the tooltip text of systray icon of given index ; Parameter(s): $iIndex - icon index (Note: starting from 0) ; $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; ; Requirement(s): ; Return Value(s): On Success - Returns tooltip text of icon ; On Failure - Returns -1 ; ; Author(s): Tuape, Erik Pilsits ; ;=============================================================================== Func _SysTrayIconTooltip($iIndex, $iWin = 1) Return _SysTrayGetButtonInfo($iIndex, $iWin, 2) EndFunc ;==>_SysTrayIconTooltip ;=============================================================================== ; ; Function Name: _SysTrayIconPos($iIndex, $iWin = 1) ; Description: Gets x & y position of systray icon ; Parameter(s): $iIndex - icon index (Note: starting from 0) ; $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; ; Requirement(s): ; Return Value(s): On Success - Returns x [0] and y [1] position of icon ; On Failure - Returns -1, also if icon is hidden (Autohide on XP etc.) ; ; Author(s): Tuape, Erik Pilsits ; ;=============================================================================== Func _SysTrayIconPos($iIndex, $iWin = 1) Return _SysTrayGetButtonInfo($iIndex, $iWin, 3) EndFunc ;==>_SysTrayIconPos ;=============================================================================== ; ; Function Name: _SysTrayIconVisible($iIndex, $iWin = 1) ; Description: Gets the visibility of a systray icon ; Parameter(s): $iIndex - icon index (Note: starting from 0) ; $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; ; Requirement(s): ; Return Value(s): On Success - Returns True (visible) or False (hidden) ; On Failure - Returns -1 ; ; Author(s): Tuape, Erik Pilsits ; ;=============================================================================== Func _SysTrayIconVisible($iIndex, $iWin = 1) Return _SysTrayGetButtonInfo($iIndex, $iWin, 4) EndFunc ;==>_SysTrayIconVisible ;=============================================================================== ; ; Function Name: _SysTrayIconHide($index, $iFlag, $iWin) ; Description: Hides / unhides any icon on systray ; ; Parameter(s): $index - icon index. Can be queried with _SysTrayIconIndex() ; $iFlag - hide (1) or show (0) icon ; $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; ; Requirement(s): ; Return Value(s): On Success - Returns 1 if operation was successfull or 0 if ; icon was already hidden/unhidden ; On Failure - Returns -1 ; ; Author(s): Tuape, Erik Pilsits ; ;=============================================================================== Func _SysTrayIconHide($index, $iFlag, $iWin = 1) Return _SysTrayGetButtonInfo($index, $iWin, 0, $iFlag) EndFunc ;==>_SysTrayIconHide ;=============================================================================== ; ; Function Name: _SysTrayIconmove($curPos, $newPos) ; Description: Moves systray icon ; ; Parameter(s): $curPos - icon's current index (0 based) ; $newPos - icon's new position ; ($curPos+1 = one step to right, $curPos-1 = one step to left) ; $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; ; Requirement(s): AutoIt3 Beta ; Return Value(s): On Success - Returns 1 if operation was successfull ; On Failure - If invalid parameters, returns -1 ; ; Author(s): Tuape, Erik Pilsits ; ;=============================================================================== Func _SysTrayIconmove($curPos, $newPos, $iWin = 1) Local Const $TB_MOVEBUTTON = 1106 ; WM_USER +82 Local $iconCount = _SysTrayIconCount($iWin) If $iconCount <= 0 Then Return -1 If $curPos < 0 Or $newPos < 0 Or $curPos > $iconCount - 1 Or $newPos > $iconCount - 1 Or Not IsInt($curPos) Or Not IsInt($newPos) Then Return -1 Local $hWnd = _FindTrayToolbarWindow($iWin) If $hWnd = -1 Then Return -1 Local $ret = DllCall("user32.dll", "int", "SendMessageW", "hwnd", $hWnd, "uint", $TB_MOVEBUTTON, "wparam", $curPos, "lparam", $newPos) If @error Or Not $ret[0] Then Return -1 Return $ret[0] EndFunc ;==>_SysTrayIconmove ;=============================================================================== ; ; Function Name: _SysTrayIconRemove($index=0) ; Description: Removes systray icon completely. ; ; Parameter(s): $index - Icon index (first icon is 0) ; $iWin ; | 1 - ToolbarWindow32, Win2000+ ; | 2 - NotifyIconOverflowWindow, Win7+ ; ; Requirement(s): AutoIt3 Beta ; Return Value(s): On Success - Returns 1 if icon successfully removed ; On Failure - Returns -1 ; ; Author(s): Tuape, Erik Pilsits ; ;=============================================================================== Func _SysTrayIconRemove($index, $iWin = 1) ; added from council of KaFu DLLCall("user32.dll","int","SendMessage", "hwnd", $hWnd, "int", $TB_DELETEBUTTON, "int", $index, "int", 0) ; End of added from council of KaFu Local Const $TB_DELETEBUTTON = 1046 If $index < 0 Or $index > _SysTrayIconCount($iWin) - 1 Then Return -1 Local $hWnd = _FindTrayToolbarWindow($iWin) % Edited September 12, 2012 by apollo13 Link to comment Share on other sites More sharing options...
guinness Posted September 12, 2012 Share Posted September 12, 2012 Use [autoit][/autioit] tags, otherwise you get a block of text, like above. UDF List:  _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
KaFu Posted September 12, 2012 Share Posted September 12, 2012 What OS do you use? I just realized that posting the WM_SETTINGCHANGE only seems to work on XP for me, on Win7 there are still blank icons left. Maybe give this excellent post by Rover a try: Â OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13)Â BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16)Â ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
apollo13 Posted September 13, 2012 Author Share Posted September 13, 2012 KaFuI'm using Win7 Ultimate x64 Sp1 Link to comment Share on other sites More sharing options...
KaFu Posted September 14, 2012 Share Posted September 14, 2012 (edited) Now at least... here's a working example, maybe I'll clean up the code later on, currently only a proof of concept, I'll definitely add it to my program HMW (see sig) ...Based on Rovers nice example and requires Yashieds UDF Tested on XP-32bit-EN and Win7-64bit-DE.expandcollapse popup#AutoIt3Wrapper_UseX64=y #include <SendMessage.au3> #include <WinApi.au3> Global $__hWnd_Shell_TrayWnd = DllCall("user32.dll", "hwnd", "FindWindow", "str", "Shell_TrayWnd", "ptr", 0) $__hWnd_Shell_TrayWnd = $__hWnd_Shell_TrayWnd[0] #include <WinAPIEx_3.8_3380APIConstants.au3> #include <WinAPIEx_3.8_3380WinAPIEx.au3> Global $hWnd = WinGetHandle(AutoItWinGetTitle()) Global $tNOTIFYICONDATA = DllStructCreate($tagNOTIFYICONDATA) OnAutoItExitRegister('OnAutoItExit') DllStructSetData($tNOTIFYICONDATA, 'Size', DllStructGetSize($tNOTIFYICONDATA)) DllStructSetData($tNOTIFYICONDATA, 'hWnd', WinGetHandle(AutoItWinGetTitle())) DllStructSetData($tNOTIFYICONDATA, 'Flags', $NIF_ICON) DllStructSetData($tNOTIFYICONDATA, 'ID', 2) DllStructSetData($tNOTIFYICONDATA, 'hIcon', _WinAPI_ShellExtractIcon(@SystemDir & 'shell32.dll', 166, 16, 16)) _WinAPI_ShellNotifyIcon($NIM_ADD, $tNOTIFYICONDATA) DllStructSetData($tNOTIFYICONDATA, 'ID', 3) DllStructSetData($tNOTIFYICONDATA, 'hIcon', _WinAPI_ShellExtractIcon(@SystemDir & 'shell32.dll', 130, 16, 16)) _WinAPI_ShellNotifyIcon($NIM_ADD, $tNOTIFYICONDATA) DllStructSetData($tNOTIFYICONDATA, 'ID', 4) DllStructSetData($tNOTIFYICONDATA, 'hIcon', _WinAPI_ShellExtractIcon(@SystemDir & 'shell32.dll', 131, 16, 16)) _WinAPI_ShellNotifyIcon($NIM_ADD, $tNOTIFYICONDATA) DllStructSetData($tNOTIFYICONDATA, 'ID', 5) DllStructSetData($tNOTIFYICONDATA, 'hIcon', _WinAPI_ShellExtractIcon(@SystemDir & 'shell32.dll', 132, 16, 16)) _WinAPI_ShellNotifyIcon($NIM_ADD, $tNOTIFYICONDATA) TraySetToolTip("ToolTipTest") Sleep(2000) _RefreshNotificationAreaIcons(0, 1) Sleep(2000) _RefreshNotificationAreaIcons(0, 0) Sleep(2000) Exit #cs Global $ret = _RefreshNotificationAreaIcons(0);User Promoted Notification Area/Notification Area - Win7-2008R2/Vista ConsoleWrite("+User Promoted Notification Area/Notification Area: " & $ret & @LF) $ret = _RefreshNotificationAreaIcons(1);Overflow Notification Area - Win7-2008R2 ConsoleWrite("+Overflow Notification Area: " & $ret & @LF) $ret = _RefreshNotificationAreaIcons(2);System Promoted Notification Area - Win7-2008R2 ;(system clears these after 30 seconds anyway) ConsoleWrite("+System Promoted Notification Area: " & $ret & @LF) #ce ; #FUNCTION# ==================================================================================================== ; Name...........: _RefreshNotificationAreaIcons ; Description ...: Remove Notification Area toolbar buttons (icons) orphaned after an application crash or process close ; Removes icons from all three Notification areas in Win 7/Server 2008R2 32/64 bit versions ; Syntax.........: _RefreshNotificationAreaIcons(0) - User Promoted Notification Area/Notification Area - Win7-2008R2/Vista ; _RefreshNotificationAreaIcons(1) - Overflow Notification Area - Win7-2008R2 ; _RefreshNotificationAreaIcons(2) - System Promoted Notification Area (system clears these after 30 seconds anyway) - Win7-2008R2 ; Return values .: Success Removed icon count ; Failure 0 sets error ; Author ........: rover 28/11/2011 - update of _RefreshTrayIcon() ; Modified.......: ; Remarks .......: Cannot be called from a service. ; Synopsis: Each taskbar Notification Area toolbar button/icon has an applications ; window handle associated with it that receives notification messages from user interaction with the icon. ; This toolbar button removal method tests if the handle is no longer valid, ; and uses the MS recommended API Shell_NotifyIcon to remove them. ; The Shell_NotifyIcon API requires a matching window handle and application identifier to allow icon deletion. ; ; Minimum Operating Systems: Vista, Win 2008, Win 7, Win 2008R2 ; 64 bit OS support. Tested on: Win 7, Win 2008R2 ; Related .......: _RefreshTrayIcon() (for 32 bit Win2k, XP and Vista), _RefreshSystemTray() ; Link ..........; @@MsdnLink@@ Shell_NotifyIcon ; Example .......; Yes ; ; =============================================================================================================== Func _RefreshNotificationAreaIcons($iTbar = 0, $iHide = 0) ; http://www.autoitscript.com/forum/topic/94447-refreshtrayicons-refreshnotificationareaicons-udf-tray-icons-refresh-redux/ ; Rover #cs Switch @OSVersion Case "WIN_2000", "WIN_XP", "WIN_2003", "WIN_XPe" Return SetError(1, 1, 0) EndSwitch #ce Local $hOwnerWin, $i_uID, $aRet, $iRet, $hTrayNotifyWnd, $iButtonCount = 0, _ $hToolbar, $iCount, $iDLLUser32, $iDLLKrnl32, $iDLLShll32, _ $tTBBUTTON, $pTBBUTTON, $iTBBUTTON, $tTRAYDATA, $pTRAYDATA, $iTRAYDATA, _ $tNOTIFYICONDATA, $pNOTIFYICONDATA, $iProcessID, $hProcess, $pAddress $hTrayNotifyWnd = ControlGetHandle(WinGetHandle("[CLASS:Shell_TrayWnd]"), "", "[CLASS:TrayNotifyWnd]") Switch $iTbar Case 0 $hToolbar = ControlGetHandle(ControlGetHandle($hTrayNotifyWnd, "", "[CLASS:SysPager]"), "", "[CLASS:ToolbarWindow32; INSTANCE:1]") Case 1 $hToolbar = ControlGetHandle(WinGetHandle("[CLASS:NotifyIconOverflowWindow]"), "", "[CLASS:ToolbarWindow32; INSTANCE:1]") Case 2 $hToolbar = ControlGetHandle($hTrayNotifyWnd, "", "[CLASS:ToolbarWindow32; INSTANCE:2]") EndSwitch $aRet = DllCall("user32.dll", "lparam", "SendMessageW", "hwnd", $hToolbar, "int", 0x418, "wparam", 0, "lparam", 0) If @error Or $aRet[0] < 1 Then Return SetError(2, @error, 0) $iCount = $aRet[0] - 1 $iProcessID = WinGetProcess($hToolbar) If @error Or $iProcessID = -1 Then Return SetError(3, @error, 0) $aRet = DllCall("kernel32.dll", "ptr", "OpenProcess", "dword", 0x00000018, "int", 0, "int", $iProcessID) If @error Or $aRet[0] = 0 Then Return SetError(4, @error, 0) $hProcess = $aRet[0] $tTBBUTTON = DllStructCreate("int;int;byte;byte;align;dword_ptr;int_ptr") $pTBBUTTON = DllStructGetPtr($tTBBUTTON) $iTBBUTTON = DllStructGetSize($tTBBUTTON) If @error Or $iTBBUTTON = 0 Then Return SetError(5, @error, 0) $aRet = DllCall("kernel32.dll", "ptr", "VirtualAllocEx", "ptr", $hProcess, "ptr", 0, "int", $iTBBUTTON, "dword", 0x00001000, "dword", 0x00000004) If @error Or $aRet[0] = 0 Then DllCall("kernel32.dll", "int", "CloseHandle", "ptr", $hProcess) Return SetError(6, @error, 0) EndIf $pAddress = $aRet[0] $iDLLUser32 = DllOpen("user32.dll") $iDLLKrnl32 = DllOpen("kernel32.dll") $iDLLShll32 = DllOpen("shell32.dll") $tTRAYDATA = DllStructCreate("hwnd;uint;uint;dword[2];ptr") $pTRAYDATA = DllStructGetPtr($tTRAYDATA) $iTRAYDATA = DllStructGetSize($tTRAYDATA) $tNOTIFYICONDATA = DllStructCreate("dword;hwnd;uint;uint;uint;ptr;wchar[128];dword;dword;wchar[256];uint;wchar[64];dword;int;short;short;byte[8];ptr") $pNOTIFYICONDATA = DllStructGetPtr($tNOTIFYICONDATA) DllStructSetData($tNOTIFYICONDATA, 1, DllStructGetSize($tNOTIFYICONDATA)) For $iID = $iCount To 0 Step -1 If IsHWnd($hToolbar) = False Then ExitLoop $aRet = DllCall($iDLLUser32, "lparam", "SendMessageW", "hwnd", $hToolbar, "int", 0x417, "wparam", $iID, "lparam", $pAddress) If @error Or $aRet[0] <> 1 Then ContinueLoop $aRet = DllCall($iDLLKrnl32, "int", "ReadProcessMemory", "ptr", $hProcess, "ptr", $pAddress, "ptr", $pTBBUTTON, "int", $iTBBUTTON, "int*", -1) If @error Or $aRet[5] <> $iTBBUTTON Then ContinueLoop $aRet = DllCall($iDLLKrnl32, "int", "ReadProcessMemory", "ptr", $hProcess, "dword_ptr", DllStructGetData($tTBBUTTON, 5), "ptr", $pTRAYDATA, "int", $iTRAYDATA, "int*", -1) If @error Or $aRet[5] <> $iTRAYDATA Then ContinueLoop $hOwnerWin = DllStructGetData($tTRAYDATA, 1) ; If @error Or $hOwnerWin = 0 Then ContinueLoop ; If IsPtr($hOwnerWin) = 0 Or IsHWnd($hOwnerWin) = True Then ContinueLoop $i_uID = DllStructGetData($tTRAYDATA, 2) If @error Or $i_uID < 0 Then ContinueLoop $iRet = WinGetProcess($hOwnerWin) ; If @error Or $iRet <> -1 Then ContinueLoop DllStructSetData($tNOTIFYICONDATA, 2, $hOwnerWin) DllStructSetData($tNOTIFYICONDATA, 3, $i_uID) DllStructSetData($tNOTIFYICONDATA, 4, 0x8) ; NIF_STATE (0x00000008) If $iHide Then DllStructSetData($tNOTIFYICONDATA, 8, 0x1) ; dwState = NIS_HIDDEN (0x00000001) Else DllStructSetData($tNOTIFYICONDATA, 8, 0x0) EndIf DllStructSetData($tNOTIFYICONDATA, 9, 0x1) ; dwStateMask ; Testing, only for current process If WinGetProcess($hOwnerWin) <> @AutoItPID Then ContinueLoop ; Local Const $TB_HIDEBUTTON = 1028 ; WM_USER +4 $ret = DllCall("user32.dll", "int", "SendMessageW", "hwnd", $hToolbar, "uint", 1028, "wparam", DllStructGetData($tTBBUTTON, 2), "lparam", $iHide) _SendMessage($hToolbar, 0x000B, 0, 0) $aRet = DllCall($iDLLShll32, "int", "Shell_NotifyIconW", "dword", 0x1, "ptr", $pNOTIFYICONDATA) ; NIM_MODIFY (0x00000001) ConsoleWrite($iID & @TAB & $aRet[0] & @CRLF) _SendMessage($hToolbar, 0x000B, 1, 0) ; WM_SETREDRAW 0x000B #cs ::SendMessage(hTrayWnd_dll,WM_SETREDRAW,(WPARAM)FALSE,0); Shell_NotifyIcon(NIM_MODIFY,&nid2); SendMessage(hTrayWnd_dll,WM_SETREDRAW,(WPARAM)TRUE,0); #ce ; $aRet = DllCall($iDLLShll32, "int", "Shell_NotifyIconW", "dword", 0x2, "ptr", $pNOTIFYICONDATA) ; NIM_DELETE (0x00000002) If @error Or $aRet[0] <> 1 Then ContinueLoop $iButtonCount += $aRet[0] Next DllCall("user32.dll", "int", "SendMessageW", "hwnd", $__hWnd_Shell_TrayWnd, "uint", 0x001A, "wparam", 0, "lparam", 0) ; WM_SETTINGCHANGE 0x001A _WinAPI_RedrawWindow($hToolbar) DllCall($iDLLKrnl32, "int", "VirtualFreeEx", "ptr", $hProcess, "ptr", $pAddress, "int", 0, "dword", 0x00008000) DllCall($iDLLKrnl32, "int", "CloseHandle", "ptr", $hProcess) DllClose($iDLLShll32) DllClose($iDLLUser32) DllClose($iDLLKrnl32) Return SetError(0, 0, $iButtonCount) EndFunc ;==>_RefreshNotificationAreaIcons Func OnAutoItExit() DllStructSetData($tNOTIFYICONDATA, 'ID', 2) _WinAPI_ShellNotifyIcon($NIM_DELETE, $tNOTIFYICONDATA) DllStructSetData($tNOTIFYICONDATA, 'ID', 3) _WinAPI_ShellNotifyIcon($NIM_DELETE, $tNOTIFYICONDATA) DllStructSetData($tNOTIFYICONDATA, 'ID', 4) _WinAPI_ShellNotifyIcon($NIM_DELETE, $tNOTIFYICONDATA) DllStructSetData($tNOTIFYICONDATA, 'ID', 5) _WinAPI_ShellNotifyIcon($NIM_DELETE, $tNOTIFYICONDATA) EndFunc ;==>OnAutoItExit Edited September 14, 2012 by KaFu  OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
apollo13 Posted September 15, 2012 Author Share Posted September 15, 2012 Nothing to do. I have installed WINAPI and inserted correct path "include" but... An error are showed: Func_WinAPI_DuplicateHandle... Can you compile your script au3 and send me the EXE that run very well on your computer ? I don't know how do. :-/ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now