Jump to content

Hide icon of a running program


Recommended Posts

Wouldn't #NoTrayIcon be better? Look at this qoute from the manual:

You can use Opt("TrayIconHide", 1) to remove the AutoIt tray icon, but it will still be visible for a second when the script starts. Placing the #NoTrayIcon directive anywhere in your script will stop the icon from being shown at startup.

Edited by SolidSnake
HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Link to comment
Share on other sites

I think he means hiding icon of "non-AutoIt" program.

I did get this far:

Const $TB_DELETEBUTTON  = 1046
;Const $TB_GETBUTTON = 1047
Const $TB_BUTTONCOUNT = 1048
;Const $TB_GETBUTTONTEXT = 1099

_RemoveTrayButton()

Func _GetToolBarButtonCount()
    Local $hWnd = _FindTrayToolbarWindow()
    Local $count = DLLCall("user32.dll","int","SendMessage", "hwnd", $hWnd[0], "int", $TB_BUTTONCOUNT, "int", 0, "int", 0)
EndFunc

Func _RemoveTrayButton($index=1)
    Local $hWnd = _FindTrayToolbarWindow()
    DLLCall("user32.dll","int","SendMessage", "hwnd", $hWnd[0], "int", $TB_DELETEBUTTON, "int", $index, "int", 0)
    If Not @error Then
        return 1
    Else
        return -1
    EndIf
EndFunc

; Utility function
Func _FindTrayToolbarWindow()
  Local $hWnd = DLLCall("user32.dll","hwnd","FindWindow", "str", "Shell_TrayWnd", "int", 0)
  
  if Not @error Then 
      $hWnd = DLLCall("user32.dll","hwnd","FindWindowEx", "hwnd", $hWnd[0], "int", 0, "str", "TrayNotifyWnd", "int", 0)
     if Not @error Then 
          $hWnd = DLLCall("user32.dll","hwnd","FindWindowEx", "hwnd", $hWnd[0], "int", 0, "str", "SysPager", "int", 0)
          if Not @error Then 
            $hWnd = DLLCall("user32.dll","hwnd","FindWindowEx", "hwnd", $hWnd[0], "int", 0, "str", "ToolbarWindow32", "int", 0)
        
          EndIf
    EndIf
        
  EndIf
           
  Return $hWnd

EndFunc

_RemoveTrayButton removes traybutton which index is given as a parameter. Index 1 is first button from the left (including icons that are hided in XP)..

So the above example will remove first button from the left.

Somebody might want to study if we can identify buttons by other means (text etc.). I took a quick look but it seemed ugly (structures etc.)

Edited by tuape
Link to comment
Share on other sites

Not really, no. I think that this will help you create and remove icon owned by your own program.

However, I did find another reference. It seems that this is quite complicated process involving reading other process' memory.

So far I have succeeded in getting names (=Window titles) of all programs that have icon at systray + removing icons completely from tray.

I will post an UDF to another thread later today. I was thinking to include at least these functions:

SysTrayIconCount() - Get count of all systray icons

SysTrayIconWinTitle($index) - Get wintitle of specific icon

SysTrayIconAllTitles() - Get titles of all programs that have icon on systray

SysTrayIconProcess($index) - Get process name linked to specific icon

SysTrayIconPid($index) - Get parent process id of specific icon

SysTrayIconRemove($index) - Remove icon (removes completely, not just hide)

SysTrayIconIndex($wintitle or $process)

@t0ddie: The above removes icons completely (meaning you have to stop & restart the process owning icon / restart pc to get them back). After I get the first version of this SysTray UDF ready I will take a look of hiding / unhiding icons.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...