OiMunk Posted February 9, 2008 Share Posted February 9, 2008 I'm having some difficulty getting this script to run properly, it seems to occasionally remove the wrong tray icon. I'm not sure if the TrayIconTitle numbers don't correspond to the _SysTrayIconRemove numbers.. #include "SysTray_UDF.au3" Opt("WinTitleMatchMode", 2) $tray=_SysTrayIconTitles() $count=UBound($tray)-1 for $i = 0 to $count If StringInStr($tray[$i],"onnections") or StringinStr($tray[$i],"troke") or StringinStr($tray[$i],"LCDM")Then ;targets specific icons _SysTrayIconRemove($i) ;removes the icon Sleep(1111) EndIf Next ;any ideas? thanks, Link to comment Share on other sites More sharing options...
rasim Posted February 9, 2008 Share Posted February 9, 2008 (edited) Hi! Try this: expandcollapse popup#include <GuiToolBar.au3> _SysTray_HideItem("Winamp", 1) ;======================================================================================== ; ;$iTitle - The title of the item in Windows system tray ;+(you can see the title of the item when mouse cursor hovered on item, enough substring) ; ;$iState - [optional] The icon state, 1 = hide, 0 = visible, default is 1. ; ;======================================================================================== Func _SysTray_HideItem($iTitle, $iState = 1) If Not $iTitle Then MsgBox(16, "Error", "Please indicate title") Return EndIf Local $hToolbar, $ItemCount, $ID, $i If $iState = 1 Then $iState = $TBSTATE_HIDDEN Else $iState = $TBSTATE_ENABLED EndIf $hToolbar = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]') If @error Then Return $ItemCount = _GUICtrlToolbar_ButtonCount($hToolbar) If $ItemCount = 0 Then Return For $i = 0 To $ItemCount $ID = _GUICtrlToolbar_IndexToCommand($hToolbar, $i) If StringInStr(_GUICtrlToolbar_GetButtonText($hToolbar, $ID), "Winamp") Then _GUICtrlToolbar_SetButtonState($hToolbar, $ID, $iState) Return EndIf Next MsgBox(48, "Message", "Required item not found") EndFunc Edited February 9, 2008 by rasim Link to comment Share on other sites More sharing options...
OiMunk Posted February 9, 2008 Author Share Posted February 9, 2008 (edited) Thanks! I had to replace If StringInStr(_GUICtrlToolbar_GetButtonText($hToolbar, $ID), "WinAmp") Then ;with If StringInStr(_GUICtrlToolbar_GetButtonText($hToolbar, $ID), $iTitle) Then ;but it works perfectly now. cheers, Edited February 9, 2008 by OiMunk Link to comment Share on other sites More sharing options...
MilesAhead Posted February 10, 2008 Share Posted February 10, 2008 Hi! Try this:Very useful script!! I have a Cmd Window with DosKey customizations.. sort of like a clunky Slickrun imitation, that I load on Windows startup. I've been looking everywhere for a means to remove the Taskbar Button without hiding the window or removing it from Alt-Tab list. A few edits to this script and bingo!!! My Freeware Page Link to comment Share on other sites More sharing options...
MilesAhead Posted February 11, 2008 Share Posted February 11, 2008 I've run into a bit of a snag in Vista. What I'm trying to do is: launch the customized command prompt at startup; change its title so that Taskbar grouping won't add onto it if I open another command prompt; then hide the Taskbar button. This snippet works in XP. ShellExecute("C:\Documents and Settings\Owner\Desktop\Command Prompt.lnk") Sleep(1000) If Not WinSetTitle("Command Prompt","","DosKey") Then MsgBox(0,"DosNoTaskButton","Command Prompt Window Not Found",3) Exit EndIf WinActivate("DosKey") _SysTray_HideItem("DosKey", 1) I made the changes for Vista(C:\Users instead of Documents and Settings etc.) and the command prompt launches. I use Title "Administrator: Command Prompt" and WinSetTitle does not complain. But the title in the Command Window is not changed. A bit baffling. My Freeware Page Link to comment Share on other sites More sharing options...
MilesAhead Posted February 11, 2008 Share Posted February 11, 2008 I got it. Just had to use the handle functions instead. WinGetHandle then _WinAPI_SetWindowText. My Freeware Page Link to comment Share on other sites More sharing options...
MilesAhead Posted February 11, 2008 Share Posted February 11, 2008 (edited) I got it. Just had to use the handle functions instead. WinGetHandle then _WinAPI_SetWindowText.Ahh jeez!! There's always another wrinkle when it comes to Windows Shell. Turns out as soon as I run a command, the window title will reset. I was trying to do it the hard way. Looks like the easiest method is to create a shortcut in the Programs Startup Folder from the custom command prompt, and rename it. Then just use the _SysTray_HideItem() to hide the button. Edited February 11, 2008 by MilesAhead My Freeware Page 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