Sign in to follow this  
Followers 0
Carlos

Hide icon of a running program

9 posts in this topic

I have running programs that show an trayicon.

How can i hide thes icons?

Share this post


Link to post
Share on other sites



I have running programs that show an trayicon.

How can i hide thes icons?

<{POST_SNAPBACK}>

Opt("TrayIconHide", 1) ;0=show, 1=hide tray icon

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

nice code.

how would you put the icon BACK?


Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Share this post


Link to post
Share on other sites

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.)

<{POST_SNAPBACK}>

Can we use this?

http://www.codeguru.com/Cpp/COM-Tech/shell...icle.php/c1335/

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

I did put the UDF here few days ago: SysTray UDF

I changed function names & functionality a bit. Try it out and give comments or suggestion what could/should be added. Thanks.

Share this post


Link to post
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
Sign in to follow this  
Followers 0